From 18594cf7017f9c63eea33d4ea871ba0536991551 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Nov 2016 08:50:11 -0300 Subject: [PATCH] test --- src/komodo_bitcoind.h | 53 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 1823ef151..bc5dc0589 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -437,7 +437,10 @@ void komodo_block2pubkey33(uint8_t *pubkey33,CBlock& block) uint8_t *ptr = (uint8_t *)&block.vtx[0].vout[0].scriptPubKey[0]; #endif komodo_init(0); - memcpy(pubkey33,ptr+1,33); + n = block.vtx[0].vout[0].scriptPubKey.size(); + if ( n == 35 ) + memcpy(pubkey33,ptr+1,33); + else memset(pubkey33,0,33); } void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height) @@ -447,14 +450,27 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height) memset(pubkey33,0,33); if ( pindex != 0 ) { - if ( ReadBlockFromDisk(block,(const CBlockIndex *)pindex + block.SetNull(); + // Open history file to read + CAutoFile filein(OpenBlockFile(pindex->GetBlockPos(),true),SER_DISK,CLIENT_VERSION); + if (filein.IsNull()) + return; + // Read block + try { filein >> block; } + catch (const std::exception& e) + { + fprintf(stderr,"readblockfromdisk err B\n"); + return; + } + komodo_block2pubkey33(pubkey33,block); +/* if ( ReadBlockFromDisk(block,(const CBlockIndex *)pindex #ifndef KOMODO_ZCASH ,Params().GetConsensus() #endif ) != 0 ) { komodo_block2pubkey33(pubkey33,block); - } + }*/ } else { @@ -467,35 +483,18 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height); int8_t komodo_minerid(int32_t height) { - //static uint32_t depth; - CBlock block; int32_t notaryid,num,i; CBlockIndex *pindex; uint8_t pubkeys[64][33],script[35]; + int32_t num,i; CBlockIndex *pindex; uint8_t pubkey33[33],pubkeys[64][33]; if ( (pindex= chainActive[height]) != 0 ) { - block.SetNull(); - // Open history file to read - CAutoFile filein(OpenBlockFile(pindex->GetBlockPos(),true),SER_DISK,CLIENT_VERSION); - if (filein.IsNull()) - return(-1); - // Read block - try { filein >> block; } - catch (const std::exception& e) + komodo_index2pubkey33(pubkey33,pindex,height); + if ( (num= komodo_notaries(pubkeys,height)) > 0 ) { - fprintf(stderr,"readblockfromdisk err B\n"); - return(-1); - } - if ( gettxout_scriptPubKey(script,sizeof(script),block.vtx[0].GetHash(),0) == 35 ) - { - if ( (num= komodo_notaries(pubkeys,height)) > 0 ) - { - for (i=0; i