leveldb work.
This commit is contained in:
parent
74aa4c1fd0
commit
7cb7346b98
@ -187,7 +187,7 @@ using namespace v8;
|
|||||||
#define EMPTY ("\\x01")
|
#define EMPTY ("\\x01")
|
||||||
|
|
||||||
// LevelDB options
|
// LevelDB options
|
||||||
#define USE_LDB_ADDR 0
|
#define USE_LDB_ADDR 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node.js Exposed Function Templates
|
* Node.js Exposed Function Templates
|
||||||
@ -5888,22 +5888,13 @@ read_addr(const std::string addr) {
|
|||||||
char *k_debug = NULL;
|
char *k_debug = NULL;
|
||||||
try {
|
try {
|
||||||
leveldb::Slice slKey = pcursor->key();
|
leveldb::Slice slKey = pcursor->key();
|
||||||
CDataStream ssKey(slKey.data(), slKey.data() + slKey.size(), SER_DISK, CLIENT_VERSION);
|
if (slKey.ToString().c_str()[0] == 'b') {
|
||||||
std::string key;
|
|
||||||
// XXX ERRORS HERE:
|
|
||||||
ssKey >> key;
|
|
||||||
char type = key.c_str()[0];
|
|
||||||
k_debug = (char *)key.c_str();
|
|
||||||
if (type == 'b') {
|
|
||||||
char *blockhash_ = strdup(key.c_str());
|
|
||||||
blockhash_++;
|
|
||||||
std::string sblockhash = std::string(blockhash_);
|
|
||||||
free(blockhash_);
|
|
||||||
uint256 blockhash(sblockhash);
|
|
||||||
leveldb::Slice slValue = pcursor->value();
|
leveldb::Slice slValue = pcursor->value();
|
||||||
CDataStream ssValue(slValue.data(), slValue.data() + slValue.size(), SER_DISK, CLIENT_VERSION);
|
CDataStream ssValue(slValue.data(), slValue.data() + slValue.size(), SER_DISK, CLIENT_VERSION);
|
||||||
CBlock cblock;
|
CBlock cblock;
|
||||||
ssValue >> cblock;
|
ssValue >> cblock;
|
||||||
|
uint256 blockhash = cblock.GetHash();
|
||||||
|
k_debug = strdup(blockhash.GetHex().c_str());
|
||||||
BOOST_FOREACH(const CTransaction& ctx, cblock.vtx) {
|
BOOST_FOREACH(const CTransaction& ctx, cblock.vtx) {
|
||||||
BOOST_FOREACH(const CTxIn& txin, ctx.vin) {
|
BOOST_FOREACH(const CTxIn& txin, ctx.vin) {
|
||||||
if (txin.scriptSig.ToString() != expectedScriptSig.ToString()) {
|
if (txin.scriptSig.ToString() != expectedScriptSig.ToString()) {
|
||||||
@ -5956,15 +5947,28 @@ read_addr(const std::string addr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
found:
|
found:
|
||||||
|
if (k_debug != NULL) {
|
||||||
|
free(k_debug);
|
||||||
|
}
|
||||||
|
k_debug = NULL;
|
||||||
pcursor->Next();
|
pcursor->Next();
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
head->err_msg = std::string(
|
//head->err_msg = std::string(
|
||||||
e.what()
|
// e.what()
|
||||||
+ std::string(" : Deserialize or I/O error. Key: ")
|
// + std::string(" : Deserialize or I/O error. Key: ")
|
||||||
+ (k_debug != NULL ? std::string(k_debug) : std::string("NULL"))
|
// + (k_debug != NULL ? std::string(k_debug) : std::string("NULL"))
|
||||||
);
|
//);
|
||||||
delete pcursor;
|
|
||||||
return head;
|
if (k_debug != NULL) {
|
||||||
|
free(k_debug);
|
||||||
|
}
|
||||||
|
k_debug = NULL;
|
||||||
|
|
||||||
|
//delete pcursor;
|
||||||
|
//return head;
|
||||||
|
|
||||||
|
pcursor->Next();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user