add getlastfileindex - probably not necessary.

This commit is contained in:
Christopher Jeffrey 2014-12-04 11:21:10 -08:00
parent 3427124270
commit 6c8b08e697
2 changed files with 26 additions and 0 deletions

View File

@ -498,6 +498,10 @@ Bitcoin.prototype.getBlocksByTime = function(options, callback) {
return bitcoindjs.getBlocksByTime(options, callback);
};
Bitcoin.prototype.getLastFileIndex = function() {
return bitcoindjs.getLastFileIndex();
};
Bitcoin.prototype.log =
Bitcoin.prototype.info = function() {
if (this.options.silent) return;

View File

@ -215,6 +215,7 @@ NAN_METHOD(GetBestBlock);
NAN_METHOD(GetChainHeight);
NAN_METHOD(GetBlockByTx);
NAN_METHOD(GetBlocksByTime);
NAN_METHOD(GetLastFileIndex);
NAN_METHOD(GetBlockHex);
NAN_METHOD(GetTxHex);
@ -2381,6 +2382,26 @@ async_block_time_after(uv_work_t *req) {
delete req;
}
/**
* GetLastFileIndex()
* bitcoindjs.getLastFileIndex()
* Get last file index
*/
NAN_METHOD(GetLastFileIndex) {
NanScope();
if (args.Length() > 0) {
return NanThrowError(
"Usage: bitcoindjs.getLastFileIndex(callback)");
}
CBlockIndex *pindex = chainActive.Tip();
CDiskBlockPos blockPos = pindex->GetBlockPos();
NanReturnValue(NanNew<Number>(blockPos.nFile));
}
/**
* GetBlockHex()
* bitcoindjs.getBlockHex(callback)
@ -6494,6 +6515,7 @@ init(Handle<Object> target) {
NODE_SET_METHOD(target, "getChainHeight", GetChainHeight);
NODE_SET_METHOD(target, "getBlockByTx", GetBlockByTx);
NODE_SET_METHOD(target, "getBlocksByTime", GetBlocksByTime);
NODE_SET_METHOD(target, "getLastFileIndex", GetLastFileIndex);
NODE_SET_METHOD(target, "getBlockHex", GetBlockHex);
NODE_SET_METHOD(target, "getTxHex", GetTxHex);
NODE_SET_METHOD(target, "blockFromHex", BlockFromHex);