txcache

package
v1.0.131 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigDestinationMe added in v1.0.123

type ConfigDestinationMe struct {
	Name                        string
	NumChunks                   uint32
	MaxNumItems                 uint32
	MaxNumBytes                 uint32
	NumItemsToPreemptivelyEvict uint32
}

ConfigDestinationMe holds cache configuration

func (*ConfigDestinationMe) String added in v1.0.123

func (config *ConfigDestinationMe) String() string

String returns a readable representation of the object

type ConfigSourceMe added in v1.0.123

type ConfigSourceMe struct {
	Name                          string
	NumChunks                     uint32
	EvictionEnabled               bool
	NumBytesThreshold             uint32
	NumBytesPerSenderThreshold    uint32
	CountThreshold                uint32
	CountPerSenderThreshold       uint32
	NumSendersToPreemptivelyEvict uint32
	MinGasPriceNanoErd            uint32
}

ConfigSourceMe holds cache configuration

func (*ConfigSourceMe) String added in v1.0.123

func (config *ConfigSourceMe) String() string

String returns a readable representation of the object

type CrossTxCache added in v1.0.123

type CrossTxCache struct {
	*immunitycache.ImmunityCache
	// contains filtered or unexported fields
}

CrossTxCache holds cross-shard transactions (where destination == me)

func NewCrossTxCache added in v1.0.123

func NewCrossTxCache(config ConfigDestinationMe) (*CrossTxCache, error)

NewCrossTxCache creates a new transactions cache

func (*CrossTxCache) AddTx added in v1.0.123

func (cache *CrossTxCache) AddTx(tx *WrappedTransaction) (ok bool, added bool)

AddTx adds a transaction in the cache

func (*CrossTxCache) ForEachTransaction added in v1.0.123

func (cache *CrossTxCache) ForEachTransaction(function ForEachTransaction)

ForEachTransaction iterates over the transactions in the cache

func (*CrossTxCache) Get added in v1.0.123

func (cache *CrossTxCache) Get(key []byte) (value interface{}, ok bool)

Get returns the unwrapped payload of a TransactionWrapper Implemented for compatibiltiy reasons (see txPoolsCleaner.go).

func (*CrossTxCache) GetByTxHash added in v1.0.123

func (cache *CrossTxCache) GetByTxHash(txHash []byte) (*WrappedTransaction, bool)

GetByTxHash gets the transaction by hash

func (*CrossTxCache) ImmunizeTxsAgainstEviction added in v1.0.123

func (cache *CrossTxCache) ImmunizeTxsAgainstEviction(keys [][]byte)

ImmunizeTxsAgainstEviction marks items as non-evictable

func (*CrossTxCache) IsInterfaceNil added in v1.0.123

func (cache *CrossTxCache) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*CrossTxCache) Peek added in v1.0.123

func (cache *CrossTxCache) Peek(key []byte) (value interface{}, ok bool)

Peek returns the unwrapped payload of a TransactionWrapper Implemented for compatibiltiy reasons (see transactions.go, common.go).

func (*CrossTxCache) RemoveTxByHash added in v1.0.123

func (cache *CrossTxCache) RemoveTxByHash(txHash []byte) bool

RemoveTxByHash removes tx by hash

type DisabledCache added in v1.0.116

type DisabledCache struct {
}

DisabledCache represents a disabled cache

func NewDisabledCache added in v1.0.116

func NewDisabledCache() *DisabledCache

NewDisabledCache creates a new disabled cache

func (*DisabledCache) AddTx added in v1.0.116

func (cache *DisabledCache) AddTx(_ *WrappedTransaction) (ok bool, added bool)

AddTx does nothing

func (*DisabledCache) Clear added in v1.0.116

func (cache *DisabledCache) Clear()

Clear does nothing

func (*DisabledCache) ForEachTransaction added in v1.0.116

func (cache *DisabledCache) ForEachTransaction(_ ForEachTransaction)

ForEachTransaction does nothing

func (*DisabledCache) Get added in v1.0.116

