burrow: github.com/hyperledger/burrow/acm/acmstate Index | Files

package acmstate

import "github.com/hyperledger/burrow/acm/acmstate"

Index

Package Files

dump_state.go memory_state.go metadata_cache.go state.go state_cache.go

func GlobalAccountPermissions Uses

func GlobalAccountPermissions(getter AccountGetter) (permission.AccountPermissions, error)

Get global permissions from the account at GlobalPermissionsAddress

type AccountGetter Uses

type AccountGetter interface {
    // Get an account by its address return nil if it does not exist (which should not be an error)
    GetAccount(address crypto.Address) (*acm.Account, error)
}

type AccountIterable Uses

type AccountIterable interface {
    // Iterates through accounts calling passed function once per account, if the consumer
    // returns true the iteration breaks and returns true to indicate it iteration
    // was escaped
    IterateAccounts(consumer func(*acm.Account) error) (err error)
}

type AccountStats Uses

type AccountStats struct {
    AccountsWithCode    uint64
    AccountsWithoutCode uint64
}

type AccountStatsGetter Uses

type AccountStatsGetter interface {
    GetAccountStats() AccountStats
}

type AccountUpdater Uses

type AccountUpdater interface {
    // Updates the fields of updatedAccount by address, creating the account
    // if it does not exist
    UpdateAccount(updatedAccount *acm.Account) error
    // Remove the account at address
    RemoveAccount(address crypto.Address) error
}

type Cache Uses

type Cache struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

func NewCache Uses

func NewCache(backend Reader, options ...CacheOption) *Cache

Returns a Cache that wraps an underlying Reader to use on a cache miss, can write to an output Writer via Sync. Goroutine safe for concurrent access.

func (*Cache) GetAccount Uses

func (cache *Cache) GetAccount(address crypto.Address) (*acm.Account, error)

func (*Cache) GetStorage Uses

func (cache *Cache) GetStorage(address crypto.Address, key binary.Word256) ([]byte, error)

func (*Cache) IterateCachedAccount Uses

func (cache *Cache) IterateCachedAccount(consumer func(*acm.Account) (stop bool)) (stopped bool, err error)

Iterates over all cached accounts first in cache and then in backend until consumer returns true for 'stop'

func (*Cache) IterateCachedStorage Uses

func (cache *Cache) IterateCachedStorage(address crypto.Address,
    consumer func(key binary.Word256, value []byte) error) error

Iterates over all cached storage items first in cache and then in backend until consumer returns true for 'stop'

func (*Cache) RemoveAccount Uses

func (cache *Cache) RemoveAccount(address crypto.Address) error

func (*Cache) Reset Uses

func (cache *Cache) Reset(backend Reader)

Resets the cache to empty initialising the backing map to the same size as the previous iteration.

func (*Cache) SetStorage Uses

func (cache *Cache) SetStorage(address crypto.Address, key binary.Word256, value []byte) error

NOTE: Set value to zero to remove.

func (*Cache) String Uses

func (cache *Cache) String() string

func (*Cache) Sync Uses

func (cache *Cache) Sync(st Writer) error

Syncs changes to the backend in deterministic order. Sends storage updates before updating the account they belong so that storage values can be taken account of in the update.

func (*Cache) UpdateAccount Uses

func (cache *Cache) UpdateAccount(account *acm.Account) error

type CacheOption Uses

type CacheOption func(*Cache) *Cache
var ReadOnly CacheOption = func(cache *Cache) *Cache {
    cache.readonly = true
    return cache
}

func Named Uses

func Named(name string) CacheOption

type CodeHash Uses

type CodeHash [32]byte

CodeHash is the keccak hash for the code for an account. This is used for the EVM CODEHASH opcode, and to find the correct Metadata for a contract

func (*CodeHash) Bytes Uses

func (h *CodeHash) Bytes() []byte

func (CodeHash) MarshalText Uses

func (ch CodeHash) MarshalText() ([]byte, error)

func (CodeHash) String Uses

func (ch CodeHash) String() string

func (*CodeHash) UnmarshalText Uses

func (ch *CodeHash) UnmarshalText(hexBytes []byte) error

type DumpState Uses

type DumpState struct {
    bytes.Buffer
}

func (*DumpState) RemoveAccount Uses

func (dw *DumpState) RemoveAccount(address crypto.Address) error

func (*DumpState) SetStorage Uses

func (dw *DumpState) SetStorage(address crypto.Address, key, value []byte) error

func (*DumpState) UpdateAccount Uses

func (dw *DumpState) UpdateAccount(updatedAccount *acm.Account) error

type Iterable Uses

type Iterable interface {
    AccountIterable
    StorageIterable
}

type IterableReader Uses

type IterableReader interface {
    Iterable
    Reader
}

Read and list account and storage state

type IterableReaderWriter Uses

type IterableReaderWriter interface {
    Iterable
    Reader
    Writer
}

