Documentation ¶
Index ¶
- func NewBlockTxnCaches(sc *StateCache, b Block) (*BlockCache, *TransactionCache)
- type Block
- type BlockCache
- type BlockCacher
- type Copyer
- type EmptyValue
- type QueryBlockCache
- type StateCache
- type String
- type TransactionCache
- func (tc *TransactionCache) AddHit()
- func (tc *TransactionCache) AddMiss()
- func (tc *TransactionCache) Commit()
- func (tc *TransactionCache) Get(key string) (Value, bool)
- func (tc *TransactionCache) Remove(key string)
- func (tc *TransactionCache) Set(key string, e Value)
- func (tc *TransactionCache) Stats() (hit, miss int64)
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBlockTxnCaches ¶
func NewBlockTxnCaches(sc *StateCache, b Block) (*BlockCache, *TransactionCache)
NewBlockTxnCaches creates a new block cache and a transaction cache for the given block
Types ¶
type BlockCache ¶
type BlockCache struct {
// contains filtered or unexported fields
}
BlockCache is a pre commit cache for all changes in a block. This is mainly for caching values in current block when executing blocks.
Call `Commit()` method to merge the changes to the StateCache when the block is executed.
func NewBlockCache ¶
func NewBlockCache(main *StateCache, b Block) *BlockCache
func (*BlockCache) Commit ¶
func (pcc *BlockCache) Commit()
Commit moves the values from the pre-commit cache to the main cache
func (*BlockCache) Get ¶
func (pcc *BlockCache) Get(key string) (Value, bool)
Get returns the value with the given key
func (*BlockCache) Round ¶
func (pcc *BlockCache) Round() int64
func (*BlockCache) Set ¶
func (pcc *BlockCache) Set(key string, e Value)
Set sets the value with the given key in the pre-commit cache
func (*BlockCache) SetBlockHash ¶
func (pcc *BlockCache) SetBlockHash(hash string)
SetBlockHash sets the block hash, which is used after miners generating the block. miners generator does not know the block hash until the block is generated.
func (*BlockCache) Stats ¶
func (pcc *BlockCache) Stats() (hit, miss int64)
type BlockCacher ¶
type Copyer ¶
type Copyer interface { // CopyFrom copies the value from the given value, returns false if not able to copy CopyFrom(v interface{}) bool }
type EmptyValue ¶
type EmptyValue struct{}
func (*EmptyValue) Clone ¶
func (e *EmptyValue) Clone() Value
func (*EmptyValue) CopyFrom ¶
func (e *EmptyValue) CopyFrom(interface{}) bool
type QueryBlockCache ¶
type QueryBlockCache struct {
// contains filtered or unexported fields
}
QueryBlockCache is a read-only cache for querying values from the current block.
func NewQueryBlockCache ¶
func NewQueryBlockCache(sc *StateCache, blockHash string) *QueryBlockCache
NewQueryBlockCache creates a new QueryBlockCache instance.
func (*QueryBlockCache) Commit ¶
func (qbc *QueryBlockCache) Commit()
func (*QueryBlockCache) Get ¶
func (qbc *QueryBlockCache) Get(key string) (Value, bool)
Get returns the value with the given key from the current block cache.
func (*QueryBlockCache) Round ¶
func (qbc *QueryBlockCache) Round() int64
type StateCache ¶
type StateCache struct {
// contains filtered or unexported fields
}
func NewStateCache ¶
func NewStateCache() *StateCache
func (*StateCache) Get ¶
func (sc *StateCache) Get(key, blockHash string) (Value, bool)
Get returns the value with the given key and block hash
func (*StateCache) Remove ¶
func (sc *StateCache) Remove(key string)
Remove removes the values map with the given key
func (*StateCache) Stats ¶
func (sc *StateCache) Stats() (hits int64, miss int64)
type TransactionCache ¶
type TransactionCache struct {
// contains filtered or unexported fields
}
func NewTransactionCache ¶
func NewTransactionCache(main BlockCacher) *TransactionCache
func (*TransactionCache) AddHit ¶
func (tc *TransactionCache) AddHit()
func (*TransactionCache) AddMiss ¶
func (tc *TransactionCache) AddMiss()
func (*TransactionCache) Commit ¶
func (tc *TransactionCache) Commit()
func (*TransactionCache) Remove ¶
func (tc *TransactionCache) Remove(key string)
func (*TransactionCache) Set ¶
func (tc *TransactionCache) Set(key string, e Value)
func (*TransactionCache) Stats ¶
func (tc *TransactionCache) Stats() (hit, miss int64)