This commit is contained in:
blackjok3r
2018-10-27 00:29:21 +08:00
parent fd8fe7b404
commit baa6c49084

View File

@@ -365,6 +365,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp)
int did1 = 0; int did1 = 0;
int skippedtxs = 0; int skippedtxs = 0;
int failed = 0; int failed = 0;
int getfirstblock = 0;
static std::string streamid,firsttxid; static std::string streamid,firsttxid;
static int firsttxnHeight; static int firsttxnHeight;
std::string blockdata; std::string blockdata;
@@ -392,6 +393,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp)
ss >> seqid; ss >> seqid;
if ( seqid == 1 ) { if ( seqid == 1 ) {
streamid = idstr; streamid = idstr;
getfirstblock = 1;
} else if ( seqid == 2 ) { } else if ( seqid == 2 ) {
firsttxid = idstr; firsttxid = idstr;
} else if (firsttxid.empty()) { } else if (firsttxid.empty()) {
@@ -403,7 +405,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp)
streamid.clear(); streamid.clear();
firsttxnHeight = 0; firsttxnHeight = 0;
} }
if ( seqid == (lastseqid + 1) || did1 == 0 ) { if ( seqid == (lastseqid + 1) || did1 == 0 ) {
blockdata.append(data); blockdata.append(data);
} else { } else {
@@ -425,17 +426,16 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp)
} }
i = i + 1; i = i + 1;
} }
if (streamid.empty()) { if (streamid.empty() || getfirstblock == 1) {
if ( lastseqid == 1) {
firsttxid = block.vtx[1].GetHash().GetHex();
}
uint256 hash; CTransaction firsttx; uint256 hash; CTransaction firsttx;
uint256 firsttxid_256(uint256S(firsttxid)); uint256 firsttxid_256(uint256S(firsttxid));
if (GetTransaction(firsttxid_256,firsttx,hash,false)) { if (GetTransaction(firsttxid_256,firsttx,hash,false)) {
std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end());
streamid.append(firststreamid.substr (8,64)); streamid.append(firststreamid.substr (8,64));
printf("first stream id changed to: %s\n", streamid.c_str()); printf("first stream id changed to: %s\n", streamid.c_str());
if ( firstseqid == 1 ) {
firsttxnHeight == pblockindex->nHeight;
printf("first seq id is 1 and found height: %d\n",firsttxnHeight );
} else {
BlockMap::iterator mi = mapBlockIndex.find(hash); BlockMap::iterator mi = mapBlockIndex.find(hash);
if (mi != mapBlockIndex.end() && (*mi).second) { if (mi != mapBlockIndex.end() && (*mi).second) {
CBlockIndex* pindex = (*mi).second; CBlockIndex* pindex = (*mi).second;
@@ -446,7 +446,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp)
} }
} }
} }
}
} else { } else {
failed = 1; failed = 1;
} }