Documentation
¶
Index ¶
- Constants
- func Close()
- func InitMempool()
- func SetInstance(p *TxMempool)
- type EntryAncestorFeeRateSort
- type EntryFeeSort
- type LockPoints
- type OrphanTx
- type PoolRemovalReason
- type StatisInformation
- type TxEntry
- func (t *TxEntry) CheckLockPointValidity(chain *chain.Chain) bool
- func (t *TxEntry) GetFeeRate() *util.FeeRate
- func (t *TxEntry) GetInfo() *TxMempoolInfo
- func (t *TxEntry) GetLockPointFromTxEntry() LockPoints
- func (t *TxEntry) GetSigOpCountWithAncestors() int64
- func (t *TxEntry) GetSpendsCoinbase() bool
- func (t *TxEntry) GetTime() int64
- func (t *TxEntry) GetUsageSize() int64
- func (t *TxEntry) Less(than mapcontainer.Lesser) bool
- func (t *TxEntry) SetLockPointFromTxEntry(lp LockPoints)
- func (t *TxEntry) UpdateAncestorState(updateCount, updateSize, updateSigOps int, updateFee int64)
- func (t *TxEntry) UpdateChild(child *TxEntry, add bool)
- func (t *TxEntry) UpdateChildOfParents(add bool)
- func (t *TxEntry) UpdateDescendantState(updateCount, updateSize int, updateFee int64)
- func (t *TxEntry) UpdateParent(parent *TxEntry, add bool)
- type TxMempool
- func (m *TxMempool) AddOrphanTx(orphantx *tx.Tx, nodeID int64)
- func (m *TxMempool) AddTx(txEntry *TxEntry, ancestors map[*TxEntry]struct{}) error
- func (m *TxMempool) CalculateDescendants(entry *TxEntry, descendants map[*TxEntry]struct{})
- func (m *TxMempool) CalculateDescendantsWithLock(txHash *util.Hash) map[*TxEntry]struct{}
- func (m *TxMempool) CalculateMemPoolAncestors(tx *tx.Tx, limitAncestorCount uint64, limitAncestorSize uint64, ...) (ancestors map[*TxEntry]struct{}, err error)
- func (m *TxMempool) CalculateMemPoolAncestorsWithLock(txhash *util.Hash) map[*TxEntry]struct{}
- func (m *TxMempool) CleanOrphan()
- func (m *TxMempool) EraseOrphanTx(txHash util.Hash, removeRedeemers bool)
- func (m *TxMempool) FindTx(hash util.Hash) *TxEntry
- func (m *TxMempool) GetAllSpentOutWithoutLock() map[outpoint.OutPoint]*TxEntry
- func (m *TxMempool) GetAllTxEntry() map[util.Hash]*TxEntry
- func (m *TxMempool) GetAllTxEntryWithoutLock() map[util.Hash]*TxEntry
- func (m *TxMempool) GetCheckFrequency() uint64
- func (m *TxMempool) GetCoin(outpoint *outpoint.OutPoint) *utxo.Coin
- func (m *TxMempool) GetMinFee(sizeLimit int64) util.FeeRate
- func (m *TxMempool) GetMinFeeRate() util.FeeRate
- func (m *TxMempool) GetPoolAllTxSize(lock bool) uint64
- func (m *TxMempool) GetPoolUsage() int64
- func (m *TxMempool) GetRootTx() map[util.Hash]TxEntry
- func (m *TxMempool) HasSPentOutWithoutLock(out *outpoint.OutPoint) *TxEntry
- func (m *TxMempool) HasSpentOut(out *outpoint.OutPoint) bool
- func (m *TxMempool) HaveTransaction(tx *tx.Tx) bool
- func (m *TxMempool) IsOrphanInPool(tx *tx.Tx) bool
- func (m *TxMempool) IsTransactionInPool(tx *tx.Tx) bool
- func (m *TxMempool) LimitMempoolSize(sizeLimit, age int64)
- func (m *TxMempool) Lock()
- func (m *TxMempool) RLock()
- func (m *TxMempool) RUnlock()
- func (m *TxMempool) RemoveOrphansByTag(nodeID int64) int
- func (m *TxMempool) RemoveStaged(entriesToRemove map[*TxEntry]struct{}, updateDescendants bool, ...)
- func (m *TxMempool) RemoveTxRecursive(origTx *tx.Tx, reason PoolRemovalReason)
- func (m *TxMempool) RemoveTxSelf(txs []*tx.Tx)
- func (m *TxMempool) Size() int
- func (m *TxMempool) TxInfoAll() []*TxMempoolInfo
- func (m *TxMempool) Unlock()
- type TxMempoolInfo
Constants ¶
const ( OrphanTxExpireTime = 20 * 60 OrphanTxExpireInterval = 5 * 60 DefaultMaxOrphanTransaction = 100 )
const (
RollingFeeHalfLife = 12 * 60 * 60
)
Variables ¶
This section is empty.
Functions ¶
func Close ¶ added in v0.0.3
func Close()
Close FIXME this is only for test. We must do it in a graceful way
func InitMempool ¶
func InitMempool()
func SetInstance ¶ added in v0.0.3
func SetInstance(p *TxMempool)
Types ¶
type EntryAncestorFeeRateSort ¶
type EntryAncestorFeeRateSort TxEntry
func (*EntryAncestorFeeRateSort) Less ¶
func (r *EntryAncestorFeeRateSort) Less(than mapcontainer.Lesser) bool
type EntryFeeSort ¶
type EntryFeeSort TxEntry
func (EntryFeeSort) Less ¶
func (e EntryFeeSort) Less(than mapcontainer.Lesser) bool
type LockPoints ¶
type LockPoints struct { // Height and Time will be set to the blockChain height and median time past values that // would be necessary to satisfy all relative lockTime constraints (BIP68) // of this tx given our view of block chain history Height int32 Time int64 // MaxInputBlock as long as the current chain descends from the highest height block // containing one of the inputs used in the calculation, then the cached // values are still valid even after a reOrg. MaxInputBlock *blockindex.BlockIndex }
func NewLockPoints ¶
func NewLockPoints() *LockPoints
type PoolRemovalReason ¶
type PoolRemovalReason int
const ( // UNKNOWN Manually removed or unknown reason UNKNOWN PoolRemovalReason = iota // EXPIRY Expired from memPool EXPIRY // SIZELIMIT Removed in size limiting SIZELIMIT // REORG Removed for reorganization REORG // BLOCK Removed for block BLOCK // CONFLICT Removed for conflict with in-block transaction CONFLICT // REPLACED Removed for replacement REPLACED )
Reason why a transaction was removed from the memPool, this is passed to the notification signal.
type StatisInformation ¶
type StatisInformation struct { // sumTxCountWithDescendants is this tx and all Descendants transaction's number. init number is 1. SumTxCountWithDescendants int64 // sumFeeWithDescendants is calculated by this tx and all Descendants transaction; SumTxFeeWithDescendants int64 // sumSizeWithDescendants size calculated by this tx and all Descendants transaction; SumTxSizeWithDescendants int64 SumTxCountWithAncestors int64 SumTxSizeWitAncestors int64 SumTxSigOpCountWithAncestors int64 SumTxFeeWithAncestors int64 }
type TxEntry ¶
type TxEntry struct { Tx *tx.Tx TxSize int // txFee tis transaction fee TxFee int64 TxHeight int32 // sigOpCount sigop plus P2SH sigops count SigOpCount int // childTx the tx's all Descendants transaction ChildTx map[*TxEntry]struct{} // parentTx the tx's all Ancestors transaction ParentTx map[*TxEntry]struct{} //Statistics Information for every txentry with its ancestors And descend. StatisInformation // contains filtered or unexported fields }
func NewTxentry ¶
func (*TxEntry) CheckLockPointValidity ¶
func (*TxEntry) GetFeeRate ¶
func (*TxEntry) GetInfo ¶
func (t *TxEntry) GetInfo() *TxMempoolInfo
func (*TxEntry) GetLockPointFromTxEntry ¶
func (t *TxEntry) GetLockPointFromTxEntry() LockPoints
func (*TxEntry) GetSigOpCountWithAncestors ¶
func (*TxEntry) GetSpendsCoinbase ¶
func (*TxEntry) GetUsageSize ¶
func (*TxEntry) SetLockPointFromTxEntry ¶
func (t *TxEntry) SetLockPointFromTxEntry(lp LockPoints)
func (*TxEntry) UpdateAncestorState ¶
func (*TxEntry) UpdateChild ¶
func (*TxEntry) UpdateChildOfParents ¶
func (*TxEntry) UpdateDescendantState ¶
func (*TxEntry) UpdateParent ¶
UpdateParent update the tx's parent transaction.
type TxMempool ¶
type TxMempool struct { //transactionsUpdated mempool update transaction total number when create mempool late. TransactionsUpdated uint64 OrphanTransactionsByPrev map[outpoint.OutPoint]map[util.Hash]OrphanTx OrphanTransactions map[util.Hash]OrphanTx // contains filtered or unexported fields }
TxMempool is safe for concurrent write And read access.
func GetInstance ¶
func GetInstance() *TxMempool
func NewTxMempool ¶
func NewTxMempool() *TxMempool
func (*TxMempool) AddTx ¶
AddTx operator is safe for concurrent write And read access. this function is used to add tx to the memPool, and now the tx should be passed all appropriate checks.
func (*TxMempool) CalculateDescendants ¶
CalculateDescendants Calculates descendants of entry that are not already in setDescendants, and adds to setDescendants. Assumes entry it is already a tx in the mempool and setMemPoolChildren is correct for tx and all descendants. Also assumes that if an entry is in setDescendants already, then all in-mempool descendants of it are already in setDescendants as well, so that we can save time by not iterating over those entries.
func (*TxMempool) CalculateDescendantsWithLock ¶
func (*TxMempool) CalculateMemPoolAncestors ¶
func (m *TxMempool) CalculateMemPoolAncestors(tx *tx.Tx, limitAncestorCount uint64, limitAncestorSize uint64, limitDescendantCount uint64, limitDescendantSize uint64, searchForParent bool) (ancestors map[*TxEntry]struct{}, err error)
CalculateMemPoolAncestors get tx all ancestors transaction in mempool. when the find is false: the tx must in mempool, so directly get his parent.
func (*TxMempool) CalculateMemPoolAncestorsWithLock ¶
func (*TxMempool) CleanOrphan ¶ added in v0.0.3
func (m *TxMempool) CleanOrphan()
func (*TxMempool) EraseOrphanTx ¶
func (*TxMempool) GetAllSpentOutWithoutLock ¶
func (*TxMempool) GetAllTxEntryWithoutLock ¶
func (*TxMempool) GetCheckFrequency ¶
func (*TxMempool) GetMinFeeRate ¶
func (*TxMempool) GetPoolAllTxSize ¶
func (*TxMempool) GetPoolUsage ¶
func (*TxMempool) HasSPentOutWithoutLock ¶
func (*TxMempool) HaveTransaction ¶ added in v0.0.3
func (*TxMempool) IsOrphanInPool ¶ added in v0.0.3
func (*TxMempool) IsTransactionInPool ¶ added in v0.0.3
func (*TxMempool) LimitMempoolSize ¶
LimitMempoolSize limit mempool size with time And limit size. when the noSpendsRemaining set, the function will return these have removed transaction's txin from mempool which use TrimToSize rule. Later, caller will remove these txin from uxto cache.
func (*TxMempool) RemoveOrphansByTag ¶
func (*TxMempool) RemoveStaged ¶
func (m *TxMempool) RemoveStaged(entriesToRemove map[*TxEntry]struct{}, updateDescendants bool, reason PoolRemovalReason)
func (*TxMempool) RemoveTxRecursive ¶
func (m *TxMempool) RemoveTxRecursive(origTx *tx.Tx, reason PoolRemovalReason)
func (*TxMempool) RemoveTxSelf ¶
RemoveTxSelf will only remove these transaction self.
func (*TxMempool) TxInfoAll ¶
func (m *TxMempool) TxInfoAll() []*TxMempoolInfo
type TxMempoolInfo ¶
type TxMempoolInfo struct { Tx *tx.Tx // The transaction itself Time int64 // Time the transaction entered the memPool FeeRate util.FeeRate // FeeRate of the transaction }
func (*TxMempoolInfo) Unserialize ¶
func (info *TxMempoolInfo) Unserialize(r io.Reader) error