service

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: Apache-2.0 Imports: 27 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 (
	LogLevelNone = iota
	LogLevelMsg
	LogLevelDebug
)
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 ConfigTransitionResultCacheEntryCount = 10
View Source
const ConfigTransitionResultCacheEntrySize = 1024 * 1024
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 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 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 NewManager(chain module.Chain, nm module.NetworkManager,
	eem eeproxy.Manager, plt Platform, contractDir string,
) (module.ServiceManager, error)

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 TimestampToDuration(t int64) time.Duration

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

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 []byte) ssync.Syncer
}

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, bk db.Bucket, logger log.Logger) *TransactionManager

func (*TransactionManager) Add

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