add GetBestBlock().
This commit is contained in:
parent
3a8ded71b3
commit
f8efdb105e
@ -388,6 +388,11 @@ Bitcoin.prototype.getAddrTransactions = function(addr, callback) {
|
|||||||
return bitcoindjs.getAddrTransactions(addr, callback);
|
return bitcoindjs.getAddrTransactions(addr, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Bitcoin.prototype.getBestBlock = function(callback) {
|
||||||
|
var hash = bitcoindjs.getBestBlock();
|
||||||
|
return bitcoindjs.getBlock(hash, callback);
|
||||||
|
};
|
||||||
|
|
||||||
Bitcoin.prototype.log =
|
Bitcoin.prototype.log =
|
||||||
Bitcoin.prototype.info = function() {
|
Bitcoin.prototype.info = function() {
|
||||||
if (this.options.silent) return;
|
if (this.options.silent) return;
|
||||||
|
|||||||
@ -252,6 +252,7 @@ NAN_METHOD(SetGenerate);
|
|||||||
NAN_METHOD(GetGenerate);
|
NAN_METHOD(GetGenerate);
|
||||||
NAN_METHOD(GetMiningInfo);
|
NAN_METHOD(GetMiningInfo);
|
||||||
NAN_METHOD(GetAddrTransactions);
|
NAN_METHOD(GetAddrTransactions);
|
||||||
|
NAN_METHOD(GetBestBlock);
|
||||||
|
|
||||||
NAN_METHOD(GetBlockHex);
|
NAN_METHOD(GetBlockHex);
|
||||||
NAN_METHOD(GetTxHex);
|
NAN_METHOD(GetTxHex);
|
||||||
@ -2152,6 +2153,30 @@ async_get_addrtx_after(uv_work_t *req) {
|
|||||||
delete req;
|
delete req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GetBestBlock()
|
||||||
|
* bitcoindjs.getBestBlock()
|
||||||
|
* Get the best block
|
||||||
|
*/
|
||||||
|
|
||||||
|
NAN_METHOD(GetBestBlock) {
|
||||||
|
NanScope();
|
||||||
|
|
||||||
|
if (args.Length() < 0) {
|
||||||
|
return NanThrowError(
|
||||||
|
"Usage: bitcoindjs.getBestBlock()");
|
||||||
|
}
|
||||||
|
|
||||||
|
//static CCoinsViewDB *pcoinsdbview = NULL;
|
||||||
|
//pcoinsdbview = new CCoinsViewDB(nCoinDBCache, false, fReindex);
|
||||||
|
//uint256 block_hash = pcoinsdbview->GetBestBlock();
|
||||||
|
|
||||||
|
//CCoinsViewCache &viewChain = *pcoinsTip;
|
||||||
|
uint256 block_hash = pcoinsTip->GetBestBlock();
|
||||||
|
|
||||||
|
NanReturnValue(NanNew<String>(block_hash.GetHex()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GetBlockHex()
|
* GetBlockHex()
|
||||||
* bitcoindjs.getBlockHex(callback)
|
* bitcoindjs.getBlockHex(callback)
|
||||||
@ -5799,6 +5824,7 @@ init(Handle<Object> target) {
|
|||||||
NODE_SET_METHOD(target, "getGenerate", GetGenerate);
|
NODE_SET_METHOD(target, "getGenerate", GetGenerate);
|
||||||
NODE_SET_METHOD(target, "getMiningInfo", GetMiningInfo);
|
NODE_SET_METHOD(target, "getMiningInfo", GetMiningInfo);
|
||||||
NODE_SET_METHOD(target, "getAddrTransactions", GetAddrTransactions);
|
NODE_SET_METHOD(target, "getAddrTransactions", GetAddrTransactions);
|
||||||
|
NODE_SET_METHOD(target, "getBestBlock", GetBestBlock);
|
||||||
NODE_SET_METHOD(target, "getBlockHex", GetBlockHex);
|
NODE_SET_METHOD(target, "getBlockHex", GetBlockHex);
|
||||||
NODE_SET_METHOD(target, "getTxHex", GetTxHex);
|
NODE_SET_METHOD(target, "getTxHex", GetTxHex);
|
||||||
NODE_SET_METHOD(target, "blockFromHex", BlockFromHex);
|
NODE_SET_METHOD(target, "blockFromHex", BlockFromHex);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user