transactionsm

package
v0.0.0-...-ff61ee7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTransactionAreadyInPool = fmt.Errorf("transactions already existsts in pool")
View Source
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 EncodeInterface interface {
	Encode(writer io.Writer) (n int, err error)
	Decode(reader io.Reader) (n int, err error)
}

type PoolStats

type PoolStats struct {
	Inserted         uint64
	FailedInsert     uint64
	Proposed         uint64
	FailedValidation uint64
	Validated        uint64
}

func (PoolStats) String

func (ps PoolStats) String() string

type TestTx

type TestTx struct {
	Id int
}

func (*TestTx) Decode

func (tx *TestTx) Decode(reader io.Reader) (n int, err error)

func (*TestTx) Encode

func (tx *TestTx) Encode(writer io.Writer) (n int, err error)

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
}

func (*TransactionList) Decode

func (tx *TransactionList) Decode(reader io.Reader) (n int, err error)

func (*TransactionList) Encode

func (tx *TransactionList) Encode(writer io.Writer) (n int, err error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL