Skip to content

Commit

Permalink
Merge pull request #6 from namebasehq/jacob/ch154/add-requestmissingb…
Browse files Browse the repository at this point in the history
…locks-api-to-full-node

Add requestmissingblocks rpc call
  • Loading branch information
Jacob H. Haven committed Aug 30, 2019
2 parents 96cf7dc + e2ccd56 commit a0ac285
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions lib/node/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ class RPC extends RPCBase {
// this.add('getnameinfo', this.getNameInfo);
// this.add('getnameresource', this.getNameResource);
// this.add('getnameproof', this.getNameProof);

// Namebase use only
this.add('requestmissingblocks', this.requestMissingBlocks);
}

/*
Expand Down Expand Up @@ -2467,6 +2470,20 @@ class RPC extends RPCBase {
return proof.hash().toString('hex');
}

async requestMissingBlocks(args, help) {
if (help || args.length !== 1)
throw new RPCError(errs.MISC_ERROR, 'requestmissingblocks ( "jsonrequestobject" )');

const valid = new Validator(args);
const knownHashes = valid.array(0);

if (!knownHashes)
throw new RPCError(errs.TYPE_ERROR, 'Invalid array of knownHashes.');

this.emit('requestmissingblocks', knownHashes);
return null;
}

/*
* Helpers
*/
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "namebase-hsd",
"version": "0.0.22",
"version": "0.0.23",
"private": false,
"description": "Cryptocurrency bike-shed",
"license": "MIT",
Expand Down

0 comments on commit a0ac285

Please sign in to comment.