Merge pull request #895 from UdjinM6/ISKeepLock
Refactor InstantSend to use block count instead of local time
This commit is contained in:
commit
453c6628cd
@ -76,6 +76,8 @@ public:
|
|||||||
consensus.nMasternodePaymentsStartBlock = 100000; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
|
consensus.nMasternodePaymentsStartBlock = 100000; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
|
||||||
consensus.nMasternodePaymentsIncreaseBlock = 158000; // actual historical value
|
consensus.nMasternodePaymentsIncreaseBlock = 158000; // actual historical value
|
||||||
consensus.nMasternodePaymentsIncreasePeriod = 576*30; // 17280 - actual historical value
|
consensus.nMasternodePaymentsIncreasePeriod = 576*30; // 17280 - actual historical value
|
||||||
|
consensus.nInstantSendKeepLock = 24;
|
||||||
|
consensus.nInstantSendReprocessBlocks = 15;
|
||||||
consensus.nBudgetPaymentsStartBlock = 328008; // actual historical value
|
consensus.nBudgetPaymentsStartBlock = 328008; // actual historical value
|
||||||
consensus.nBudgetPaymentsCycleBlocks = 16616; // ~(60*24*30)/2.6, actual number of blocks per month is 200700 / 12 = 16725
|
consensus.nBudgetPaymentsCycleBlocks = 16616; // ~(60*24*30)/2.6, actual number of blocks per month is 200700 / 12 = 16725
|
||||||
consensus.nBudgetPaymentsWindowBlocks = 100;
|
consensus.nBudgetPaymentsWindowBlocks = 100;
|
||||||
@ -191,6 +193,8 @@ public:
|
|||||||
consensus.nMasternodePaymentsStartBlock = 10000; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
|
consensus.nMasternodePaymentsStartBlock = 10000; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
|
||||||
consensus.nMasternodePaymentsIncreaseBlock = 46000;
|
consensus.nMasternodePaymentsIncreaseBlock = 46000;
|
||||||
consensus.nMasternodePaymentsIncreasePeriod = 576;
|
consensus.nMasternodePaymentsIncreasePeriod = 576;
|
||||||
|
consensus.nInstantSendKeepLock = 6;
|
||||||
|
consensus.nInstantSendReprocessBlocks = 4;
|
||||||
consensus.nBudgetPaymentsStartBlock = 78476;
|
consensus.nBudgetPaymentsStartBlock = 78476;
|
||||||
consensus.nBudgetPaymentsCycleBlocks = 50;
|
consensus.nBudgetPaymentsCycleBlocks = 50;
|
||||||
consensus.nBudgetPaymentsWindowBlocks = 10;
|
consensus.nBudgetPaymentsWindowBlocks = 10;
|
||||||
@ -288,6 +292,8 @@ public:
|
|||||||
consensus.nMasternodePaymentsStartBlock = 240;
|
consensus.nMasternodePaymentsStartBlock = 240;
|
||||||
consensus.nMasternodePaymentsIncreaseBlock = 350;
|
consensus.nMasternodePaymentsIncreaseBlock = 350;
|
||||||
consensus.nMasternodePaymentsIncreasePeriod = 10;
|
consensus.nMasternodePaymentsIncreasePeriod = 10;
|
||||||
|
consensus.nInstantSendKeepLock = 6;
|
||||||
|
consensus.nInstantSendReprocessBlocks = 4;
|
||||||
consensus.nBudgetPaymentsStartBlock = 1000;
|
consensus.nBudgetPaymentsStartBlock = 1000;
|
||||||
consensus.nBudgetPaymentsCycleBlocks = 50;
|
consensus.nBudgetPaymentsCycleBlocks = 50;
|
||||||
consensus.nBudgetPaymentsWindowBlocks = 100;
|
consensus.nBudgetPaymentsWindowBlocks = 100;
|
||||||
|
@ -40,6 +40,8 @@ struct Params {
|
|||||||
int nMasternodePaymentsStartBlock;
|
int nMasternodePaymentsStartBlock;
|
||||||
int nMasternodePaymentsIncreaseBlock;
|
int nMasternodePaymentsIncreaseBlock;
|
||||||
int nMasternodePaymentsIncreasePeriod; // in blocks
|
int nMasternodePaymentsIncreasePeriod; // in blocks
|
||||||
|
int nInstantSendKeepLock; // in blocks
|
||||||
|
int nInstantSendReprocessBlocks;
|
||||||
int nBudgetPaymentsStartBlock;
|
int nBudgetPaymentsStartBlock;
|
||||||
int nBudgetPaymentsCycleBlocks;
|
int nBudgetPaymentsCycleBlocks;
|
||||||
int nBudgetPaymentsWindowBlocks;
|
int nBudgetPaymentsWindowBlocks;
|
||||||
|
@ -247,7 +247,8 @@ int64_t CreateNewLock(CTransaction tx)
|
|||||||
|
|
||||||
CTransactionLock newLock;
|
CTransactionLock newLock;
|
||||||
newLock.nBlockHeight = nBlockHeight;
|
newLock.nBlockHeight = nBlockHeight;
|
||||||
newLock.nExpiration = GetTime()+(60*60); //locks expire after 60 minutes (24 confirmations)
|
//locks expire after nInstantSendKeepLock confirmations
|
||||||
|
newLock.nLockExpirationBlock = chainActive.Height() + Params().GetConsensus().nInstantSendKeepLock;
|
||||||
newLock.nTimeout = GetTime()+(60*5);
|
newLock.nTimeout = GetTime()+(60*5);
|
||||||
newLock.txHash = tx.GetHash();
|
newLock.txHash = tx.GetHash();
|
||||||
mapTxLocks.insert(std::make_pair(tx.GetHash(), newLock));
|
mapTxLocks.insert(std::make_pair(tx.GetHash(), newLock));
|
||||||
@ -338,7 +339,8 @@ bool ProcessConsensusVote(CNode* pnode, CConsensusVote& vote)
|
|||||||
|
|
||||||
CTransactionLock newLock;
|
CTransactionLock newLock;
|
||||||
newLock.nBlockHeight = 0;
|
newLock.nBlockHeight = 0;
|
||||||
newLock.nExpiration = GetTime()+(60*60);
|
//locks expire after nInstantSendKeepLock confirmations
|
||||||
|
newLock.nLockExpirationBlock = chainActive.Height() + Params().GetConsensus().nInstantSendKeepLock;
|
||||||
newLock.nTimeout = GetTime()+(60*5);
|
newLock.nTimeout = GetTime()+(60*5);
|
||||||
newLock.txHash = vote.txHash;
|
newLock.txHash = vote.txHash;
|
||||||
mapTxLocks.insert(std::make_pair(vote.txHash, newLock));
|
mapTxLocks.insert(std::make_pair(vote.txHash, newLock));
|
||||||
@ -433,10 +435,10 @@ bool FindConflictingLocks(CTransaction& tx)
|
|||||||
LogPrintf("FindConflictingLocks -- found two complete conflicting locks, removing both: txid=%s, txin=%s", tx.GetHash().ToString(), mapLockedInputs[txin.prevout].ToString());
|
LogPrintf("FindConflictingLocks -- found two complete conflicting locks, removing both: txid=%s, txin=%s", tx.GetHash().ToString(), mapLockedInputs[txin.prevout].ToString());
|
||||||
|
|
||||||
if(mapTxLocks.count(tx.GetHash()))
|
if(mapTxLocks.count(tx.GetHash()))
|
||||||
mapTxLocks[tx.GetHash()].nExpiration = GetTime();
|
mapTxLocks[tx.GetHash()].nLockExpirationBlock = -1;
|
||||||
|
|
||||||
if(mapTxLocks.count(mapLockedInputs[txin.prevout]))
|
if(mapTxLocks.count(mapLockedInputs[txin.prevout]))
|
||||||
mapTxLocks[mapLockedInputs[txin.prevout]].nExpiration = GetTime();
|
mapTxLocks[mapLockedInputs[txin.prevout]].nLockExpirationBlock = -1;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -452,8 +454,8 @@ void ResolveConflicts(CTransaction& tx)
|
|||||||
if (IsLockedInstandSendTransaction(tx.GetHash()) && !FindConflictingLocks(tx)) { //?????
|
if (IsLockedInstandSendTransaction(tx.GetHash()) && !FindConflictingLocks(tx)) { //?????
|
||||||
LogPrintf("ResolveConflicts -- Found Existing Complete IX Lock, resolving...\n");
|
LogPrintf("ResolveConflicts -- Found Existing Complete IX Lock, resolving...\n");
|
||||||
|
|
||||||
//reprocess the last 15 blocks
|
//reprocess the last nInstantSendReprocessBlocks blocks
|
||||||
ReprocessBlocks(15);
|
ReprocessBlocks(Params().GetConsensus().nInstantSendReprocessBlocks);
|
||||||
if(!mapTxLockReq.count(tx.GetHash()))
|
if(!mapTxLockReq.count(tx.GetHash()))
|
||||||
mapTxLockReq.insert(std::make_pair(tx.GetHash(), tx)); //?????
|
mapTxLockReq.insert(std::make_pair(tx.GetHash(), tx)); //?????
|
||||||
}
|
}
|
||||||
@ -480,9 +482,10 @@ void CleanTransactionLocksList()
|
|||||||
|
|
||||||
std::map<uint256, CTransactionLock>::iterator it = mapTxLocks.begin();
|
std::map<uint256, CTransactionLock>::iterator it = mapTxLocks.begin();
|
||||||
|
|
||||||
|
int nHeight = chainActive.Height();
|
||||||
while(it != mapTxLocks.end()) {
|
while(it != mapTxLocks.end()) {
|
||||||
CTransactionLock &txLock = it->second;
|
CTransactionLock &txLock = it->second;
|
||||||
if(GetTime() > txLock.nExpiration){
|
if(GetTime() > txLock.nLockExpirationBlock) {
|
||||||
LogPrintf("Removing old transaction lock: txid=%s\n", txLock.txHash.ToString());
|
LogPrintf("Removing old transaction lock: txid=%s\n", txLock.txHash.ToString());
|
||||||
|
|
||||||
if(mapTxLockReq.count(txLock.txHash)){
|
if(mapTxLockReq.count(txLock.txHash)){
|
||||||
|
@ -108,7 +108,7 @@ public:
|
|||||||
int nBlockHeight;
|
int nBlockHeight;
|
||||||
uint256 txHash;
|
uint256 txHash;
|
||||||
std::vector<CConsensusVote> vecConsensusVotes;
|
std::vector<CConsensusVote> vecConsensusVotes;
|
||||||
int nExpiration;
|
int nLockExpirationBlock;
|
||||||
int nTimeout;
|
int nTimeout;
|
||||||
|
|
||||||
bool VotesValid();
|
bool VotesValid();
|
||||||
|
Loading…
Reference in New Issue
Block a user