From d2fd57faef9ceed644bd88ab8059a3b3a89020dc Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 2 Dec 2014 03:27:08 -0800 Subject: [PATCH] remove overcomplicated code and comments temporarily. --- src/bitcoindjs.cc | 142 ++-------------------------------------------- 1 file changed, 5 insertions(+), 137 deletions(-) diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index d436d6d4..cb9f0b2e 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -405,14 +405,6 @@ static bool g_txindex = false; * Used for async functions and necessary linked lists at points. */ -#if 0 -typedef struct _prev_list { - std::string addr; - int64_t val; - struct _prev_list *next; -} prev_list; -#endif - /** * async_node_data * Where the uv async request data resides. @@ -438,9 +430,6 @@ struct async_block_data { int64_t height; CBlock cblock; CBlockIndex* cblock_index; -#if 0 - prev_list *inputs; -#endif Persistent callback; }; @@ -453,9 +442,6 @@ struct async_tx_data { std::string txHash; std::string blockHash; CTransaction ctx; -#if 0 - prev_list *inputs; -#endif Persistent callback; }; @@ -1019,30 +1005,6 @@ async_get_block(uv_work_t *req) { if (ReadBlockFromDisk(cblock, pblockindex)) { data->cblock = cblock; data->cblock_index = pblockindex; -#if 0 - BOOST_FOREACH(const CTransaction& ctx, cblock.vtx) { - BOOST_FOREACH(const CTxIn& txin, ctx.vin) { - CTransaction prev_tx; - if (GetTransaction(txin.prevout.hash, prev_tx, block_hash, true)) { - CTxDestination from; - CTxOut prev_out = prev_tx.vout[txin.prevout.n]; - ExtractDestination(prev_out.scriptPubKey, from); - CBitcoinAddress addrFrom(from); - std::string addr = addrFrom.ToString(); - int64_t val = (int64_t)prev_out.nValue; - prev_list *cur = new prev_list(); - cur->addr = addr; - cur->val = val; - if (data->inputs == NULL) { - data->inputs = cur; - } else { - data->inputs->next = cur; - data->inputs = cur; - } - } - } - } -#endif } else { data->err_msg = std::string("get_block(): failed."); } @@ -1069,24 +1031,6 @@ async_get_block_after(uv_work_t *req) { Local jsblock = NanNew(); cblock_to_jsblock(cblock, cblock_index, jsblock, false); -#if 0 - prev_list *head = data->inputs; - prev_list *cur = data->inputs; - prev_list *next; - for (int i = 0; i < jsblock->tx->ength(); i++) { - for (int j = 0; j < jstx->vin->Length(); j++) { - next = cur->next; - jsblock. - Local jsprev = NanNew(); - jsprev->Set(NanNew("address"), NanNew(cur->addr)); - jsprev->Set(NanNew("value"), NanNew(cur->val)); - jsblock->tx->Get(i)->vin->Get(j)->Set(NanNew("prev"), jsprev); - delete cur; - cur = next; - } - } -#endif - const unsigned argc = 2; Local argv[argc] = { Local::New(Null()), @@ -1184,28 +1128,6 @@ async_get_tx(uv_work_t *req) { collect_prev: return; -#if 0 - BOOST_FOREACH(const CTxIn& txin, ctx.vin) { - CTransaction prev_tx; - if (GetTransaction(txin.prevout.hash, prev_tx, block_hash, true)) { - CTxDestination from; - CTxOut prev_out = prev_tx.vout[txin.prevout.n]; - ExtractDestination(prev_out.scriptPubKey, from); - CBitcoinAddress addrFrom(from); - std::string addr = addrFrom.ToString(); - int64_t val = (int64_t)prev_out.nValue; - prev_list *cur = new prev_list(); - cur->addr = addr; - cur->val = val; - if (data->inputs == NULL) { - data->inputs = cur; - } else { - data->inputs->next = cur; - data->inputs = cur; - } - } - } -#endif } static void @@ -1233,22 +1155,6 @@ async_get_tx_after(uv_work_t *req) { Local jstx = NanNew(); ctx_to_jstx(ctx, block_hash, jstx); - // XXX Do this for GetBlock, and PacketHook -#if 0 - prev_list *head = data->inputs; - prev_list *cur = data->inputs; - prev_list *next; - for (int i = 0; i < jstx->vin->Length(); i++) { - next = cur->next; - Local jsprev = NanNew(); - jsprev->Set(NanNew("address"), NanNew(cur->addr)); - jsprev->Set(NanNew("value"), NanNew(cur->val)); - jstx->vin->Get(i)->Set(NanNew("prev"), jsprev); - delete cur; - cur = next; - } -#endif - const unsigned argc = 2; Local argv[argc] = { Local::New(Null()), @@ -1916,23 +1822,6 @@ NAN_METHOD(GetMiningInfo) { json_spirit::Array empty_params; - // (json_spirit::Value)GetNetworkHashPS(120 /* blocks=-1 */, -1 /* height=x */); - // (int64_t)GetNetworkHashPS(120 /* blocks=-1 */, -1 /* height=x */).get_int64(); - // (int64_t)getnetworkhashps(empty_params, false).get_int64(); - - // (json_spirit::Value)getgenerate(empty_params, false); - // (bool)getgenerate(empty_params, false).get_bool(); - // (bool)GetBoolArg("-gen", false); - - // (json_spirit::Value)gethashespersec(empty_params, false); - // (int64_t)gethashespersec(empty_params, false).get_int64(); - // int64_t hashespersec = 0; - // if (GetTimeMillis() - nHPSTimerStart > 8000) { - // hashespersec = (int64_t)0; - // } else { - // hashespersec = (int64_t)dHashesPerSec; - // } - obj->Set(NanNew("blocks"), NanNew((int)chainActive.Height())); obj->Set(NanNew("currentblocksize"), NanNew((uint64_t)nLastBlockSize)); obj->Set(NanNew("currentblocktx"), NanNew((uint64_t)nLastBlockTx)); @@ -2042,10 +1931,6 @@ async_get_addrtx(uv_work_t *req) { int64_t i = 0; - // Check the last 20,000 blocks - // int64_t i = chainActive.Height() - 20000; - // if (i < 0) i = 0; - if (data->blockindex != -1) { i = data->blockindex; } @@ -2599,16 +2484,7 @@ NAN_METHOD(HookPackets) { vRecv >> block; Local jsblock = NanNew(); cblock_to_jsblock(block, NULL, jsblock, true); - // cblock_to_jsblock(block, NULL, o, true); - // last_block_hash = block.GetHash(); o->Set(NanNew("block"), jsblock); - // XXX Can now directly access the DB: -#if 0 - leveldb::Iterator* pcursor = pblocktree->pdb->NewIterator(pblocktree->iteroptions); - pcursor->SeekToFirst(); - while (pcursor->Valid()); -#endif - } else if (strCommand == "getaddr") { ; // not much other information in getaddr as long as we know we got a getaddr } else if (strCommand == "mempool") { @@ -5884,17 +5760,12 @@ jstx_to_ctx(const Local jstx, CTransaction& ctx_) { Local in = Local::Cast(vin->Get(vi)); - //if (ctx.IsCoinBase()) { - // txin.prevout.hash = uint256(0); - // txin.prevout.n = (unsigned int)0; - //} else { - String::AsciiValue phash__(in->Get(NanNew("txid"))->ToString()); - std::string phash_ = *phash__; - uint256 phash(phash_); + String::AsciiValue phash__(in->Get(NanNew("txid"))->ToString()); + std::string phash_ = *phash__; + uint256 phash(phash_); - txin.prevout.hash = phash; - txin.prevout.n = (unsigned int)in->Get(NanNew("vout"))->Uint32Value(); - //} + txin.prevout.hash = phash; + txin.prevout.n = (unsigned int)in->Get(NanNew("vout"))->Uint32Value(); std::string shash_; Local script_obj = Local::Cast(in->Get(NanNew("scriptSig"))); @@ -6194,9 +6065,6 @@ error: static int64_t SatoshiFromAmount(const CAmount& amount) { - // ./core.h : static const int64_t COIN = 100000000; - // ValueFromAmount: - // return (double)amount / (double)COIN; return (int64_t)amount; }