test
This commit is contained in:
@@ -33,12 +33,12 @@
|
|||||||
#include "uthash.h"
|
#include "uthash.h"
|
||||||
#include "utlist.h"
|
#include "utlist.h"
|
||||||
|
|
||||||
#include "komodo_structs.h"
|
int32_t gettxout_scriptPubKey(uint8_t *scriptPubkey,int32_t maxsize,uint256 txid,int32_t n);
|
||||||
|
|
||||||
|
#include "komodo_structs.h"
|
||||||
#include "komodo_globals.h"
|
#include "komodo_globals.h"
|
||||||
#include "komodo_utils.h"
|
#include "komodo_utils.h"
|
||||||
|
|
||||||
|
|
||||||
void komodo_setkmdheight(int32_t kmdheight)
|
void komodo_setkmdheight(int32_t kmdheight)
|
||||||
{
|
{
|
||||||
if ( kmdheight > KMDHEIGHT )
|
if ( kmdheight > KMDHEIGHT )
|
||||||
|
|||||||
@@ -463,12 +463,27 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t komodo_currentheight();
|
|
||||||
int8_t komodo_minerid(int32_t height)
|
int8_t komodo_minerid(int32_t height)
|
||||||
{
|
{
|
||||||
static uint32_t depth;
|
//static uint32_t depth;
|
||||||
int32_t notaryid; CBlockIndex *pindex; uint8_t pubkey33[33];
|
int32_t notaryid,num,i; CBlockIndex *pindex; uint8_t pubkeys[64][33],script[35];
|
||||||
if ( Minerids[height] >= -1 )
|
if ( (pindex= chainActive[height]) != 0 )
|
||||||
|
{
|
||||||
|
if ( gettxout_scriptPubKey(script,sizeof(script),pindex->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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(-1);
|
||||||
|
/*if ( Minerids[height] >= -1 )
|
||||||
{
|
{
|
||||||
printf("cached[%d] -> %d\n",height,Minerids[height]);
|
printf("cached[%d] -> %d\n",height,Minerids[height]);
|
||||||
return(Minerids[height]);
|
return(Minerids[height]);
|
||||||
@@ -493,7 +508,7 @@ int8_t komodo_minerid(int32_t height)
|
|||||||
depth--;
|
depth--;
|
||||||
return(notaryid);
|
return(notaryid);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
return(-2);
|
return(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -510,7 +525,7 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33])
|
|||||||
Minerids[height-i] = komodo_minerid(height-i);
|
Minerids[height-i] = komodo_minerid(height-i);
|
||||||
if ( Minerids[height - i] == -2 )
|
if ( Minerids[height - i] == -2 )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"second -2 for Minerids[%d] current.%d\n",height-i,komodo_currentheight());
|
fprintf(stderr,"second -2 for Minerids[%d] current.%d\n",height-i,komodo_currentheight());
|
||||||
return(-2);
|
return(-2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -589,6 +589,29 @@ Value gettxout(const Array& params, bool fHelp)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t gettxout_scriptPubKey(uint8_t *scriptPubkey,int32_t maxsize,uint256 txid,int32_t n)
|
||||||
|
{
|
||||||
|
int32_t i,m; uint8_t *ptr;
|
||||||
|
LOCK(cs_main);
|
||||||
|
CCoins coins;
|
||||||
|
if (fMempool)
|
||||||
|
{
|
||||||
|
LOCK(mempool.cs);
|
||||||
|
CCoinsViewMemPool view(pcoinsTip,mempool);
|
||||||
|
if ( view.GetCoins(txid,coins) == 0 )
|
||||||
|
return(-1);
|
||||||
|
mempool.pruneSpent(txid, coins); // TODO: this should be done by the CCoinsViewMemPool
|
||||||
|
} else if ( pcoinsTip->GetCoins(txid,coins) == 0 )
|
||||||
|
return(-1);
|
||||||
|
if ( n < 0 || (unsigned int)n >= coins.vout.size() || coins.vout[n].IsNull() )
|
||||||
|
return(-1);
|
||||||
|
ptr = (uint8_t *)coins.vout[n].scriptPubKey.data();
|
||||||
|
m = coins.vout[n].scriptPubKey.size();
|
||||||
|
for (i=0; i<maxsize&&i<m; i++)
|
||||||
|
scriptPubKey[i] = ptr[i];
|
||||||
|
return(i);
|
||||||
|
}
|
||||||
|
|
||||||
Value verifychain(const Array& params, bool fHelp)
|
Value verifychain(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() > 2)
|
if (fHelp || params.size() > 2)
|
||||||
|
|||||||
Reference in New Issue
Block a user