service

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DuplicateTransactionError errors.Code = iota + errors.CodeService
	TransactionPoolOverflowError
	ExpiredTransactionError
	FutureTransactionError
	TransitionInterruptedError
	InvalidTransactionError
	InvalidQueryError
	InvalidResultError
	NoActiveContractError
	NotContractAddressError
	InvalidPatchDataError
	CommittedTransactionError
)
View Source
const (
	ConfigTransitionResultCacheEntryCount = 10
	ConfigTransitionResultCacheEntrySize  = 1024 * 1024
	ConfigMaxDroppedTxSlotSize            = 10000
	ConfigDroppedTxSlotDuration           = 1000 * time.Millisecond
)
View Source
const (
	ReactorName     = "transaction"
	ReactorPriority = 4
)
View Source
const (
	ConfigTXTimestampThresholdDefault = int64(5 * time.Minute / time.Microsecond)
	ConfigPatchTimestampThreshold     = int64(1 * time.Minute / time.Microsecond)
)
View Source
const (
	ExFlagBTPData = 1 << iota
)
View Source
const InvalidHeight = -1
View Source
const (
	RetryCount = 2
)

Variables

View Source
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 BTPDigestHashFromResult added in v1.3.0

func BTPDigestHashFromResult(result []byte) ([]byte, error)

func CheckTxTimestamp

func CheckTxTimestamp(min, max int64, tx transaction.Transaction) error

func DurationToTimestamp

func DurationToTimestamp(d time.Duration) int64

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 Inspect

func Inspect(c module.Chain, informal bool) map[string]interface{}

func NewBTPContext added in v1.3.0

func NewBTPContext(dbase db.Database, result []byte) (state.BTPContext, error)

func NewExecutionResult added in v0.9.4

func NewExecutionResult(p, n module.ReceiptList, vfee, fee *big.Int) base.ExecutionResult

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 base.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 NewManager(chain module.Chain, nm module.NetworkManager,
	eem eeproxy.Manager, plt base.Platform, contractDir string,
) (module.ServiceManager, error)

func NewSyncTransition added in v0.9.7

func NewSyncTransition(
	tr module.Transition,
	sm SyncManager,
	result []byte, vl []byte,
	noBuffer bool,
) 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 base.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 TimestampToDuration(t int64) time.Duration

func TransactionTimestampThreshold

func TransactionTimestampThreshold(wc state.WorldContext, g module.TransactionGroup) int64

Types

type Monitor

type Monitor interface {
	OnDropTx(n int, user bool)
	OnAddTx(n int, user bool)
	OnRemoveTx(n int, user bool)
	OnCommit(id []byte, ts time.Time, d time.Duration)
}

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)

func (*QueryHandler) Query

func (qh *QueryHandler) Query(ctx contract.Context) (interface{}, error)

type SyncManager added in v0.9.7

type SyncManager interface {
	NewSyncer(ah, prh, nrh, vh, ed, bh []byte, noBuffer bool) ssync.Syncer
}

type TXIDCache added in v1.3.3

type TXIDCache interface {
	Contains(id []byte, ts int64) bool
	Add(id []byte, ts int64)
	RemoveOldTXsByTS(ts int64)
	Len() int
}

func NewTxIDCache added in v1.3.3

func NewTxIDCache(slotDuration time.Duration, slotSize int, logger log.Logger) TXIDCache

type TXIDLogger added in v1.1.1

type TXIDLogger interface {
	Has(id []byte) (bool, error)
	Add(id []byte, force bool) error
	Commit() error
	NewLogger(height int64, ts int64) TXIDLogger
}

type TXIDManager added in v1.1.1

type TXIDManager interface {
	OnThresholdChange()
	HasLocator(id []byte) (bool, error)
	HasRecent(id []byte) (bool, error)
	CheckTXForAdd(tx transaction.Transaction) error
	AddDroppedTX(id []byte, ts int64)
	NewLogger(group module.TransactionGroup, height int64, ts int64) TXIDLogger
}

func NewTXIDManager added in v1.1.1

func NewTXIDManager(dbase db.Database, tsc *TxTimestampChecker, tic TXIDCache) (TXIDManager, error)

type TXIDSet added in v1.1.1

type TXIDSet interface {
	GetHeightOf(id string) (int64, error)
	SetPrevious(p TXIDSet)
	Previous() TXIDSet
}

type TimestampRange

type TimestampRange interface {
	CheckTx(tx transaction.Transaction) error
}

func NewDummyTimeStampRange

func NewDummyTimeStampRange() TimestampRange

func NewTimestampRange

func NewTimestampRange(bts int64, th int64) TimestampRange

type TransactionManager

type TransactionManager struct {
	// contains filtered or unexported fields
}

func NewTransactionManager

func NewTransactionManager(nid int, tsc *TxTimestampChecker, ptp *TransactionPool, ntp *TransactionPool, tim TXIDManager, logger log.Logger) *TransactionManager

func (*TransactionManager) Add

func (m *TransactionManager) Add(tx transaction.Transaction, direct bool, verified 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 (*TransactionManager) HasTx

func (m *TransactionManager) HasTx(id []byte) bool

func (*TransactionManager) Logger

func (m *TransactionManager) Logger() log.Logger

func (*TransactionManager) NotifyFinalized

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 (*TransactionManager) SetPoolCapacityMonitor

func (m *TransactionManager) SetPoolCapacityMonitor(pcm PoolCapacityMonitor)

func (*TransactionManager) VerifyTx added in v1.1.1

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, tim TXIDManager, 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 (*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 (ts *TransactionShare) HandleRequestTransaction(buf []byte, peer module.PeerID) (bool, error)

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

type TxBloom struct {
	Bits  uint
	Bloom big.Int
}

func (*TxBloom) Add

func (b *TxBloom) Add(id []byte)

func (*TxBloom) Contains

func (b *TxBloom) Contains(id []byte) bool

func (*TxBloom) ContainsAllOf

func (b *TxBloom) ContainsAllOf(b2 *TxBloom) bool

func (*TxBloom) Merge

func (b *TxBloom) Merge(b2 *TxBloom)

type TxDrop

type TxDrop struct {
	ID  []byte
	Err error
}

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)
}

Directories

Path Synopsis
platform

Jump to

Keyboard shortcuts

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