Test
This commit is contained in:
@@ -646,7 +646,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
return;
|
||||
}
|
||||
//fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight);
|
||||
numnotaries = komodo_notaries(pubkeys,pindex->nHeight);
|
||||
numnotaries = komodo_notaries(pubkeys,pindex->nHeight,pindex->GetBlockTime());
|
||||
calc_rmd160_sha256(rmd160,pubkeys[0],33);
|
||||
if ( pindex->nHeight > hwmheight )
|
||||
hwmheight = pindex->nHeight;
|
||||
|
||||
@@ -710,27 +710,28 @@ void komodo_connectpindex(CBlockIndex *pindex)
|
||||
komodo_connectblock(pindex,block);
|
||||
}
|
||||
|
||||
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height);
|
||||
int32_t komodo_electednotary(uint8_t *pubkey33,int32_t height);
|
||||
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
|
||||
int32_t komodo_electednotary(uint8_t *pubkey33,int32_t height,uint32_t timestamp);
|
||||
|
||||
int8_t komodo_minerid(int32_t height,uint8_t *pubkey33)
|
||||
{
|
||||
int32_t num,i; CBlockIndex *pindex; uint8_t _pubkey33[33],pubkeys[64][33];
|
||||
int32_t num,i; CBlockIndex *pindex; uint32_t timestamp=0; uint8_t _pubkey33[33],pubkeys[64][33];
|
||||
if ( pubkey33 == 0 && (pindex= chainActive[height]) != 0 )
|
||||
{
|
||||
timestamp = pindex->GetBlockTime();
|
||||
if ( pubkey33 == 0 )
|
||||
{
|
||||
pubkey33 = _pubkey33;
|
||||
komodo_index2pubkey33(pubkey33,pindex,height);
|
||||
}
|
||||
if ( (num= komodo_notaries(pubkeys,height)) > 0 )
|
||||
if ( (num= komodo_notaries(pubkeys,height,timestamp)) > 0 )
|
||||
{
|
||||
for (i=0; i<num; i++)
|
||||
if ( memcmp(pubkeys[i],pubkey33,33) == 0 )
|
||||
return(i);
|
||||
}
|
||||
}
|
||||
return(komodo_electednotary(pubkey33,height));
|
||||
return(komodo_electednotary(pubkey33,height,timestamp));
|
||||
}
|
||||
|
||||
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *nonzpkeysp,int32_t height)
|
||||
|
||||
@@ -522,7 +522,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin
|
||||
uint32_t komodo_txtime(uint256 hash);
|
||||
uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume);
|
||||
int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel);
|
||||
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height);
|
||||
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
|
||||
char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len);
|
||||
//uint32_t komodo_interest_args(int32_t *txheightp,uint32_t *tiptimep,uint64_t *valuep,uint256 hash,int32_t n);
|
||||
int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width);
|
||||
@@ -581,17 +581,23 @@ UniValue kvsearch(const UniValue& params, bool fHelp)
|
||||
|
||||
UniValue minerids(const UniValue& params, bool fHelp)
|
||||
{
|
||||
UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR); uint8_t minerids[2000],pubkeys[65][33]; int32_t i,j,n,numnotaries,tally[129];
|
||||
uint32_t timestamp = 0; UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR); uint8_t minerids[2000],pubkeys[65][33]; int32_t i,j,n,numnotaries,tally[129];
|
||||
if ( fHelp || params.size() != 1 )
|
||||
throw runtime_error("minerids needs height\n");
|
||||
LOCK(cs_main);
|
||||
int32_t height = atoi(params[0].get_str().c_str());
|
||||
if ( height <= 0 )
|
||||
height = chainActive.Tip()->nHeight;
|
||||
else
|
||||
{
|
||||
CBlockIndex *pblockindex = chainActive[height];
|
||||
if ( pblockindex != 0 )
|
||||
timestamp = pblockindex->GetBlockTime();
|
||||
}
|
||||
if ( (n= komodo_minerids(minerids,height,(int32_t)(sizeof(minerids)/sizeof(*minerids)))) > 0 )
|
||||
{
|
||||
memset(tally,0,sizeof(tally));
|
||||
numnotaries = komodo_notaries(pubkeys,height);
|
||||
numnotaries = komodo_notaries(pubkeys,height,timestamp);
|
||||
if ( numnotaries > 0 )
|
||||
{
|
||||
for (i=0; i<n; i++)
|
||||
|
||||
Reference in New Issue
Block a user