From 7c454e84811391a008c400d61caaf576e3d9a717 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 22 Oct 2014 16:13:46 -0700 Subject: [PATCH] all packets finally implemented. --- src/bitcoindjs.cc | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index f8d7bc31..a4cf4572 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -3399,7 +3399,7 @@ NAN_METHOD(HookPackets) { o->Set(NanNew("received"), NanNew((int64_t)cur->nTimeReceived)); o->Set(NanNew("peerId"), NanNew(pfrom->id)); //o->Set(NanNew("peerId"), NanNew(pfrom->GetId())); - // pfrom->cleanSubVer, // string + o->Set(NanNew("versionMessage"), NanNew(pfrom->cleanSubVer.c_str())); if (strCommand == "version") { #if 0 @@ -3634,12 +3634,15 @@ NAN_METHOD(HookPackets) { if (pfrom->nVersion > BIP0031_VERSION) { uint64_t nonce = 0; cur->vRecv >> nonce; - char snonce[21] = {0}; - int written = snprintf(snonce, sizeof(snonce), "%020lu", (uint64_t)nonce); + char sNonce[21] = {0}; + int written = snprintf(sNonce, sizeof(sNonce), "%020lu", (uint64_t)nonce); assert(written == 20); - o->Set(NanNew("nonce"), NanNew(snonce)); + o->Set(NanNew("nonce"), NanNew(sNonce)); } else { - o->Set(NanNew("nonce"), NanNew("0")); + char sNonce[21] = {0}; + int written = snprintf(sNonce, sizeof(sNonce), "%020lu", (uint64_t)0); + assert(written == 20); + o->Set(NanNew("nonce"), NanNew(sNonce)); } } else if (strCommand == "pong") { int64_t pingUsecEnd = nTimeReceived; @@ -3761,11 +3764,11 @@ NAN_METHOD(HookPackets) { } } } else if (strCommand == "filterclear") { - ; + ; // nothing much to grab from this packet } else if (strCommand == "reject") { - ; + ; // nothing much to grab from this packet } else { - ; + o->Set(NanNew("unknown"), NanNew(true)); } // Update the last seen time for this node's address @@ -3775,7 +3778,7 @@ NAN_METHOD(HookPackets) { || strCommand == "inv" || strCommand == "getdata" || strCommand == "ping") { - ; + o->Set(NanNew("connected"), NanNew(true)); } }