Fix minor issues with rpc
This commit is contained in:
parent
a5a8230166
commit
541a06f5c3
@ -38,7 +38,7 @@ Blocks.blockHashParam = function(req, res, next, blockHash) {
|
||||
*/
|
||||
Blocks.heightParam = function(req, res, next, height) {
|
||||
height = parseInt(height);
|
||||
node.getBlock(height)
|
||||
node.blockService.getBlockByHeight(height)
|
||||
.then(function(block) {
|
||||
req.block = block;
|
||||
})
|
||||
@ -83,7 +83,7 @@ Blocks.list = function(req, res) {
|
||||
};
|
||||
|
||||
Blocks.getLatest = function(req, res) {
|
||||
node.getLatestBlock()
|
||||
node.blockService.getLatest()
|
||||
.then(function(block) {
|
||||
req.block = block;
|
||||
Blocks.get(req, res);
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
var LevelUp = require('levelup');
|
||||
var LevelLock = require('level-lock');
|
||||
var Promise = require('bluebird');
|
||||
var RPC = require('bitcoind-rpc');
|
||||
var TransactionService = require('./transaction');
|
||||
@ -95,7 +94,6 @@ BlockService.prototype.unlock = function() {
|
||||
* @return {bitcore.Block}
|
||||
*/
|
||||
BlockService.blockRPCtoBitcore = function(blockData) {
|
||||
console.log(blockData);
|
||||
$.checkArgument(blockData, 'blockData is required');
|
||||
var block = new bitcore.Block({
|
||||
header: new bitcore.BlockHeader({
|
||||
@ -113,7 +111,7 @@ BlockService.blockRPCtoBitcore = function(blockData) {
|
||||
new bitcore.deps.Buffer(blockData.merkleroot, 'hex')
|
||||
)
|
||||
}),
|
||||
transactions: blockData.transaction
|
||||
transactions: blockData.transactions
|
||||
});
|
||||
block.height = blockData.height;
|
||||
return block;
|
||||
@ -185,12 +183,13 @@ BlockService.prototype.getBlockByHeight = function(height) {
|
||||
|
||||
return Promise.try(function() {
|
||||
|
||||
return self.rpc.getBlockHash(height);
|
||||
return self.rpc.getBlockHashAsync(height);
|
||||
|
||||
})
|
||||
.catch(blockNotFound)
|
||||
.then(function(blockHash) {
|
||||
.then(function(result) {
|
||||
|
||||
var blockHash = result.result;
|
||||
return self.getBlock(blockHash);
|
||||
|
||||
});
|
||||
@ -225,7 +224,6 @@ BlockService.prototype.getLatest = function() {
|
||||
* @return a list of events back to the event bus
|
||||
*/
|
||||
BlockService.prototype.onBlock = function(block) {
|
||||
console.log('block', block);
|
||||
var events = [];
|
||||
return this.save(block)
|
||||
.then(function(block) {
|
||||
|
||||
@ -59,8 +59,7 @@
|
||||
"express": "4.11.1",
|
||||
"glob": "*",
|
||||
"js-yaml": "^3.2.7",
|
||||
"leveldown": "^0.10.4",
|
||||
"levelup": "^0.19.0",
|
||||
"leveldown": "^1.0.1",
|
||||
"moment": "~2.5.0",
|
||||
"morgan": "^1.5.1",
|
||||
"request": "^2.48.0",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user