Documentation ¶
Index ¶
Constants ¶
View Source
const ( GenBatchTimeoutEvent = iota GenBatchNoTxTimeoutEvent GenBatchFirstEvent GenBatchSizeEvent ReConstructBatchEvent GetTxsForGenBatchEvent ReplyBatchSignalEvent )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountMeta ¶
type AccountMeta[T any, Constraint types.TXConstraint[T]] struct { CommitNonce uint64 PendingNonce uint64 TxCount uint64 Txs []*TxInfo[T, Constraint] SimpleTxs []*TxSimpleInfo }
type BatchSimpleInfo ¶
type BatchSimpleInfo struct { TxCount uint64 Txs []*TxSimpleInfo Timestamp int64 }
type ConsensusConfig ¶
type EpochConfig ¶
type Meta ¶
type Meta[T any, Constraint types.TXConstraint[T]] struct { TxCountLimit uint64 TxCount uint64 ReadyTxCount uint64 NotReadyTxCount uint64 Batches map[string]*BatchSimpleInfo MissingBatchTxs map[string]map[uint64]string Accounts map[string]*AccountMeta[T, Constraint] }
type RequestHashBatch ¶
type RequestHashBatch[T any, Constraint types.TXConstraint[T]] struct { BatchHash string // hash of this batch calculated by MD5 TxHashList []string // list of all txs' hashes TxList []*T // list of all txs LocalList []bool // list track if tx is received locally or not Timestamp int64 // generation time of this batch }
RequestHashBatch contains transactions that batched by primary.
func (*RequestHashBatch[T, Constraint]) BatchItemSize ¶
func (rb *RequestHashBatch[T, Constraint]) BatchItemSize() uint64
func (*RequestHashBatch[T, Constraint]) FillBatchItem ¶
func (rb *RequestHashBatch[T, Constraint]) FillBatchItem(tx *T, local bool)
func (*RequestHashBatch[T, Constraint]) GenerateBatchHash ¶
func (rb *RequestHashBatch[T, Constraint]) GenerateBatchHash() string
GetBatchHash calculate hash of a RequestHashBatch
type TxPool ¶
type TxPool[T any, Constraint types.TXConstraint[T]] interface { Init(config ConsensusConfig) // Start starts txPool service Start() error // Stop stops txPool service Stop() // AddLocalTx add local tx into txPool AddLocalTx(tx *T) error // AddRemoteTxs add p2p txs into txPool AddRemoteTxs(txs []*T) // AddRebroadcastTxs add rebroadcast txs into txPool AddRebroadcastTxs(txs []*T) // GenerateRequestBatch generates a transaction batch and post it // to outside if there are transactions in txPool. GenerateRequestBatch(typ int) (*RequestHashBatch[T, Constraint], error) // RemoveBatches removes several batches by given digests of // transaction batches from the pool(batchedTxs). RemoveBatches(batchHashList []string) // RemoveStateUpdatingTxs removes all committed txs when state update one block during state updating RemoveStateUpdatingTxs(txPointerList []*WrapperTxPointer) // RestorePool move all batched txs back to non-batched tx which should // only be used after abnormal recovery. RestorePool() // ReConstructBatchByOrder reconstruct batch from empty txPool by order, must be called after RestorePool. ReConstructBatchByOrder(oldBatch *RequestHashBatch[T, Constraint]) (deDuplicateTxHashes []string, err error) FilterOutOfDateRequests(timeout bool) []*T // RestoreOneBatch moves one batch from batchStore back to non-batched txs. RestoreOneBatch(hash string) error // GetRequestsByHashList returns the transaction list corresponding to the given hash list. // When replicas receive hashList from primary, they need to generate a totally same // batch to primary generated one. deDuplicateTxHashes specifies some txs which should // be excluded from duplicate rules. // 1. If this batch has been batched, just return its transactions without error. // 2. If we have checked this batch and found we were missing some transactions, just // return the same missingTxsHash as before without error. // 3. If one transaction in hashList has been batched before in another batch, // return ErrDuplicateTx // 4. If we miss some transactions, we need to fetch these transactions from primary, // and return missingTxsHash without error // 5. If this node get all transactions from pool, generate a batch and return its // transactions without error GetRequestsByHashList(batchHash string, timestamp int64, hashList []string, deDuplicateTxHashes []string) (txs []*T, list []bool, missingTxsHash map[uint64]string, err error) // SendMissingRequests used by primary to find one batch in batchStore which should contain // txs which are specified in missingHashList. // 1. If there is no such batch, return ErrNoBatch. // 2. If there is such a batch, but it doesn't contain all txs in missingHashList, // return ErrMismatch. // 3. If there is such a batch, and contains all needed txs, returns all needed txs by // order. SendMissingRequests(batchHash string, missingHashList map[uint64]string) (txs map[uint64]*T, err error) // ReceiveMissingRequests receives txs fetched from primary and add txs to txPool ReceiveMissingRequests(batchHash string, txs map[uint64]*T) error GetLocalTxs() [][]byte ReplyBatchSignal() // contains filtered or unexported methods }
type TxSimpleInfo ¶
type WrapperTxPointer ¶
Directories ¶
Path | Synopsis |
---|---|
Package mock_txpool is a generated GoMock package.
|
Package mock_txpool is a generated GoMock package. |
Click to show internal directories.
Click to hide internal directories.