func (cache *DisabledCache) Get(_ []byte) (value interface{}, ok bool)

Get returns no transaction

func (*DisabledCache) GetByTxHash added in v1.0.116

func (cache *DisabledCache) GetByTxHash(_ []byte) (*WrappedTransaction, bool)

GetByTxHash returns no transaction

func (*DisabledCache) Has added in v1.0.116

func (cache *DisabledCache) Has(_ []byte) bool

Has returns false

func (*DisabledCache) HasOrAdd added in v1.0.116

func (cache *DisabledCache) HasOrAdd(_ []byte, _ interface{}, _ int) (ok, evicted bool)

HasOrAdd returns false, does nothing

func (*DisabledCache) ImmunizeTxsAgainstEviction added in v1.0.123

func (cache *DisabledCache) ImmunizeTxsAgainstEviction(_ [][]byte)

ImmunizeTxsAgainstEviction does nothing

func (*DisabledCache) IsInterfaceNil added in v1.0.116

func (cache *DisabledCache) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*DisabledCache) Keys added in v1.0.116

func (cache *DisabledCache) Keys() [][]byte

Keys returns an empty slice

func (*DisabledCache) Len added in v1.0.116

func (cache *DisabledCache) Len() int

Len returns zero

func (*DisabledCache) MaxSize added in v1.0.116

func (cache *DisabledCache) MaxSize() int

MaxSize returns zero

func (*DisabledCache) NotifyAccountNonce added in v1.0.120

func (cache *DisabledCache) NotifyAccountNonce(_ []byte, _ uint64)

NotifyAccountNonce does nothing

func (*DisabledCache) Peek added in v1.0.116

func (cache *DisabledCache) Peek(_ []byte) (value interface{}, ok bool)

Peek returns no transaction

func (*DisabledCache) Put added in v1.0.116

func (cache *DisabledCache) Put(_ []byte, _ interface{}, _ int) (evicted bool)

Put does nothing

func (*DisabledCache) RegisterHandler added in v1.0.116

func (cache *DisabledCache) RegisterHandler(func(key []byte, value interface{}), string)

RegisterHandler does nothing

func (*DisabledCache) Remove added in v1.0.116

func (cache *DisabledCache) Remove(_ []byte)

Remove does nothing

func (*DisabledCache) RemoveTxByHash added in v1.0.116

func (cache *DisabledCache) RemoveTxByHash(_ []byte) bool

RemoveTxByHash does nothing

func (*DisabledCache) SelectTransactions added in v1.0.116

func (cache *DisabledCache) SelectTransactions(_ int, _ int) []*WrappedTransaction

SelectTransactions returns an empty slice

func (*DisabledCache) UnRegisterHandler added in v1.0.126

func (cache *DisabledCache) UnRegisterHandler(string)

RegisterHandler does nothing

type ForEachTransaction

type ForEachTransaction func(txHash []byte, value *WrappedTransaction)

ForEachTransaction is an iterator callback

type TxCache

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

TxCache represents a cache-like structure (it has a fixed capacity and implements an eviction mechanism) for holding transactions

func NewTxCache

func NewTxCache(config ConfigSourceMe) (*TxCache, error)

NewTxCache creates a new transaction cache

func (*TxCache) AddTx

func (cache *TxCache) AddTx(tx *WrappedTransaction) (ok bool, added bool)

AddTx adds a transaction in the cache Eviction happens if maximum capacity is reached

func (*TxCache) Clear

func (cache *TxCache) Clear()

Clear clears the cache

func (*TxCache) CountSenders

func (cache *TxCache) CountSenders() uint64

CountSenders gets the number of senders in the cache

func (*TxCache) CountTx

func (cache *TxCache) CountTx() uint64

CountTx gets the number of transactions in the cache

func (*TxCache) ForEachTransaction

func (cache *TxCache) ForEachTransaction(function ForEachTransaction)

ForEachTransaction iterates over the transactions in the cache

func (*TxCache) Get

func (cache *TxCache) Get(key []byte) (value interface{}, ok bool)

