Git Product home page Git Product logo

api-server's People

Contributors

decryp2kanon avatar itwysgsl avatar nugetzrul3 avatar volbil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

api-server's Issues

enable multi threading

this is single thread and slow

$ python3 app.py

By doing python3 app.py you running api server in single thread with development server, which is highly not recommendation for production

Volbil, [08.02.20 11:03]
There is couple ways to do that, I'm personally using gunicorn and systemd

Volbil, [08.02.20 11:33]
Well, it's not a python but flask server

Volbil, [08.02.20 11:33]
Framework which I'm using

Volbil, [08.02.20 11:39]
Also debug server is bad for production

Volbil, [08.02.20 11:39]
Since it can expose some debug consoles and etc

Volbil, [08.02.20 11:39]
[Forwarded from Fork]
pip3 install gunicorn
pip3 install eventlet
gunicorn app:app --worker-class eventlet -w 1 --bind 0.0.0.0:5000 --reload

Volbil, [08.02.20 11:39]
[In reply to Volbil]
[Unit]
Description=uWSGI instance to serve sugar api
After=network.target

[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/api
Environment="PATH=/home/ubuntu/api/venv/bin"
ExecStart=/home/ubuntu/api/venv/bin/gunicorn app:app --worker-class eventlet -w 1 --bind 0.0.0.0:5000 --reload

[Install]
WantedBy=multi-user.target

Volbil, [08.02.20 11:39]
[In reply to Volbil]
Systemd config

https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-18-04

https://blog.fossasia.org/setting-up-nginx-gunicorn-and-flask-socketio/

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04#set-up-nginx-as-a-reverse-proxy-server

api.sugarchain.org ERRORING

api.sugarchain.org has been erroring for at least more than 2 weeks now, since at least July 27th. In the mentioned link several example requests result in a 404 with the message invalid request. In the same time period also the web wallet has shown no coin amount (just says loading and nothing happens).

won't start after esplora

version

commit 7c5ce87d226e623b913b0f4c03441534e22ed2b0
Author: volbil <[email protected]>
Date:   Fri Jun 5 19:10:22 2020 +0900

    Fix spent info method

daemon (still syncing)

$HOME/sugarchain/src/sugarchaind -server=1 -rpcuser=rpcuser -rpcpassword=rpcpassword -testnet -txindex=1 -addressindex -spentindex -daemon

error

$ python3 app.py
Traceback (most recent call last):
  File "app.py", line 1, in <module>
    from server import config
  File "/root/api-server/server/__init__.py", line 28, in <module>
    from server import esplora
  File "/root/api-server/server/esplora.py", line 101
    return Response(f"start index must be a multipication of {config.tx_page}", mimetype="text/plain", status=400)
                                                                             ^
SyntaxError: invalid syntax

config (testnet)

$ cat config.py 
rid = 'api-server'
cache = 3600  # Cache request for 1 hour
secret = 'PASSWORD'
endpoint = 'http://rpcuser:[email protected]:44229/' # Testnet5
host = '0.0.0.0'
port = 1234
debug = False
block_page = 10
tx_page = 25

whats missing in config?

reindex required after -spentindex(esplora)

You need to rebuild the database using -reindex to change -spentindex. Please restart with -reindex or -reindex-chainstate to recover.

2020-06-14 20:02:57 Checking all blk files are present...
2020-06-14 20:02:58 LoadBlockIndexDB: address index enabled
2020-06-14 20:02:58 LoadBlockIndexDB: timestamp index disabled
2020-06-14 20:02:58 LoadBlockIndexDB: spent index disabled
2020-06-14 20:02:58 LoadBlockIndexDB: transaction index enabled
2020-06-14 20:02:58 : You need to rebuild the database using -reindex to change -spentindex.
Please restart with -reindex or -reindex-chainstate to recover.
2020-06-14 20:02:58 Aborted block database rebuild. Exiting.
2020-06-14 20:02:58 Shutdown: In progress...
2020-06-14 20:02:58 scheduler thread interrupt
2020-06-14 20:02:58 Shutdown: done
  • try -reindex-chainstate: not working
  • try -reindex or sync again from zero

$HOME/sugarchain/src/sugarchaind -server=1 -rpcuser=rpcuser -rpcpassword=rpcpassword -testnet -txindex=1 -addressindex -spentindex -daemon

suggest: adding some API calls

getnetworkinfo
https://bitcoin.stackexchange.com/questions/13165/check-which-bitcoind-version-i-am-running

{
  "version": 160330,
  "subversion": "/Yumekawa:0.16.3.30/",
  "protocolversion": 70015,
  "localservices": "000000000000040d",
  "localrelay": true,
  "timeoffset": 0,
  "networkactive": true,
  "connections": 7,
  "networks": [
    {
      "name": "ipv4",
      "limited": false,
      "reachable": true,
      "proxy": "",
      "proxy_randomize_credentials": false
    },
    {
      "name": "ipv6",
      "limited": false,
      "reachable": true,
      "proxy": "",
      "proxy_randomize_credentials": false
    },
    {
      "name": "onion",
      "limited": true,
      "reachable": false,
      "proxy": "",
      "proxy_randomize_credentials": false
    }
  ],
  "relayfee": 0.00001000,
  "incrementalfee": 0.00001000,
  "localaddresses": [
  ],
  "warnings": ""
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.