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