mempool: enforce relative lock-time semantics
This commit introduces behavior which enforces sequence num based relative lock-time semantics when accepting transaction to the mempool.
This commit is contained in:
parent
7eb0ab5f8d
commit
6cd8955498
2 changed files with 18 additions and 2 deletions
|
@ -619,10 +619,11 @@ func (mp *TxPool) maybeAcceptTransaction(tx *btcutil.Tx, isNew, rateLimit, rejec
|
|||
bestHeight := mp.cfg.BestHeight()
|
||||
nextBlockHeight := bestHeight + 1
|
||||
|
||||
medianTimePast := mp.cfg.MedianTimePast()
|
||||
|
||||
// Don't allow non-standard transactions if the network parameters
|
||||
// forbid their acceptance.
|
||||
if !mp.cfg.Policy.AcceptNonStd {
|
||||
medianTimePast := mp.cfg.MedianTimePast()
|
||||
err = checkTransactionStandard(tx, nextBlockHeight,
|
||||
medianTimePast, mp.cfg.Policy.MinRelayTxFee)
|
||||
if err != nil {
|
||||
|
@ -692,6 +693,22 @@ func (mp *TxPool) maybeAcceptTransaction(tx *btcutil.Tx, isNew, rateLimit, rejec
|
|||
return missingParents, nil
|
||||
}
|
||||
|
||||
// Don't allow the transaction into the mempool unless its sequence
|
||||
// lock is active, meaning that it'll be allowed into the next block
|
||||
// with respect to its defined relative lock times.
|
||||
sequenceLock, err := mp.cfg.CalcSequenceLock(tx, utxoView)
|
||||
if err != nil {
|
||||
if cerr, ok := err.(blockchain.RuleError); ok {
|
||||
return nil, chainRuleError(cerr)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if !blockchain.SequenceLockActive(sequenceLock, nextBlockHeight,
|
||||
medianTimePast) {
|
||||
return nil, txRuleError(wire.RejectNonstandard,
|
||||
"transaction's sequence locks on inputs not met")
|
||||
}
|
||||
|
||||
// Perform several checks on the transaction inputs using the invariant
|
||||
// rules in blockchain for what transactions are allowed into blocks.
|
||||
// Also returns the fees associated with the transaction which will be
|
||||
|
|
|
@ -481,7 +481,6 @@ mempoolLoop:
|
|||
}
|
||||
if !blockchain.IsFinalizedTransaction(tx, nextBlockHeight,
|
||||
timeSource.AdjustedTime()) {
|
||||
|
||||
minrLog.Tracef("Skipping non-finalized tx %s", tx.Hash())
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue