Documentation ¶
Index ¶
- Constants
- func Fuzz(data []byte) int
- type Mempool
- func (mp *Mempool) Flush()
- func (mp *Mempool) GetCandidateTransactionHashes() []string
- func (mp *Mempool) GetTransactionStatus(hash string) (TxStatus, bool)
- func (mp *Mempool) InsertTransaction(rawTx common.Bytes) error
- func (mp *Mempool) Lock()
- func (mp *Mempool) Reap(maxNumTxs int) []common.Bytes
- func (mp *Mempool) ReapUnsafe(maxNumTxs int) []common.Bytes
- func (mp *Mempool) SetLedger(ledger core.Ledger)
- func (mp *Mempool) Size() int
- func (mp *Mempool) Start(ctx context.Context) error
- func (mp *Mempool) Stop()
- func (mp *Mempool) Unlock()
- func (mp *Mempool) Update(committedRawTxs []common.Bytes)
- func (mp *Mempool) UpdateUnsafe(committedRawTxs []common.Bytes)
- func (mp *Mempool) Wait()
- type MempoolError
- type MempoolMessageHandler
- func (mmh *MempoolMessageHandler) EncodeMessage(message interface{}) (common.Bytes, error)
- func (mmh *MempoolMessageHandler) GetChannelIDs() []common.ChannelIDEnum
- func (mmh *MempoolMessageHandler) HandleMessage(message types.Message) error
- func (mmh *MempoolMessageHandler) ParseMessage(peerID string, channelID common.ChannelIDEnum, rawMessageBytes common.Bytes) (types.Message, error)
- type TxStatus
Constants ¶
const DuplicateTxError = MempoolError("Transaction already seen")
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Mempool ¶
type Mempool struct {
// contains filtered or unexported fields
}
Mempool manages the transactions submitted by the clients or relayed from peers
func CreateMempool ¶
func CreateMempool(dispatcher *dp.Dispatcher) *Mempool
CreateMempool creates an instance of Mempool
func (*Mempool) Flush ¶
func (mp *Mempool) Flush()
Flush removes all transactions from the Mempool and the transactionBookkeeper
func (*Mempool) GetCandidateTransactionHashes ¶
GetCandidateTransactions returns all the currently candidate transactions
func (*Mempool) GetTransactionStatus ¶
func (*Mempool) InsertTransaction ¶
InsertTransaction inserts the incoming transaction to mempool (submitted by the clients or relayed from peers)
func (*Mempool) Lock ¶
func (mp *Mempool) Lock()
Lock is for the caller to lock/unlock the Mempool and perform safely update
func (*Mempool) Reap ¶
Reap returns a list of valid raw transactions and remove these transactions from the candidate pool. maxNumTxs == 0 means none, maxNumTxs < 0 means uncapped. Note that Reap does NOT remove the transactions from the candidateTxs list. Instead, the consensus engine needs to call the Mempool.Update() function to remove the committed transactions RUNTIME COMPLEXITY: k*log(n), where k is the number transactions to reap, and n is the number of transactions in the candidate pool.
func (*Mempool) ReapUnsafe ¶
ReapUnsafe is the non-locking version of Reap.
func (*Mempool) Unlock ¶
func (mp *Mempool) Unlock()
Unlock is for the caller to lock/unlock the Mempool and perform safely update
func (*Mempool) Update ¶
Update removes the committed transactions from the transaction candidate list RUNTIME COMPLEXITY: O(k + n), where k is the number committed raw transactions, and n is the number of transactions in the candidate pool.
func (*Mempool) UpdateUnsafe ¶
UpdateUnsafe is the non-locking version of Update. Caller must call Mempool.Lock() before calling this method.
type MempoolError ¶
type MempoolError string
func (MempoolError) Error ¶
func (m MempoolError) Error() string
type MempoolMessageHandler ¶
type MempoolMessageHandler struct {
// contains filtered or unexported fields
}
MempoolMessageHandler handles the messages received over the ChannelIDTransaction channel
func CreateMempoolMessageHandler ¶
func CreateMempoolMessageHandler(mempool *Mempool) *MempoolMessageHandler
CreateMempoolMessageHandler create an instance of the MempoolMessageHandler
func (*MempoolMessageHandler) EncodeMessage ¶
func (mmh *MempoolMessageHandler) EncodeMessage(message interface{}) (common.Bytes, error)
EncodeMessage implements the p2p.MessageHandler interface
func (*MempoolMessageHandler) GetChannelIDs ¶
func (mmh *MempoolMessageHandler) GetChannelIDs() []common.ChannelIDEnum
GetChannelIDs implements the p2p.MessageHandler interface
func (*MempoolMessageHandler) HandleMessage ¶
func (mmh *MempoolMessageHandler) HandleMessage(message types.Message) error
HandleMessage implements the p2p.MessageHandler interface
func (*MempoolMessageHandler) ParseMessage ¶
func (mmh *MempoolMessageHandler) ParseMessage(peerID string, channelID common.ChannelIDEnum, rawMessageBytes common.Bytes) (types.Message, error)
ParseMessage implements the p2p.MessageHandler interface