Get gets a transaction (unwrapped) by hash Implemented for compatibiltiy reasons (see txPoolsCleaner.go).

func (*TxCache) GetByTxHash

func (cache *TxCache) GetByTxHash(txHash []byte) (*WrappedTransaction, bool)

GetByTxHash gets the transaction by hash

func (*TxCache) Has

func (cache *TxCache) Has(key []byte) bool

Has checks if a transaction exists

func (*TxCache) HasOrAdd

func (cache *TxCache) HasOrAdd(_ []byte, _ interface{}, _ int) (ok, evicted bool)

HasOrAdd is not implemented

func (*TxCache) ImmunizeTxsAgainstEviction added in v1.0.123

func (cache *TxCache) ImmunizeTxsAgainstEviction(_ [][]byte)

ImmunizeTxsAgainstEviction does nothing for this type of cache

func (*TxCache) IsInterfaceNil

func (cache *TxCache) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*TxCache) Keys

func (cache *TxCache) Keys() [][]byte

Keys returns the tx hashes in the cache

func (*TxCache) Len

func (cache *TxCache) Len() int

Len is an alias for CountTx

func (*TxCache) MaxSize

func (cache *TxCache) MaxSize() int

MaxSize is not implemented

func (*TxCache) NotifyAccountNonce

func (cache *TxCache) NotifyAccountNonce(accountKey []byte, nonce uint64)

NotifyAccountNonce should be called by external components (such as interceptors and transactions processor) in order to inform the cache about initial nonce gap phenomena

func (*TxCache) NumBytes

func (cache *TxCache) NumBytes() uint64

NumBytes gets the approximate number of bytes stored in the cache

func (*TxCache) Peek

func (cache *TxCache) Peek(key []byte) (value interface{}, ok bool)

Peek gets a transaction (unwrapped) by hash Implemented for compatibiltiy reasons (see transactions.go, common.go).

func (*TxCache) Put

func (cache *TxCache) Put(_ []byte, _ interface{}, _ int) (evicted bool)

Put is not implemented

func (*TxCache) RegisterHandler

func (cache *TxCache) RegisterHandler(func(key []byte, value interface{}), string)

RegisterHandler is not implemented

func (*TxCache) Remove

func (cache *TxCache) Remove(key []byte)

Remove removes tx by hash

func (*TxCache) RemoveTxByHash

func (cache *TxCache) RemoveTxByHash(txHash []byte) bool

RemoveTxByHash removes tx by hash

func (*TxCache) SelectTransactions

func (cache *TxCache) SelectTransactions(numRequested int, batchSizePerSender int) []*WrappedTransaction

SelectTransactions selects a reasonably fair list of transactions to be included in the next miniblock It returns at most "numRequested" transactions Each sender gets the chance to give at least "batchSizePerSender" transactions, unless "numRequested" limit is reached before iterating over all senders

func (*TxCache) UnRegisterHandler added in v1.0.126

func (cache *TxCache) UnRegisterHandler(string)

UnRegisterHandler is not implemented

type WrappedTransaction

type WrappedTransaction struct {
	Tx              data.TransactionHandler
	TxHash          []byte
	SenderShardID   uint32
	ReceiverShardID uint32
	// contains filtered or unexported fields
}

WrappedTransaction contains a transaction, its hash and extra information

func (*WrappedTransaction) GetKey added in v1.0.123

func (wrappedTx *WrappedTransaction) GetKey() []byte

GetKey gets the transaction hash

func (*WrappedTransaction) ImmunizeAgainstEviction added in v1.0.123

func (wrappedTx *WrappedTransaction) ImmunizeAgainstEviction()

ImmunizeAgainstEviction marks the transaction as immune to eviction

func (*WrappedTransaction) IsImmuneToEviction added in v1.0.123

func (wrappedTx *WrappedTransaction) IsImmuneToEviction() bool

IsImmuneToEviction returns whether the transaction is immune to eviction

func (*WrappedTransaction) Size added in v1.0.123

func (wrappedTx *WrappedTransaction) Size() int

Size gets the size (in bytes) of the transaction

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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