Documentation ¶
Index ¶
- Constants
- Variables
- func CheckTxTimestamp(min, max int64, tx transaction.Transaction) error
- func DurationToTimestamp(d time.Duration) int64
- func FinalizeTransition(tr module.Transition, opt int, noFlush bool) error
- func Inspect(c module.Chain, informal bool) map[string]interface{}
- func NewInitTransition(db db.Database, result []byte, vl module.ValidatorList, ...) (module.Transition, error)
- func NewManager(chain module.Chain, nm module.NetworkManager, eem eeproxy.Manager, ...) (module.ServiceManager, error)
- func NewSyncTransition(tr module.Transition, sm SyncManager, result []byte, vl []byte) module.Transition
- func NewTransition(parent module.Transition, patchtxs module.TransactionList, ...) module.Transition
- func NewWorldSnapshot(database db.Database, plt Platform, result []byte, vl module.ValidatorList) (state.WorldSnapshot, error)
- func PatchTransition(tr module.Transition, bi module.BlockInfo, ptxs module.TransactionList) module.Transition
- func TimestampToDuration(t int64) time.Duration
- func TransactionTimestampThreshold(wc state.WorldContext, g module.TransactionGroup) int64
- type ExecutionResult
- type Monitor
- type Platform
- type PoolCapacityMonitor
- type QueryHandler
- type SyncManager
- type TimestampRange
- type TransactionManager
- func (m *TransactionManager) Add(tx transaction.Transaction, direct bool) error
- func (m *TransactionManager) AddAndWait(tx transaction.Transaction) (<-chan interface{}, error)
- func (m *TransactionManager) Candidate(g module.TransactionGroup, wc state.WorldContext, maxBytes, maxCount int) ([]module.Transaction, int)
- func (m *TransactionManager) FilterTransactions(g module.TransactionGroup, bloom *TxBloom, max int) []module.Transaction
- func (m *TransactionManager) GetBloomOf(g module.TransactionGroup) *TxBloom
- func (m *TransactionManager) HasTx(id []byte) bool
- func (m *TransactionManager) Logger() log.Logger
- func (m *TransactionManager) NotifyFinalized(l1 module.TransactionList, r1 module.ReceiptList, l2 module.TransactionList, ...)
- func (m *TransactionManager) OnTxDrops(drops []TxDrop)
- func (m *TransactionManager) RemoveOldTxByBlockTS(group module.TransactionGroup, bts int64)
- func (m *TransactionManager) RemoveTxs(g module.TransactionGroup, l module.TransactionList)
- func (m *TransactionManager) SetPoolCapacityMonitor(pcm PoolCapacityMonitor)
- func (m *TransactionManager) Wait(wc state.WorldContext, cb func()) bool
- func (m *TransactionManager) WaitResult(id []byte) (<-chan interface{}, error)
- type TransactionPool
- func (tp *TransactionPool) Add(tx transaction.Transaction, direct bool) error
- func (tp *TransactionPool) Candidate(wc state.WorldContext, maxBytes int, maxCount int) ([]module.Transaction, int)
- func (tp *TransactionPool) CheckTxs(wc state.WorldContext) bool
- func (tp *TransactionPool) DropOldTXs(bts int64)
- func (tp *TransactionPool) FilterTransactions(bloom *TxBloom, max int) []module.Transaction
- func (tp *TransactionPool) GetBloom() *TxBloom
- func (tp *TransactionPool) HasTx(tid []byte) bool
- func (tp *TransactionPool) RemoveList(txs module.TransactionList)
- func (tp *TransactionPool) SetPoolCapacityMonitor(pcm PoolCapacityMonitor)
- func (tp *TransactionPool) SetTxManager(txm TxWaiterManager)
- func (tp *TransactionPool) Size() int
- func (tp *TransactionPool) Used() int
- type TransactionReactor
- func (r *TransactionReactor) OnFailure(err error, pi module.ProtocolInfo, b []byte)
- func (r *TransactionReactor) OnJoin(id module.PeerID)
- func (r *TransactionReactor) OnLeave(id module.PeerID)
- func (r *TransactionReactor) OnReceive(subProtocol module.ProtocolInfo, buf []byte, peerId module.PeerID) (bool, error)
- func (r *TransactionReactor) PropagateTransaction(tx transaction.Transaction) error
- func (r *TransactionReactor) Start(wallet module.Wallet)
- func (r *TransactionReactor) Stop()
- type TransactionShare
- func (ts *TransactionShare) EnableTxRequest(yn bool)
- func (ts *TransactionShare) HandleJoin(peer module.PeerID)
- func (ts *TransactionShare) HandleLeave(peer module.PeerID)
- func (ts *TransactionShare) HandleRequestTransaction(buf []byte, peer module.PeerID) (bool, error)
- func (ts *TransactionShare) OnPoolCapacityUpdated(group module.TransactionGroup, size, used int)
- func (ts *TransactionShare) Start(handler module.ProtocolHandler, wallet module.Wallet)
- func (ts *TransactionShare) Stop()
- type TxBloom
- type TxDrop
- type TxTimestampChecker
- type TxWaiterManager
Constants ¶
const ( DuplicateTransactionError errors.Code = iota + errors.CodeService TransactionPoolOverflowError ExpiredTransactionError FutureTransactionError TransitionInterruptedError InvalidTransactionError InvalidQueryError InvalidResultError NoActiveContractError NotContractAddressError InvalidPatchDataError CommittedTransactionError )
const ( LogLevelNone = iota LogLevelMsg LogLevelDebug )
const ( ReactorName = "transaction" ReactorPriority = 4 )
const ( ConfigTXTimestampThresholdDefault = int64(5 * time.Minute / time.Microsecond) ConfigPatchTimestampThreshold = int64(1 * time.Minute / time.Microsecond) )
const ConfigTransitionResultCacheEntryCount = 10
const ConfigTransitionResultCacheEntrySize = 1024 * 1024
const (
RetryCount = 2
)
Variables ¶
var ( ErrDuplicateTransaction = errors.NewBase(DuplicateTransactionError, "DuplicateTransaction") ErrTransactionPoolOverFlow = errors.NewBase(TransactionPoolOverflowError, "TransactionPoolOverFlow") ErrExpiredTransaction = errors.NewBase(ExpiredTransactionError, "ExpiredTransaction") ErrTransitionInterrupted = errors.NewBase(TransitionInterruptedError, "TransitionInterrupted") ErrInvalidTransaction = errors.NewBase(InvalidTransactionError, "InvalidTransaction") ErrCommittedTransaction = errors.NewBase(CommittedTransactionError, "CommittedTransaction") )
Functions ¶
func CheckTxTimestamp ¶
func CheckTxTimestamp(min, max int64, tx transaction.Transaction) error
func DurationToTimestamp ¶
func FinalizeTransition ¶ added in v0.9.6
func FinalizeTransition(tr module.Transition, opt int, noFlush bool) error
FinalizeTransition finalize parts of transition result without updating other information of service manager. It's only for development purpose. So, normally it should not be used.
func NewInitTransition ¶ added in v0.9.6
func NewInitTransition( db db.Database, result []byte, vl module.ValidatorList, cm contract.ContractManager, em eeproxy.Manager, chain module.Chain, logger log.Logger, plt Platform, tsc *TxTimestampChecker, ) (module.Transition, error)
NewInitTransition creates initial transition based on the last result. It's only for development purpose. So, normally it should not be used.
func NewManager ¶
func NewSyncTransition ¶ added in v0.9.7
func NewSyncTransition( tr module.Transition, sm SyncManager, result []byte, vl []byte, ) module.Transition
func NewTransition ¶ added in v0.9.6
func NewTransition( parent module.Transition, patchtxs module.TransactionList, normaltxs module.TransactionList, bi module.BlockInfo, csi module.ConsensusInfo, alreadyValidated bool, ) module.Transition
NewTransition creates new transition based on the parent to execute given transactions under given environments. It's only for development purpose. So, normally it should not be used.
func NewWorldSnapshot ¶ added in v0.9.6
func NewWorldSnapshot(database db.Database, plt Platform, result []byte, vl module.ValidatorList) (state.WorldSnapshot, error)
func PatchTransition ¶ added in v0.9.8
func PatchTransition( tr module.Transition, bi module.BlockInfo, ptxs module.TransactionList, ) module.Transition
func TimestampToDuration ¶
func TransactionTimestampThreshold ¶
func TransactionTimestampThreshold(wc state.WorldContext, g module.TransactionGroup) int64
Types ¶
type ExecutionResult ¶ added in v0.9.4
type ExecutionResult interface { PatchReceipts() module.ReceiptList NormalReceipts() module.ReceiptList TotalFee() *big.Int VirtualFee() *big.Int }
func NewExecutionResult ¶ added in v0.9.4
func NewExecutionResult(p, n module.ReceiptList, vfee, fee *big.Int) ExecutionResult
type Platform ¶ added in v0.9.1
type Platform interface { NewContractManager(dbase db.Database, dir string, logger log.Logger) (contract.ContractManager, error) NewExtensionSnapshot(dbase db.Database, raw []byte) state.ExtensionSnapshot NewExtensionWithBuilder(builder merkle.Builder, raw []byte) state.ExtensionSnapshot OnExtensionSnapshotFinalization(ess state.ExtensionSnapshot, logger log.Logger) ToRevision(value int) module.Revision NewBaseTransaction(wc state.WorldContext) (module.Transaction, error) OnExecutionBegin(wc state.WorldContext, logger log.Logger) error OnExecutionEnd(wc state.WorldContext, er ExecutionResult, logger log.Logger) error Term() DefaultBlockVersion() int }
type PoolCapacityMonitor ¶
type PoolCapacityMonitor interface {
OnPoolCapacityUpdated(group module.TransactionGroup, size, used int)
}
type QueryHandler ¶
type QueryHandler struct {
// contains filtered or unexported fields
}
func NewQueryHandler ¶
func NewQueryHandler(cm contract.ContractManager, to module.Address, data []byte) (*QueryHandler, error)
type SyncManager ¶ added in v0.9.7
type TimestampRange ¶
type TimestampRange interface {
CheckTx(tx transaction.Transaction) error
}
func NewDummyTimeStampRange ¶
func NewDummyTimeStampRange() TimestampRange
func NewTimestampRange ¶
func NewTimestampRange(bts int64, th int64) TimestampRange
func NewTxTimestampRangeFor ¶
func NewTxTimestampRangeFor(c state.WorldContext, g module.TransactionGroup) TimestampRange
type TransactionManager ¶
type TransactionManager struct {
// contains filtered or unexported fields
}
func NewTransactionManager ¶
func NewTransactionManager(nid int, tsc *TxTimestampChecker, ptp *TransactionPool, ntp *TransactionPool, bk db.Bucket, logger log.Logger) *TransactionManager
func (*TransactionManager) Add ¶
func (m *TransactionManager) Add(tx transaction.Transaction, direct bool) error
func (*TransactionManager) AddAndWait ¶
func (m *TransactionManager) AddAndWait(tx transaction.Transaction) ( <-chan interface{}, error, )
func (*TransactionManager) Candidate ¶
func (m *TransactionManager) Candidate( g module.TransactionGroup, wc state.WorldContext, maxBytes, maxCount int, ) ([]module.Transaction, int)
func (*TransactionManager) FilterTransactions ¶
func (m *TransactionManager) FilterTransactions(g module.TransactionGroup, bloom *TxBloom, max int) []module.Transaction
func (*TransactionManager) GetBloomOf ¶
func (m *TransactionManager) GetBloomOf(g module.TransactionGroup) *TxBloom
func (*TransactionManager) HasTx ¶
func (m *TransactionManager) HasTx(id []byte) bool
func (*TransactionManager) Logger ¶
func (m *TransactionManager) Logger() log.Logger
func (*TransactionManager) NotifyFinalized ¶
func (m *TransactionManager) NotifyFinalized( l1 module.TransactionList, r1 module.ReceiptList, l2 module.TransactionList, r2 module.ReceiptList, )
func (*TransactionManager) OnTxDrops ¶
func (m *TransactionManager) OnTxDrops(drops []TxDrop)
func (*TransactionManager) RemoveOldTxByBlockTS ¶
func (m *TransactionManager) RemoveOldTxByBlockTS(group module.TransactionGroup, bts int64)
func (*TransactionManager) RemoveTxs ¶
func (m *TransactionManager) RemoveTxs( g module.TransactionGroup, l module.TransactionList, )
func (*TransactionManager) SetPoolCapacityMonitor ¶
func (m *TransactionManager) SetPoolCapacityMonitor(pcm PoolCapacityMonitor)
func (*TransactionManager) Wait ¶
func (m *TransactionManager) Wait(wc state.WorldContext, cb func()) bool
func (*TransactionManager) WaitResult ¶
func (m *TransactionManager) WaitResult(id []byte) (<-chan interface{}, error)
type TransactionPool ¶
type TransactionPool struct {
// contains filtered or unexported fields
}
func NewTransactionPool ¶
func NewTransactionPool(group module.TransactionGroup, size int, txdb db.Bucket, m Monitor, log log.Logger) *TransactionPool
func (*TransactionPool) Add ¶
func (tp *TransactionPool) Add(tx transaction.Transaction, direct bool) error
return nil if tx is nil or tx is added to pool return ErrTransactionPoolOverFlow if pool is full
func (*TransactionPool) Candidate ¶
func (tp *TransactionPool) Candidate(wc state.WorldContext, maxBytes int, maxCount int) ( []module.Transaction, int, )
It returns all candidates for a negative integer n.
func (*TransactionPool) CheckTxs ¶
func (tp *TransactionPool) CheckTxs(wc state.WorldContext) bool
func (*TransactionPool) DropOldTXs ¶
func (tp *TransactionPool) DropOldTXs(bts int64)
func (*TransactionPool) FilterTransactions ¶
func (tp *TransactionPool) FilterTransactions(bloom *TxBloom, max int) []module.Transaction
func (*TransactionPool) GetBloom ¶
func (tp *TransactionPool) GetBloom() *TxBloom
func (*TransactionPool) HasTx ¶
func (tp *TransactionPool) HasTx(tid []byte) bool
func (*TransactionPool) RemoveList ¶
func (tp *TransactionPool) RemoveList(txs module.TransactionList)
removeList remove transactions when transactions are finalized.
func (*TransactionPool) SetPoolCapacityMonitor ¶
func (tp *TransactionPool) SetPoolCapacityMonitor(pcm PoolCapacityMonitor)
func (*TransactionPool) SetTxManager ¶
func (tp *TransactionPool) SetTxManager(txm TxWaiterManager)
func (*TransactionPool) Size ¶
func (tp *TransactionPool) Size() int
func (*TransactionPool) Used ¶
func (tp *TransactionPool) Used() int
type TransactionReactor ¶
type TransactionReactor struct {
// contains filtered or unexported fields
}
func NewTransactionReactor ¶
func NewTransactionReactor(nm module.NetworkManager, tm *TransactionManager) *TransactionReactor
func (*TransactionReactor) OnFailure ¶
func (r *TransactionReactor) OnFailure(err error, pi module.ProtocolInfo, b []byte)
func (*TransactionReactor) OnJoin ¶
func (r *TransactionReactor) OnJoin(id module.PeerID)
func (*TransactionReactor) OnLeave ¶
func (r *TransactionReactor) OnLeave(id module.PeerID)
func (*TransactionReactor) OnReceive ¶
func (r *TransactionReactor) OnReceive(subProtocol module.ProtocolInfo, buf []byte, peerId module.PeerID) (bool, error)
func (*TransactionReactor) PropagateTransaction ¶
func (r *TransactionReactor) PropagateTransaction(tx transaction.Transaction) error
func (*TransactionReactor) Start ¶
func (r *TransactionReactor) Start(wallet module.Wallet)
func (*TransactionReactor) Stop ¶
func (r *TransactionReactor) Stop()
type TransactionShare ¶
type TransactionShare struct {
// contains filtered or unexported fields
}
func NewTransactionShare ¶
func NewTransactionShare(tm *TransactionManager) *TransactionShare
func (*TransactionShare) EnableTxRequest ¶
func (ts *TransactionShare) EnableTxRequest(yn bool)
func (*TransactionShare) HandleJoin ¶
func (ts *TransactionShare) HandleJoin(peer module.PeerID)
func (*TransactionShare) HandleLeave ¶
func (ts *TransactionShare) HandleLeave(peer module.PeerID)
func (*TransactionShare) HandleRequestTransaction ¶
func (*TransactionShare) OnPoolCapacityUpdated ¶
func (ts *TransactionShare) OnPoolCapacityUpdated(group module.TransactionGroup, size, used int)
func (*TransactionShare) Start ¶
func (ts *TransactionShare) Start(handler module.ProtocolHandler, wallet module.Wallet)
func (*TransactionShare) Stop ¶
func (ts *TransactionShare) Stop()
type TxBloom ¶
func (*TxBloom) ContainsAllOf ¶
type TxTimestampChecker ¶
type TxTimestampChecker struct {
// contains filtered or unexported fields
}
func NewTimestampChecker ¶
func NewTimestampChecker() *TxTimestampChecker
func (*TxTimestampChecker) CheckWithCurrent ¶
func (c *TxTimestampChecker) CheckWithCurrent(min int64, tx transaction.Transaction) error
func (*TxTimestampChecker) SetThreshold ¶
func (c *TxTimestampChecker) SetThreshold(d time.Duration)
func (*TxTimestampChecker) Threshold ¶
func (c *TxTimestampChecker) Threshold() int64
func (*TxTimestampChecker) TransactionThreshold ¶
func (c *TxTimestampChecker) TransactionThreshold(group module.TransactionGroup) int64
type TxWaiterManager ¶
type TxWaiterManager interface {
OnTxDrops([]TxDrop)
}
Source Files ¶
- databaseadaptor.go
- error.go
- executionresult.go
- inspect.go
- log.go
- manager.go
- memberlist.go
- platform.go
- queryhandler.go
- transactionlist.go
- transactionmanager.go
- transactionpool.go
- transactionreactor.go
- transition.go
- transition_pe.go
- transition_se.go
- transitionresult.go
- transitionresultcache.go
- tschecker.go
- txshare.go