diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index 956890c5..08cd27d8 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -3569,7 +3569,24 @@ NAN_METHOD(HookPackets) { o->Set(NanNew("first"), NanNew(vInv[0].ToString().c_str())); } } else if (strCommand == "getblocks") { - ; + CBlockLocator locator; + uint256 hashStop; + cur->vRecv >> locator >> hashStop; + + LOCK(cs_main); + + // Find the last block the caller has in the main chain + CBlockIndex* pindex = FindForkInGlobalIndex(chainActive, locator); + + // Send the rest of the chain + if (pindex) { + pindex = chainActive.Next(pindex); + } + + o->Set(NanNew("peerId"), NanNew(pfrom->id)); + o->Set(NanNew("fromHeight"), NanNew(pindex ? pindex->nHeight : -1); + o->Set(NanNew("toHash"), NanNew(hashStop == uint256(0) ? "end" : hashStop.ToString())); + o->Set(NanNew("limit"), NanNew(nLimit)); } else if (strCommand == "getheaders") { ; } else if (strCommand == "tx") {