rabbit

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: Apache-2.0 Imports: 6 Imported by: 5

Documentation

Index

Constants

View Source
const (
	KeySize = 8 // 2 for fuzz, 8 for production

	NotFound  = 0
	EmptySlot = 1
	Exists    = 2

	MaxFindDepth = 100
)
View Source
const (
	EmptyMarkerIndex = 0
	PassbyNumIndex   = 1
	KeyLenStart      = PassbyNumIndex + 4
	KeyStart         = KeyLenStart + 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedValue

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

When a transaction accesses the underlying store with the 'RabbitJump' algorithm, each "rabbit hole" is modeled as a CacheValue. A SimpleCacheStore caches all the "rabbit holes" which are read or written during a transaction.

func BytesToCachedValue

func BytesToCachedValue(buf []byte) *CachedValue

func (*CachedValue) GetKey

func (v *CachedValue) GetKey() []byte

func (*CachedValue) GetValue

func (v *CachedValue) GetValue() []byte

func (*CachedValue) IsEmpty

func (v *CachedValue) IsEmpty() bool

func (*CachedValue) SetValue

func (v *CachedValue) SetValue(bz []byte)

func (*CachedValue) ToBytes

func (v *CachedValue) ToBytes() []byte

type RabbitStore

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

RabbitStore inherits SimpleMultiStore to implement the 'RabbitJump' algorithm

func NewRabbitStore

func NewRabbitStore(parent types.BaseStoreI) (rabbit RabbitStore)

func NewReadOnlyRabbitStore

func NewReadOnlyRabbitStore(parent types.BaseStoreI) (rabbit RabbitStore)

func NewReadOnlyRabbitStoreAtHeight added in v0.4.0

func NewReadOnlyRabbitStoreAtHeight(parent types.BaseStoreI, height uint64) (rabbit RabbitStore)

func (*RabbitStore) ActiveCount

func (rabbit *RabbitStore) ActiveCount() int

func (*RabbitStore) CachedEntryCount added in v0.1.2

func (rabbit *RabbitStore) CachedEntryCount() int

func (*RabbitStore) Close

func (rabbit *RabbitStore) Close()

func (*RabbitStore) CloseAndWriteBack

func (rabbit *RabbitStore) CloseAndWriteBack(dirty bool)

func (*RabbitStore) Delete

func (rabbit *RabbitStore) Delete(key []byte)

func (*RabbitStore) Get

func (rabbit *RabbitStore) Get(key []byte) []byte

func (*RabbitStore) GetBaseStore

func (rabbit *RabbitStore) GetBaseStore() types.BaseStoreI

func (*RabbitStore) GetShortKeyPath

func (rabbit *RabbitStore) GetShortKeyPath(key []byte) (path [][KeySize]byte, ok bool)

func (*RabbitStore) Has

func (rabbit *RabbitStore) Has(key []byte) bool

func (*RabbitStore) IsClean

func (rabbit *RabbitStore) IsClean() bool

func (*RabbitStore) ScanAllShortKeys

func (rabbit *RabbitStore) ScanAllShortKeys(fn func(key [KeySize]byte, dirty bool) bool)

func (*RabbitStore) Set

func (rabbit *RabbitStore) Set(key []byte, bz []byte)

func (*RabbitStore) WriteBack

func (rabbit *RabbitStore) WriteBack()

type SimpleCacheStore

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

func NewSimpleCacheStore

func NewSimpleCacheStore() *SimpleCacheStore

func (*SimpleCacheStore) GetValue

func (scs *SimpleCacheStore) GetValue(key [KeySize]byte) (value *CachedValue, status types.CacheStatus)

func (*SimpleCacheStore) ScanAllDirtyEntries

func (scs *SimpleCacheStore) ScanAllDirtyEntries(fn func(key, value []byte, isDeleted bool))

func (*SimpleCacheStore) ScanAllShortKeys

func (scs *SimpleCacheStore) ScanAllShortKeys(fn func(key [KeySize]byte, dirty bool) bool)

func (*SimpleCacheStore) SetValue

func (scs *SimpleCacheStore) SetValue(key [KeySize]byte, value *CachedValue)

func (*SimpleCacheStore) Size added in v0.1.2

func (scs *SimpleCacheStore) Size() int

type SimpleMultiStore

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

A SimpleMultiStore serves a transaction which uses 'RabbitJump' algorithm to access KVs. Its parent can be TrunkStore or RootStore, from which it reads data. It uses SimpleMultiStore to buffer the written data from a transaction, such that later SLOAD instructions can get the data written by previous SSTORE instructions. Before it is closed, it holds a read-lock of its parent. After it is closed, the cache's content can be written back to its parent. The write-back processes should be carefully managed by the client code to make sure there is no contention to the parent.

func NewReadOnlySimpleMultiStore added in v0.4.0

func NewReadOnlySimpleMultiStore(parent types.BaseStoreI) SimpleMultiStore

func NewReadOnlySimpleMultiStoreAtHeight added in v0.4.0

func NewReadOnlySimpleMultiStoreAtHeight(parent types.BaseStoreI, height uint64) SimpleMultiStore

func NewSimpleMultiStore

func NewSimpleMultiStore(parent types.BaseStoreI) SimpleMultiStore

func (*SimpleMultiStore) Close

func (sms *SimpleMultiStore) Close()

func (*SimpleMultiStore) GetCachedValue

func (sms *SimpleMultiStore) GetCachedValue(key [KeySize]byte) *CachedValue

func (*SimpleMultiStore) MustGetCachedValue

func (sms *SimpleMultiStore) MustGetCachedValue(key [KeySize]byte) *CachedValue

func (*SimpleMultiStore) SetCachedValue

func (sms *SimpleMultiStore) SetCachedValue(key [KeySize]byte, cv *CachedValue)

func (*SimpleMultiStore) WriteBack

func (sms *SimpleMultiStore) WriteBack()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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