From 6c8b08e697f1114ff42d30e3970cef01740f67c6 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 4 Dec 2014 11:21:10 -0800 Subject: [PATCH] add getlastfileindex - probably not necessary. --- lib/bitcoind.js | 4 ++++ src/bitcoindjs.cc | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/bitcoind.js b/lib/bitcoind.js index e03bf259..1480b684 100644 --- a/lib/bitcoind.js +++ b/lib/bitcoind.js @@ -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; diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index 54ac777a..311a7b0e 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -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(blockPos.nFile)); +} + /** * GetBlockHex() * bitcoindjs.getBlockHex(callback) @@ -6494,6 +6515,7 @@ init(Handle 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);