fix possible to choose more than 1 notarisation
This commit is contained in:
@@ -1777,14 +1777,20 @@ int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *
|
||||
uint64_t komodo_notarypayamount(int32_t height, int64_t numnotaries)
|
||||
{
|
||||
if ( numnotaries == 0 )
|
||||
{
|
||||
fprintf(stderr, "komodo_notarypayamount failed num notaries is 0!\n");
|
||||
return(0);
|
||||
}
|
||||
// fetch notarised height
|
||||
int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid;
|
||||
uint64_t AmountToPay=0,ret=0;
|
||||
notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid);
|
||||
// dont think this can happen, just sanity check.
|
||||
if ( height == notarizedht )
|
||||
{
|
||||
fprintf(stderr, "komodo_notarypayamount failed notarized height = height\n");
|
||||
return(0);
|
||||
}
|
||||
// how many block since last notarisation.
|
||||
int32_t n = height - notarizedht;
|
||||
fprintf(stderr, "blocks since last notarisation: %i\n",n);
|
||||
@@ -1851,7 +1857,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &Notar
|
||||
//fprintf(stderr,"%02x",ptr[i+1]);
|
||||
}
|
||||
ptr[34] = OP_CHECKSIG;
|
||||
//fprintf(stderr," set notary %i PUBKEY33 into vout[%i]\n",NotarisationNotaries[n],n+1);
|
||||
//fprintf(stderr," set notary %i PUBKEY33 into vout[%i] amount.%lu\n",NotarisationNotaries[n],n+1,AmountToPay);
|
||||
txNew.vout[n+1].nValue = AmountToPay;
|
||||
total += txNew.vout[n+1].nValue;
|
||||
}
|
||||
|
||||
@@ -303,7 +303,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
nTotalIn += nValueIn;
|
||||
dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16.
|
||||
} else {
|
||||
int numNotaryVins = 0; bool fToCryptoAddress = false;
|
||||
//int numNotaryVins = 0;
|
||||
bool fToCryptoAddress = false;
|
||||
if ( numSN != 0 && staked_pubkeys[0][0] != 0 && komodo_is_notarytx(tx) == 1 )
|
||||
fToCryptoAddress = true;
|
||||
|
||||
@@ -355,19 +356,19 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size();
|
||||
if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[i],33) == 0 )
|
||||
{
|
||||
numNotaryVins++;
|
||||
//numNotaryVins++;
|
||||
if ( Notarisations == 0 )
|
||||
{
|
||||
// Until we get a valid notarization this will always be 0.
|
||||
// We can add the index of each notary to vector, and clear it if this notarisation is not valid later on.
|
||||
NotarisationNotaries.push_back(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dPriority += (double)nValueIn * nConf;
|
||||
}
|
||||
if ( numSN != 0 && numNotaryVins >= numSN / 5 )
|
||||
if ( numSN != 0 && NotarisationNotaries.size() >= numSN / 5 )
|
||||
{
|
||||
// check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems)
|
||||
std::set<int> checkdupes( NotarisationNotaries.begin(), NotarisationNotaries.end() );
|
||||
@@ -704,8 +705,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
{
|
||||
fprintf(stderr, "Could not create notary payment, trying again.\n");
|
||||
invalidnotarisation = pblock->vtx[1].GetHash().ToString();
|
||||
LEAVE_CRITICAL_SECTION(cs_main);
|
||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) )
|
||||
{
|
||||
LEAVE_CRITICAL_SECTION(cs_main);
|
||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats);
|
||||
|
||||
Reference in New Issue
Block a user