Documentation ¶
Index ¶
- Variables
- type ConflictObject
- type EncodeInterface
- type PoolStats
- type TestTx
- type TransactionInterface
- type TransactionList
- type TransactionPool
- func (tp *TransactionPool) BlockIfFull() bool
- func (tp *TransactionPool) BlockUntilNotFull() bool
- func (tp *TransactionPool) Broadcast()
- func (tp *TransactionPool) ClosePool()
- func (tp *TransactionPool) GetProposal(idx types.ConsensusID, retChan chan []TransactionInterface)
- func (tp *TransactionPool) GetProposalNow(idx types.ConsensusID)
- func (tp *TransactionPool) GetStats() PoolStats
- func (tp *TransactionPool) IsClosed() bool
- func (tp *TransactionPool) ResetStats()
- func (tp *TransactionPool) String() string
- func (tp *TransactionPool) SubmitTransaction(transList ...TransactionInterface) (inserted []TransactionInterface, errs []error)
- func (tp *TransactionPool) SubmitTransactionIfValid(validFunc ValidateTxFunc, transList ...TransactionInterface) (inserted []TransactionInterface, errs []error)
- func (tp *TransactionPool) ValidatePool(txFunc ValidateTxFunc)
- type TxAlloc
- type ValidateTxFunc
Constants ¶
This section is empty.
Variables ¶
var ErrTransactionAreadyInPool = fmt.Errorf("transactions already existsts in pool")
var ErrTransactionPoolFull = fmt.Errorf("transaction pool full")
Functions ¶
This section is empty.
Types ¶
type ConflictObject ¶
type ConflictObject interface{}
if two conflictobjects are equal then transactions conflict, otherwise they dont
type EncodeInterface ¶
type PoolStats ¶
type TestTx ¶
type TestTx struct {
Id int
}
func (*TestTx) GetConflictObjects ¶
func (tx *TestTx) GetConflictObjects() []ConflictObject
type TransactionInterface ¶
type TransactionInterface interface { GetConflictObjects() []ConflictObject EncodeInterface }
type TransactionList ¶
type TransactionList struct { Items []TransactionInterface TxAlloc TxAlloc }
type TransactionPool ¶
type TransactionPool struct {
// contains filtered or unexported fields
}
func AllocateTransactionPool ¶
func AllocateTransactionPool(maxPoolSize int, minProposalSize, maxProposalSize int) *TransactionPool
func (*TransactionPool) BlockIfFull ¶
func (tp *TransactionPool) BlockIfFull() bool
func (*TransactionPool) BlockUntilNotFull ¶
func (tp *TransactionPool) BlockUntilNotFull() bool
func (*TransactionPool) Broadcast ¶
func (tp *TransactionPool) Broadcast()
func (*TransactionPool) ClosePool ¶
func (tp *TransactionPool) ClosePool()
func (*TransactionPool) GetProposal ¶
func (tp *TransactionPool) GetProposal(idx types.ConsensusID, retChan chan []TransactionInterface)
GetProposal is called when the consensus index idx is ready for a proposal. Should only be called once per index.
func (*TransactionPool) GetProposalNow ¶
func (tp *TransactionPool) GetProposalNow(idx types.ConsensusID)
GetProposalNow immediately returns a proposal for index idx even if less than minProposalSize transactions are ready. Must be called at most once, after GetProposal for the same index.
func (*TransactionPool) GetStats ¶
func (tp *TransactionPool) GetStats() PoolStats
func (*TransactionPool) IsClosed ¶
func (tp *TransactionPool) IsClosed() bool
func (*TransactionPool) ResetStats ¶
func (tp *TransactionPool) ResetStats()
func (*TransactionPool) String ¶
func (tp *TransactionPool) String() string
func (*TransactionPool) SubmitTransaction ¶
func (tp *TransactionPool) SubmitTransaction( transList ...TransactionInterface) (inserted []TransactionInterface, errs []error)
Calls SubmitTransactionIfValid with a nil valid function.
func (*TransactionPool) SubmitTransactionIfValid ¶
func (tp *TransactionPool) SubmitTransactionIfValid(validFunc ValidateTxFunc, transList ...TransactionInterface) (inserted []TransactionInterface, errs []error)
SubmitTransaction is used to submit a transaction into the pool, it is safe to be called concurrently from multiple threads. ValidFunc is called after the pool checks for a conflicting transaction for each transaction, if validFunc is nil then all non-conflicting transactions are considered valid. It returns nil if the transaction was successfully inserted into the pool.
func (*TransactionPool) ValidatePool ¶
func (tp *TransactionPool) ValidatePool(txFunc ValidateTxFunc)
Validate pool will check the transactions in the pool against txFunc, any that return false will be removed from the pool.
type TxAlloc ¶
type TxAlloc func() TransactionInterface
type ValidateTxFunc ¶
type ValidateTxFunc func(TransactionInterface) error