Prevent relaying expired tx
This commit is contained in:
@@ -1033,16 +1033,16 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_
|
|||||||
{
|
{
|
||||||
if ( txheight < 247205 )
|
if ( txheight < 247205 )
|
||||||
cmptime -= 16000;
|
cmptime -= 16000;
|
||||||
if ( (int64_t)tx.nLockTime < cmptime-3600 )
|
if ( (int64_t)tx.nLockTime < cmptime-KOMODO_MAXMEMPOOLTIME )
|
||||||
{
|
{
|
||||||
if ( tx.nLockTime != 1477258935 && dispflag != 0 )
|
if ( tx.nLockTime != 1477258935 && dispflag != 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"komodo_validate_interest.%d reject.%d [%d] locktime %u cmp2.%u\n",dispflag,txheight,(int32_t)(tx.nLockTime - (cmptime-3600)),(uint32_t)tx.nLockTime,cmptime);
|
fprintf(stderr,"komodo_validate_interest.%d reject.%d [%d] locktime %u cmp2.%u\n",dispflag,txheight,(int32_t)(tx.nLockTime - (cmptime-KOMODO_MAXMEMPOOLTIME)),(uint32_t)tx.nLockTime,cmptime);
|
||||||
}
|
}
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
if ( 0 && dispflag != 0 )
|
if ( 0 && dispflag != 0 )
|
||||||
fprintf(stderr,"validateinterest.%d accept.%d [%d] locktime %u cmp2.%u\n",dispflag,(int32_t)txheight,(int32_t)(tx.nLockTime - (cmptime-3600)),(int32_t)tx.nLockTime,cmptime);
|
fprintf(stderr,"validateinterest.%d accept.%d [%d] locktime %u cmp2.%u\n",dispflag,(int32_t)txheight,(int32_t)(tx.nLockTime - (cmptime-KOMODO_MAXMEMPOOLTIME)),(int32_t)tx.nLockTime,cmptime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
|
|||||||
@@ -6,5 +6,6 @@
|
|||||||
#define ROUNDROBIN_DELAY 61
|
#define ROUNDROBIN_DELAY 61
|
||||||
#define KOMODO_ASSETCHAIN_MAXLEN 65
|
#define KOMODO_ASSETCHAIN_MAXLEN 65
|
||||||
#define KOMODO_LIMITED_NETWORKSIZE 4
|
#define KOMODO_LIMITED_NETWORKSIZE 4
|
||||||
|
#define KOMODO_MAXMEMPOOLTIME 3600 // affects consensus
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -83,13 +83,13 @@ uint64_t komodo_moneysupply(int32_t height)
|
|||||||
uint64_t _komodo_interestnew(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime)
|
uint64_t _komodo_interestnew(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime)
|
||||||
{
|
{
|
||||||
int32_t minutes; uint64_t interest = 0;
|
int32_t minutes; uint64_t interest = 0;
|
||||||
if ( nLockTime >= LOCKTIME_THRESHOLD && tiptime > nLockTime && (minutes= (tiptime - nLockTime) / 60) >= 60 )
|
if ( nLockTime >= LOCKTIME_THRESHOLD && tiptime > nLockTime && (minutes= (tiptime - nLockTime) / 60) >= (KOMODO_MAXMEMPOOLTIME/60) )
|
||||||
{
|
{
|
||||||
if ( minutes > 365 * 24 * 60 )
|
if ( minutes > 365 * 24 * 60 )
|
||||||
minutes = 365 * 24 * 60;
|
minutes = 365 * 24 * 60;
|
||||||
if ( txheight >= 1000000 && minutes > 31 * 24 * 60 )
|
if ( txheight >= 1000000 && minutes > 31 * 24 * 60 )
|
||||||
minutes = 31 * 24 * 60;
|
minutes = 31 * 24 * 60;
|
||||||
minutes -= 59;
|
minutes -= ((KOMODO_MAXMEMPOOLTIME/60) - 1);
|
||||||
interest = ((nValue / 10512000) * minutes);
|
interest = ((nValue / 10512000) * minutes);
|
||||||
}
|
}
|
||||||
return(interest);
|
return(interest);
|
||||||
|
|||||||
@@ -1887,7 +1887,9 @@ bool CWalletTx::RelayWalletTransaction()
|
|||||||
assert(pwallet->GetBroadcastTransactions());
|
assert(pwallet->GetBroadcastTransactions());
|
||||||
if (!IsCoinBase())
|
if (!IsCoinBase())
|
||||||
{
|
{
|
||||||
if (GetDepthInMainChain() == 0) {
|
if (GetDepthInMainChain() == 0)
|
||||||
|
{
|
||||||
|
// if tx is expired, dont relay
|
||||||
LogPrintf("Relaying wtx %s\n", GetHash().ToString());
|
LogPrintf("Relaying wtx %s\n", GetHash().ToString());
|
||||||
RelayTransaction((CTransaction)*this);
|
RelayTransaction((CTransaction)*this);
|
||||||
return true;
|
return true;
|
||||||
@@ -2102,12 +2104,21 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime)
|
|||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
// Sort them in chronological order
|
// Sort them in chronological order
|
||||||
multimap<unsigned int, CWalletTx*> mapSorted;
|
multimap<unsigned int, CWalletTx*> mapSorted;
|
||||||
|
uint32_t now = (uint32_t)time(NULL);
|
||||||
BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)
|
BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)
|
||||||
{
|
{
|
||||||
CWalletTx& wtx = item.second;
|
CWalletTx& wtx = item.second;
|
||||||
// Don't rebroadcast if newer than nTime:
|
// Don't rebroadcast if newer than nTime:
|
||||||
if (wtx.nTimeReceived > nTime)
|
if (wtx.nTimeReceived > nTime)
|
||||||
continue;
|
continue;
|
||||||
|
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||||
|
{
|
||||||
|
if ( wtx.nLockTime >= LOCKTIME_THRESHOLD && wtx.nLockTime < now-KOMODO_MAXMEMPOOLTIME )
|
||||||
|
{
|
||||||
|
LogPrintf("skip Relaying wtx %s nLockTime %u vs now.%u\n", GetHash().ToString(),(uint32_t)wtx.nLockTime,now);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx));
|
mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx));
|
||||||
}
|
}
|
||||||
BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted)
|
BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted)
|
||||||
|
|||||||
Reference in New Issue
Block a user