WOW! it works

This commit is contained in:
blackjok3r
2018-10-25 01:09:19 +08:00
parent 659f97c027
commit 426015aa75

View File

@@ -321,7 +321,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp)
return chainActive.Height(); return chainActive.Height();
*/ */
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
unsigned int firstseqid,lastseqid,i,did1; signed int firstseqid,lastseqid,i,did1;
static std::string streamid,firsttxid; static std::string streamid,firsttxid;
std::string blockdata; std::string blockdata;
fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size());
@@ -332,9 +332,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp)
// ignore first and last TX and any TX that does not have 3 vouts. // ignore first and last TX and any TX that does not have 3 vouts.
if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) ) if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) )
{ {
fprintf(stderr, "skipped tx number: %u \n",i); fprintf(stderr, "skipped tx number: %d \n",i);
} else { } else {
fprintf(stderr, "added tx number: %u \n",i); fprintf(stderr, "added tx number: %d \n",i);
std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end());
if ( opretstr.size() > 81 ) { if ( opretstr.size() > 81 ) {
std::string idstr = opretstr.substr (8,64); // stream ID or txid std::string idstr = opretstr.substr (8,64); // stream ID or txid
@@ -346,7 +346,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp)
ss >> seqid; ss >> seqid;
if ( seqid == 1 ) { if ( seqid == 1 ) {
streamid = idstr; streamid = idstr;
printf("streamid: %s\n",streamid.c_str()); } else if ( seqid == 2 ) {
firsttxid = idstr;
} }
if ( seqid == (lastseqid + 1 )) { if ( seqid == (lastseqid + 1 )) {
blockdata.append(data); blockdata.append(data);
@@ -354,7 +355,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp)
if ( did1 == 0 ) { if ( did1 == 0 ) {
firstseqid = seqid; firstseqid = seqid;
did1 = 1; did1 = 1;
printf("DID 1 first seqid = %u\n", firstseqid);
} }
lastseqid = seqid; lastseqid = seqid;
} }
@@ -364,6 +364,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp)
i = i + 1; i = i + 1;
} }
result.push_back(Pair("streamid", streamid)); result.push_back(Pair("streamid", streamid));
result.push_back(Pair("firsttxid", firsttxid));
result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("firstseqid", (int)firstseqid));
result.push_back(Pair("lastseqid", (int)lastseqid)); result.push_back(Pair("lastseqid", (int)lastseqid));
result.push_back(Pair("data", blockdata)); result.push_back(Pair("data", blockdata));