Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultConfig is the default config for actpool DefaultConfig = Config{ MaxNumActsPerPool: 32000, MaxGasLimitPerPool: 320000000, MaxNumActsPerAcct: 2000, WorkerBufferSize: 2000, ActionExpiry: 10 * time.Minute, MinGasPriceStr: big.NewInt(unit.Qev).String(), BlackList: []string{}, } )
View Source
var ( // ErrGasTooHigh error when the intrinsic gas of an action is too high ErrGasTooHigh = errors.New("action gas is too high") )
Functions ¶
func WithClock ¶
func WithClock(c clock.Clock) interface{ ActQueueOption }
WithClock returns an option to overwrite clock.
func WithTimeOut ¶
func WithTimeOut(ttl time.Duration) interface{ ActQueueOption }
WithTimeOut returns an option to overwrite time out setting.
Types ¶
type ActPool ¶
type ActPool interface { action.SealedEnvelopeValidator // Reset resets actpool state Reset() // PendingActionMap returns an action map with all accepted actions PendingActionMap() map[string][]*action.SealedEnvelope // Add adds an action into the pool after passing validation Add(ctx context.Context, act *action.SealedEnvelope) error // GetPendingNonce returns pending nonce in pool given an account address GetPendingNonce(addr string) (uint64, error) // GetUnconfirmedActs returns unconfirmed actions in pool given an account address GetUnconfirmedActs(addr string) []*action.SealedEnvelope // GetActionByHash returns the pending action in pool given action's hash GetActionByHash(hash hash.Hash256) (*action.SealedEnvelope, error) // GetSize returns the act pool size GetSize() uint64 // GetCapacity returns the act pool capacity GetCapacity() uint64 // GetGasSize returns the act pool gas size GetGasSize() uint64 // GetGasCapacity returns the act pool gas capacity GetGasCapacity() uint64 // DeleteAction deletes an invalid action from pool DeleteAction(address.Address) // ReceiveBlock will be called when a new block is committed ReceiveBlock(*block.Block) error AddActionEnvelopeValidators(...action.SealedEnvelopeValidator) }
ActPool is the interface of actpool
func NewActPool ¶
func NewActPool(g genesis.Genesis, sf protocol.StateReader, cfg Config, opts ...Option) (ActPool, error)
NewActPool constructs a new actpool
type ActQueue ¶
type ActQueue interface { Put(*action.SealedEnvelope) error UpdateQueue() []*action.SealedEnvelope UpdateAccountState(uint64, *big.Int) []*action.SealedEnvelope AccountState() (uint64, *big.Int) PendingNonce() uint64 NextAction() (bool, *big.Int) Len() int Empty() bool PendingActs(context.Context) []*action.SealedEnvelope AllActs() []*action.SealedEnvelope PopActionWithLargestNonce() *action.SealedEnvelope Reset() }
ActQueue is the interface of actQueue
func NewActQueue ¶
func NewActQueue(ap *actPool, address string, pendingNonce uint64, balance *big.Int, ops ...ActQueueOption) ActQueue
NewActQueue create a new action queue
type ActQueueOption ¶
type ActQueueOption interface {
SetActQueueOption(*actQueue)
}
ActQueueOption is the option for actQueue.
type Config ¶
type Config struct { // MaxNumActsPerPool indicates maximum number of actions the whole actpool can hold MaxNumActsPerPool uint64 `yaml:"maxNumActsPerPool"` // MaxGasLimitPerPool indicates maximum gas limit the whole actpool can hold MaxGasLimitPerPool uint64 `yaml:"maxGasLimitPerPool"` // MaxNumActsPerAcct indicates maximum number of actions an account queue can hold MaxNumActsPerAcct uint64 `yaml:"maxNumActsPerAcct"` // WorkerBufferSize indicates the buffer size for each worker's job queue WorkerBufferSize uint64 `yaml:"bufferPerAcct"` // ActionExpiry defines how long an action will be kept in action pool. ActionExpiry time.Duration `yaml:"actionExpiry"` // MinGasPriceStr defines the minimal gas price the delegate will accept for an action MinGasPriceStr string `yaml:"minGasPrice"` // BlackList lists the account address that are banned from initiating actions BlackList []string `yaml:"blackList"` }
Config is the actpool config
func (Config) MinGasPrice ¶
MinGasPrice returns the minimal gas price threshold
type SortedActions ¶
type SortedActions []*action.SealedEnvelope
SortedActions is a slice of actions that implements sort.Interface to sort by Value.
func (SortedActions) Len ¶
func (p SortedActions) Len() int
func (SortedActions) Less ¶
func (p SortedActions) Less(i, j int) bool
func (SortedActions) Swap ¶
func (p SortedActions) Swap(i, j int)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.