From 94a292cf10739f3afa9303fc44b7d912689e7566 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 3 Dec 2014 14:38:14 -0800 Subject: [PATCH] parse ldb blocks correctly. --- src/bitcoindjs.cc | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index 4aa5d48b..632d1e5e 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -187,7 +187,7 @@ using namespace v8; #define EMPTY ("\\x01") // LevelDB options -#define USE_LDB_ADDR 0 +#define USE_LDB_ADDR 1 /** * Node.js Exposed Function Templates @@ -6123,6 +6123,9 @@ read_addr(const std::string addr) { // Block Structure: // CBlockHeader - headers + // nHeight + // nTx + // validation state // CDiskBlockPos - block file and pos // CDiskBlockPos - undo file and pos if (type == 'b') { @@ -6136,12 +6139,33 @@ read_addr(const std::string addr) { CBlockHeader header; ssValue >> header; - // XXX This is not being parsed right. Check math/logic. + int nHeight; + ssValue >> nHeight; + + unsigned int nTx; + ssValue >> nTx; + + /* + class CValidationState { + enum mode_state { + MODE_VALID, // everything ok + MODE_INVALID, // network rule violation (DoS value may be set) + MODE_ERROR, // run-time error + } mode; + int nDoS; + std::string strRejectReason; + unsigned char chRejectCode; + bool corruptionPossible; + } + */ + CValidationState valid; + ssValue >> valid; + CDiskBlockPos blockPos; ssValue >> blockPos; - // CDiskBlockPos undoPos; - // ssValue >> undoPos; + CDiskBlockPos undoPos; + ssValue >> undoPos; CBlock cblock;