type IterableStatsReader Uses

type IterableStatsReader interface {
    Iterable
    Reader
    AccountStatsGetter
}

type MemoryState Uses

type MemoryState struct {
    Accounts map[crypto.Address]*acm.Account
    Storage  map[crypto.Address]map[binary.Word256][]byte
    Metadata map[MetadataHash]string
}

func NewMemoryState Uses

func NewMemoryState() *MemoryState

Get an in-memory state IterableReader

func (*MemoryState) GetAccount Uses

func (ms *MemoryState) GetAccount(address crypto.Address) (*acm.Account, error)

func (*MemoryState) GetMetadata Uses

func (ms *MemoryState) GetMetadata(metahash MetadataHash) (string, error)

func (*MemoryState) GetStorage Uses

func (ms *MemoryState) GetStorage(address crypto.Address, key binary.Word256) ([]byte, error)

func (*MemoryState) IterateAccounts Uses

func (ms *MemoryState) IterateAccounts(consumer func(*acm.Account) error) (err error)

func (*MemoryState) IterateStorage Uses

func (ms *MemoryState) IterateStorage(address crypto.Address, consumer func(key binary.Word256, value []byte) error) (err error)

func (*MemoryState) RemoveAccount Uses

func (ms *MemoryState) RemoveAccount(address crypto.Address) error

func (*MemoryState) SetMetadata Uses

func (ms *MemoryState) SetMetadata(metahash MetadataHash, metadata string) error

func (*MemoryState) SetStorage Uses

func (ms *MemoryState) SetStorage(address crypto.Address, key binary.Word256, value []byte) error

func (*MemoryState) UpdateAccount Uses

func (ms *MemoryState) UpdateAccount(updatedAccount *acm.Account) error

type MetadataCache Uses

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

func NewMetadataCache Uses

func NewMetadataCache(backend MetadataReader) *MetadataCache

func (*MetadataCache) GetMetadata Uses

func (cache *MetadataCache) GetMetadata(metahash MetadataHash) (string, error)

func (*MetadataCache) Reset Uses

func (cache *MetadataCache) Reset(backend MetadataReader)

func (*MetadataCache) SetMetadata Uses

func (cache *MetadataCache) SetMetadata(metahash MetadataHash, metadata string) error

func (*MetadataCache) Sync Uses

func (cache *MetadataCache) Sync(st MetadataWriter) error

Syncs changes to the backend in deterministic order. Sends storage updates before updating the account they belong so that storage values can be taken account of in the update.

type MetadataHash Uses

type MetadataHash [32]byte

MetadataHash is the keccak hash for the metadata. This is to make the metadata content-addressed

func GetMetadataHash Uses

func GetMetadataHash(metadata string) (metahash MetadataHash)

func (*MetadataHash) Bytes Uses

func (h *MetadataHash) Bytes() []byte

func (MetadataHash) MarshalText Uses

func (ch MetadataHash) MarshalText() ([]byte, error)

func (MetadataHash) String Uses

func (ch MetadataHash) String() string

func (*MetadataHash) UnmarshalText Uses

func (ch *MetadataHash) UnmarshalText(hexBytes []byte) error

type MetadataReader Uses

type MetadataReader interface {
    // Get an Metadata by its hash. This is content-addressed
    GetMetadata(metahash MetadataHash) (string, error)
}

type MetadataReaderWriter Uses

type MetadataReaderWriter interface {
    MetadataReader
    MetadataWriter
}

type MetadataWriter Uses

type MetadataWriter interface {
    // Set an Metadata according to it keccak-256 hash.
    SetMetadata(metahash MetadataHash, metadata string) error
}

type Reader Uses

type Reader interface {
    AccountGetter
    StorageGetter
}

Read-only account and storage state

type ReaderWriter Uses

type ReaderWriter interface {
    Reader
    Writer
}

Read and write account and storage state

type StorageGetter Uses

type StorageGetter interface {
    // Retrieve a 32-byte value stored at key for the account at address, return Zero256 if key does not exist but
    // error if address does not
    GetStorage(address crypto.Address, key binary.Word256) (value []byte, err error)
}

type StorageIterable Uses

type StorageIterable interface {
    // Iterates through the storage of account ad address calling the passed function once per account,
    // if the iterator function returns true the iteration breaks and returns true to indicate it iteration
    // was escaped
    IterateStorage(address crypto.Address, consumer func(key binary.Word256, value []byte) error) (err error)
}

type StorageSetter Uses

type StorageSetter interface {
    // Store a 32-byte value at key for the account at address, setting to Zero256 removes the key
    SetStorage(address crypto.Address, key binary.Word256, value []byte) error
}

type Writer Uses

type Writer interface {
    AccountUpdater
    StorageSetter
}

Package acmstate imports 13 packages (graph) and is imported by 68 packages. Updated 2020-05-03. Refresh now. Tools for package owners.