sync mocked readme updated.

This commit is contained in:
tenthirtyone 2017-08-07 22:09:56 -04:00
parent 5bf176485b
commit fc1284b374
4 changed files with 39 additions and 16 deletions

View File

@ -2,7 +2,7 @@
Rebuilt Bitcore with Bcoin engine and Insight API sitting on top of Mongo.
### Requirements
Mongodo running on your system.
Mongodb running on your system.
node >=7.6.0 - This requirement comes from Bcoin. Developed under 8.2.0.
@ -22,21 +22,30 @@ A configuration object exists in /config/index.js that accepts a config for Bcoi
Mongo will create the bitcore db and a blocks/transactions collection automatically. These collectionss have indexes. Bcoin also syncs to the prefix set in config. To reset/start over you need to drop both collections and delete the bcoin datadir.
Bcoin offers a few database types. The most ideal for our purpose is the in memory database. Unfortunately, Bcoin will not record blockchain sync checkpoints in this mode. Every restart of the client would result in Bcoin sync'ing from the Genesis block. Long term, we should consider sending them a friendly PR.
Alternatively, I've explored putting mongo into Bcoin. The db interface seems simple enough. Bcoin mostly get/puts but it is surprisingly complicated under the hood.
So Bcoin creates its own leveldb.
### Resetting Application State
```
mongo
use bitcore
db.blocks.drop()
db.transactions.drop()
Ctrl+D out of mongo
rm -rf ~/.bcoin/chain.ldb
```
### Nginx
The API is configured to run on port 3000 by default. Use the standard Nginx reverse proxy to flip http to https and handle ssl certs.
The API is configured to run on port 3000 by default. Use the standard Nginx reverse proxy on ports 80/443 to flip http to https and handle ssl certs.
### Priorities
1. Required Insight-UI
1. Required for Insight-UI
* /addr/:addrStr/?noTxList=1
* X /block/:blockhash
@ -44,20 +53,27 @@ The API is configured to run on port 3000 by default. Use the standard Nginx rev
* X /block-index/:blockHeight
* X /currency
* X /version
* /status
* /sync
* X /status - Stubbed. Prior status was for bitcoind
* /sync - Tricky. Bcoin gets the bestHeight from peers but does not save that information. Will show best height - currently Mocked
* X /peer
* X /tx/:txId
* /txs
* /txs
* /txs - Done(ish - no pagination) for most recent txs. Needs block (hash) and address
* sockets
# ToDo
* Mongo Models : Bcoin primitives. A Bcoin block does not present all of bitcore's data.
# ToDo but required for a release
* API Endpoints
* Mongo Models : Bcoin primitives. A Bcoin block primitive does not represent all of bitcore's data.
1. scriptpubkey asm
2. peer's best block height is learned on peer connect but not retained by the app. Block height is the current sync height
# ToDo but not Required for a release
* Reorg testing - Bcoin will handle this but we need to account for this in our mongo indexes.
* JSDoc & Unit tests
* Rate Limiting
* Helmet
* Rate Limiting
* Sanitize user input - mongo and api params. Just make a quick middleware
* Helmet for security
* Caching
* Sanitize user input - mongo and api params. Just make a quick middleware.
* Change Mongo subdocuments into .populate Object Id relationships. This will reduce size & increase performance
* Make the current api the 'legacy' api and setup a real api with uniform verbage/params
* Remove hh:mm:ss from log file names and append to same file for the same day

View File

@ -1,5 +1,5 @@
const config = {
full_node: true,
start_node: true,
logging: 'debug',
bcoin: {
network: 'main',

View File

@ -10,7 +10,7 @@ logger.log('debug',
db.connect(config.mongodb.uri, config.mongodb.options);
db.connection.once('open', () => {
if (config.full_node) Bcoin.start();
if (config.start_node) Bcoin.start();
Api.listen(config.api.port, () => {
logger.log('debug',

View File

@ -13,14 +13,21 @@ module.exports = function statusAPI(router) {
difficulty: 0,
testnet: false,
relayfee: 0,
errors: "",
errors: '',
network: 'main',
},
});
});
router.get('/sync', (req, res) => {
res.send('sync');
res.json({
status: '',
blockChainHeight: 0,
syncPercentage: 0,
height: 0,
error: null,
type: 'bitcore node',
});
});
router.get('/peer', (req, res) => {