23
src/komodo.h
23
src/komodo.h
@@ -501,19 +501,26 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
numvouts = block.vtx[i].vout.size();
|
||||
notaryid = -1;
|
||||
voutmask = specialtx = notarizedheight = isratification = notarized = 0;
|
||||
signedmask = 1;
|
||||
signedmask = (height < 91400) ? 1 : 0;
|
||||
numvins = block.vtx[i].vin.size();
|
||||
for (j=0; j<numvins; j++)
|
||||
{
|
||||
if ( i == 0 && j == 0 )
|
||||
continue;
|
||||
if ( (scriptlen= gettxout_scriptPubKey(scriptPubKey,sizeof(scriptPubKey),block.vtx[i].vin[j].prevout.hash,block.vtx[i].vin[j].prevout.n)) > 0 )
|
||||
{
|
||||
if ( (k= komodo_notarycmp(scriptPubKey,scriptlen,pubkeys,numnotaries,rmd160)) >= 0 )
|
||||
signedmask |= (1LL << k);
|
||||
}
|
||||
else if ( numvins >= 17 )
|
||||
{
|
||||
int32_t k;
|
||||
for (k=0; k<scriptlen; k++)
|
||||
printf("%02x",scriptPubKey[k]);
|
||||
printf(" scriptPubKey doesnt match any notary\n");
|
||||
}
|
||||
} else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j);
|
||||
}
|
||||
numvalid = bitweight(signedmask);
|
||||
//if ( height == 79633 )
|
||||
// notarized = 1;
|
||||
if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries/3)) )
|
||||
{
|
||||
printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts);
|
||||
@@ -538,10 +545,14 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d notarized.%d special.%d isratification.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts,notarized,specialtx,isratification);
|
||||
if ( notarized != 0 && (notarizedheight != 0 || specialtx != 0) )
|
||||
{
|
||||
//printf("%s NOTARY SIGNED.%llx numvins.%d ht.%d txi.%d notaryht.%d specialtx.%d\n",ASSETCHAINS_SYMBOL,(long long)signedmask,numvins,height,i,notarizedheight,specialtx);
|
||||
//printf("ht.%d specialtx.%d isratification.%d numvouts.%d signed.%llx numnotaries.%d\n",height,specialtx,isratification,numvouts,(long long)signedmask,numnotaries);
|
||||
if ( isratification != 0 )
|
||||
{
|
||||
printf("%s NOTARY SIGNED.%llx numvins.%d ht.%d txi.%d notaryht.%d specialtx.%d\n",ASSETCHAINS_SYMBOL,(long long)signedmask,numvins,height,i,notarizedheight,specialtx);
|
||||
printf("ht.%d specialtx.%d isratification.%d numvouts.%d signed.%llx numnotaries.%d\n",height,specialtx,isratification,numvouts,(long long)signedmask,numnotaries);
|
||||
}
|
||||
if ( specialtx != 0 && isratification != 0 && numvouts > 2 )
|
||||
{
|
||||
numvalid = 0;
|
||||
|
||||
17
src/main.cpp
17
src/main.cpp
@@ -2555,6 +2555,7 @@ static int64_t nTimePostConnect = 0;
|
||||
* corresponding to pindexNew, to bypass loading it again from disk.
|
||||
*/
|
||||
bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *pblock) {
|
||||
|
||||
assert(pindexNew->pprev == chainActive.Tip());
|
||||
mempool.check(pcoinsTip);
|
||||
// Read block from disk.
|
||||
@@ -2703,7 +2704,21 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
|
||||
if (!DisconnectTip(state))
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( 0 )
|
||||
{
|
||||
static int32_t didinit;
|
||||
if ( didinit++ == 0 )
|
||||
{
|
||||
while (chainActive.Tip()->nHeight > 91418 )
|
||||
{
|
||||
fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight);
|
||||
if ( !DisconnectTip(state) )
|
||||
return false;
|
||||
}
|
||||
pindexOldTip = chainActive.Tip();
|
||||
pindexFork = chainActive.FindFork(pindexMostWork);
|
||||
}
|
||||
}
|
||||
// Build list of new blocks to connect.
|
||||
std::vector<CBlockIndex*> vpindexToConnect;
|
||||
bool fContinue = true;
|
||||
|
||||
@@ -661,7 +661,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
int32_t nseconds = Mining_start+ROUNDROBIN_DELAY-time(NULL);
|
||||
if ( nseconds > 0 )
|
||||
sleep(nseconds);
|
||||
MilliSleep((rand() % 3700) + 1);
|
||||
MilliSleep((rand() % 700) + 1);
|
||||
}
|
||||
KOMODO_CHOSEN_ONE = 1;
|
||||
// Found a solution
|
||||
|
||||
@@ -677,29 +677,6 @@ Value gettxout(const Array& params, bool fHelp)
|
||||
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 ( 1 )
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (fHelp || params.size() > 2)
|
||||
|
||||
@@ -253,6 +253,56 @@ Value getrawtransaction(const Array& params, bool fHelp)
|
||||
return result;
|
||||
}
|
||||
|
||||
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;
|
||||
for (iter=0; iter<2; iter++)
|
||||
{
|
||||
if ( iter == 0 )
|
||||
{
|
||||
LOCK(mempool.cs);
|
||||
CCoinsViewMemPool view(pcoinsTip,mempool);
|
||||
if ( view.GetCoins(txid,coins) == 0 )
|
||||
{
|
||||
//fprintf(stderr,"cant get view\n");
|
||||
continue;
|
||||
}
|
||||
mempool.pruneSpent(txid, coins); // TODO: this should be done by the CCoinsViewMemPool
|
||||
}
|
||||
else if ( pcoinsTip->GetCoins(txid,coins) == 0 )
|
||||
{
|
||||
//fprintf(stderr,"cant get pcoinsTip->GetCoins\n");
|
||||
continue;
|
||||
}
|
||||
if ( n < 0 || (unsigned int)n >= coins.vout.size() || coins.vout[n].IsNull() )
|
||||
{
|
||||
fprintf(stderr,"iter.%d n.%d vs voutsize.%d\n",iter,n,(int32_t)coins.vout.size());
|
||||
continue;
|
||||
}
|
||||
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);
|
||||
}*/
|
||||
CTransaction tx;
|
||||
uint256 hashBlock;
|
||||
if ( GetTransaction(txid,tx,hashBlock,true) == 0 )
|
||||
return(-1);
|
||||
else if ( n <= tx.vout.size() ) // vout.size() seems off by 1
|
||||
{
|
||||
ptr = (uint8_t *)tx.vout[n].scriptPubKey.data();
|
||||
m = tx.vout[n].scriptPubKey.size();
|
||||
for (i=0; i<maxsize&&i<m; i++)
|
||||
scriptPubKey[i] = ptr[i];
|
||||
//fprintf(stderr,"got scriptPubKey via rawtransaction\n");
|
||||
return(i);
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
Value gettxoutproof(const Array& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || (params.size() != 1 && params.size() != 2))
|
||||
|
||||
Reference in New Issue
Block a user