test
This commit is contained in:
@@ -437,7 +437,10 @@ void komodo_block2pubkey33(uint8_t *pubkey33,CBlock& block)
|
|||||||
uint8_t *ptr = (uint8_t *)&block.vtx[0].vout[0].scriptPubKey[0];
|
uint8_t *ptr = (uint8_t *)&block.vtx[0].vout[0].scriptPubKey[0];
|
||||||
#endif
|
#endif
|
||||||
komodo_init(0);
|
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)
|
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);
|
memset(pubkey33,0,33);
|
||||||
if ( pindex != 0 )
|
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
|
#ifndef KOMODO_ZCASH
|
||||||
,Params().GetConsensus()
|
,Params().GetConsensus()
|
||||||
#endif
|
#endif
|
||||||
) != 0 )
|
) != 0 )
|
||||||
{
|
{
|
||||||
komodo_block2pubkey33(pubkey33,block);
|
komodo_block2pubkey33(pubkey33,block);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -467,35 +483,18 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height);
|
|||||||
|
|
||||||
int8_t komodo_minerid(int32_t height)
|
int8_t komodo_minerid(int32_t height)
|
||||||
{
|
{
|
||||||
//static uint32_t depth;
|
int32_t num,i; CBlockIndex *pindex; uint8_t pubkey33[33],pubkeys[64][33];
|
||||||
CBlock block; int32_t notaryid,num,i; CBlockIndex *pindex; uint8_t pubkeys[64][33],script[35];
|
|
||||||
if ( (pindex= chainActive[height]) != 0 )
|
if ( (pindex= chainActive[height]) != 0 )
|
||||||
{
|
{
|
||||||
block.SetNull();
|
komodo_index2pubkey33(pubkey33,pindex,height);
|
||||||
// Open history file to read
|
if ( (num= komodo_notaries(pubkeys,height)) > 0 )
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
fprintf(stderr,"readblockfromdisk err B\n");
|
for (i=0; i<num; i++)
|
||||||
return(-1);
|
if ( memcmp(pubkeys[i],pubkey33,33) == 0 )
|
||||||
}
|
return(i);
|
||||||
if ( gettxout_scriptPubKey(script,sizeof(script),block.vtx[0].GetHash(),0) == 35 )
|
|
||||||
{
|
|
||||||
if ( (num= komodo_notaries(pubkeys,height)) > 0 )
|
|
||||||
{
|
|
||||||
for (i=0; i<num; i++)
|
|
||||||
if ( memcmp(pubkeys[i],&script[1],33) == 0 )
|
|
||||||
{
|
|
||||||
printf("minderid.%d ht.%d\n",i,height);
|
|
||||||
return(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printf("minderid not notary ht.%d\n",height);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user