chain_utils

package
v2.12.1-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// hash -> address + height
	AccountBlockHashKeyPrefix = byte(1)

	// address + height -> hash
	AccountBlockHeightKeyPrefix = byte(2)

	// send block hash -> receive block hash
	ReceiveKeyPrefix = byte(3)

	// address + height -> snapshot block height
	ConfirmHeightKeyPrefix = byte(4)

	// toAddress + hash -> empty
	OnRoadKeyPrefix = byte(5)

	// hash -> height
	SnapshotBlockHashKeyPrefix = byte(7)

	// height -> hash
	SnapshotBlockHeightKeyPrefix = byte(8)

	// address -> account id
	AccountAddressKeyPrefix = byte(9)
	// account id -> address
	AccountIdKeyPrefix = byte(10)
)

index db

View Source
const (
	StorageKeyPrefix = byte(1)

	StorageHistoryKeyPrefix = byte(2)

	BalanceKeyPrefix = byte(3)

	BalanceHistoryKeyPrefix = byte(4)

	CodeKeyPrefix = byte(5)

	ContractMetaKeyPrefix = byte(7)

	GidContractKeyPrefix = byte(9)

	VmLogListKeyPrefix = byte(10)

	CallDepthKeyPrefix = byte(11)
)

state db

View Source
const (
	// toAddress + fromAddress + fromHeight + fromHash -> fromIndex
	OnRoadAddressHeightKeyPrefix = byte(1)
)
View Source
const (
	SnapshotKeyPrefix = byte(1)
)

state redo db

Variables

This section is empty.

Functions

func BytesToUint64

func BytesToUint64(bytes []byte) uint64

func CreateBalanceKeyPrefix

func CreateBalanceKeyPrefix(address types.Address) []byte

func CreateGidContractPrefixKey

func CreateGidContractPrefixKey(gid *types.Gid) []byte

func CreateHistoryStorageValueKeyPrefix

func CreateHistoryStorageValueKeyPrefix(address *types.Address, prefix []byte) []byte

func CreateStorageValueKeyPrefix

func CreateStorageValueKeyPrefix(address *types.Address, prefix []byte) []byte

func DeserializeLocation

func DeserializeLocation(bytes []byte) *chain_file_manager.Location

func SerializeLocation

func SerializeLocation(location *chain_file_manager.Location) []byte

func Uint64Put

func Uint64Put(bytes []byte, height uint64) []byte

func Uint64ToBytes

func Uint64ToBytes(height uint64) []byte

Types

type AccountAddressKey

type AccountAddressKey [1 + types.AddressSize]byte

--------------------------------

func CreateAccountAddressKey

func CreateAccountAddressKey(addr *types.Address) AccountAddressKey

func (*AccountAddressKey) AddressRefill

func (key *AccountAddressKey) AddressRefill(addr types.Address)

func (AccountAddressKey) Bytes

func (key AccountAddressKey) Bytes() []byte

func (AccountAddressKey) String

func (key AccountAddressKey) String() string

type AccountBlockHashKey

type AccountBlockHashKey [1 + types.HashSize]byte

-------------------------------

func CreateAccountBlockHashKey

func CreateAccountBlockHashKey(blockHash *types.Hash) AccountBlockHashKey

====== index db ======

func (AccountBlockHashKey) Bytes

func (key AccountBlockHashKey) Bytes() []byte

func (*AccountBlockHashKey) HashRefill

func (key *AccountBlockHashKey) HashRefill(hash types.Hash)

func (AccountBlockHashKey) String

func (key AccountBlockHashKey) String() string

type AccountBlockHeightKey

type AccountBlockHeightKey [1 + types.AddressSize + types.HeightSize]byte

-------------------------------

func CreateAccountBlockHeightKey

func CreateAccountBlockHeightKey(addr *types.Address, height uint64) AccountBlockHeightKey

func (*AccountBlockHeightKey) AddressRefill

func (key *AccountBlockHeightKey) AddressRefill(addr types.Address)

func (AccountBlockHeightKey) Bytes

func (key AccountBlockHeightKey) Bytes() []byte

func (*AccountBlockHeightKey) HeightRefill

func (key *AccountBlockHeightKey) HeightRefill(height uint64)

func (AccountBlockHeightKey) String

func (key AccountBlockHeightKey) String() string

type AccountIdKey

type AccountIdKey [1 + types.AccountIdSize]byte

--------------------------------

func CreateAccountIdKey

func CreateAccountIdKey(accountId uint64) AccountIdKey

func (*AccountIdKey) AccountIdRefill

func (key *AccountIdKey) AccountIdRefill(accountId uint64)

func (AccountIdKey) Bytes

func (key AccountIdKey) Bytes() []byte

func (AccountIdKey) String

func (key AccountIdKey) String() string

type BalanceHistoryKey

type BalanceHistoryKey [1 + types.AddressSize + types.TokenTypeIdSize + types.HeightSize]byte

-------------------------------

func CreateHistoryBalanceKey

func CreateHistoryBalanceKey(address types.Address, tokenTypeId types.TokenTypeId, snapshotHeight uint64) BalanceHistoryKey

func (*BalanceHistoryKey) AddressRefill

func (key *BalanceHistoryKey) AddressRefill(addr types.Address)

func (BalanceHistoryKey) Bytes

func (key BalanceHistoryKey) Bytes() []byte

func (BalanceHistoryKey) Construct

func (key BalanceHistoryKey) Construct(bytes []byte) *BalanceHistoryKey

func (BalanceHistoryKey) EqualAddressAndTokenId

func (key BalanceHistoryKey) EqualAddressAndTokenId(addr types.Address, tokenId types.TokenTypeId) bool

func (BalanceHistoryKey) ExtraHeight

func (key BalanceHistoryKey) ExtraHeight() uint64

func (BalanceHistoryKey) ExtraTokenId

func (key BalanceHistoryKey) ExtraTokenId() types.TokenTypeId

func (*BalanceHistoryKey) HeightRefill

func (key *BalanceHistoryKey) HeightRefill(height uint64)

func (BalanceHistoryKey) String

func (key BalanceHistoryKey) String() string

func (*BalanceHistoryKey) TokenIdRefill

func (key *BalanceHistoryKey) TokenIdRefill(tokenId types.TokenTypeId)

type BalanceKey

type BalanceKey [1 + types.AddressSize + types.TokenTypeIdSize]byte

-------------------------------

func CreateBalanceKey

func CreateBalanceKey(address types.Address, tokenTypeId types.TokenTypeId) BalanceKey

func (*BalanceKey) AddressRefill

func (key *BalanceKey) AddressRefill(addr types.Address)

func (BalanceKey) Bytes

func (key BalanceKey) Bytes() []byte

func (BalanceKey) String

func (key BalanceKey) String() string

func (*BalanceKey) TokenIdRefill

func (key *BalanceKey) TokenIdRefill(tokenId types.TokenTypeId)

type CallDepthKey

type CallDepthKey [1 + types.HashSize]byte

-------------------------------

func CreateCallDepthKey

func CreateCallDepthKey(blockHash types.Hash) CallDepthKey

func (CallDepthKey) Bytes

func (key CallDepthKey) Bytes() []byte

func (*CallDepthKey) HashRefill

func (key *CallDepthKey) HashRefill(hash types.Hash)

func (CallDepthKey) String

func (key CallDepthKey) String() string

type CodeKey

type CodeKey [1 + types.AddressSize]byte

-------------------------------

func CreateCodeKey

func CreateCodeKey(address types.Address) CodeKey

func (*CodeKey) AddressRefill

func (key *CodeKey) AddressRefill(addr types.Address)

func (CodeKey) Bytes

func (key CodeKey) Bytes() []byte

func (CodeKey) String

func (key CodeKey) String() string

type ConfirmHeightKey

type ConfirmHeightKey [1 + types.AddressSize + types.HeightSize]byte

--------------------------------

func CreateConfirmHeightKey

func CreateConfirmHeightKey(addr *types.Address, height uint64) ConfirmHeightKey

func (*ConfirmHeightKey) AddressRefill

func (key *ConfirmHeightKey) AddressRefill(addr types.Address)

func (ConfirmHeightKey) Bytes

func (key ConfirmHeightKey) Bytes() []byte

func (*ConfirmHeightKey) HeightRefill

func (key *ConfirmHeightKey) HeightRefill(height uint64)

func (ConfirmHeightKey) String

func (key ConfirmHeightKey) String() string

type ContractMetaKey

type ContractMetaKey [1 + types.AddressSize]byte

-------------------------------

func CreateContractMetaKey

func CreateContractMetaKey(address types.Address) ContractMetaKey

func (*ContractMetaKey) AddressRefill

func (key *ContractMetaKey) AddressRefill(addr types.Address)

func (ContractMetaKey) Bytes

func (key ContractMetaKey) Bytes() []byte

func (ContractMetaKey) String

func (key ContractMetaKey) String() string

type DBKey

type DBKey interface {
	Bytes() []byte
	String() string
}

type DBKeyAddressRefill

type DBKeyAddressRefill interface {
	AddressRefill(addr types.Address)
}

type DBKeyBalance

type DBKeyBalance interface {
	DBKey
	DBKeyAddressRefill
	DBKeyTokenIdRefill
}

type DBKeyHashRefill

type DBKeyHashRefill interface {
	HashRefill(hash types.Hash)
}

type DBKeyHeightRefill

type DBKeyHeightRefill interface {
	HeightRefill(height uint64)
}

type DBKeyRealKeyRefill

type DBKeyRealKeyRefill interface {
	KeyRefill(real StorageRealKey)
}

type DBKeyStorage

type DBKeyStorage interface {
	DBKey
	DBKeyAddressRefill
	DBKeyRealKeyRefill
}

type DBKeyTokenIdRefill

type DBKeyTokenIdRefill interface {
	TokenIdRefill(tokenId types.TokenTypeId)
}

type GidContractKey

type GidContractKey [1 + types.GidSize + types.AddressSize]byte

-------------------------------

func CreateGidContractKey

func CreateGidContractKey(gid types.Gid, address *types.Address) GidContractKey

func (*GidContractKey) AddressRefill

func (key *GidContractKey) AddressRefill(addr types.Address)

func (GidContractKey) Bytes

func (key GidContractKey) Bytes() []byte

func (*GidContractKey) GidRefill

func (key *GidContractKey) GidRefill(gid types.Gid)

func (GidContractKey) String

func (key GidContractKey) String() string

type OnRoadHeightKey added in v2.11.3

func CreateOnRoadAddressHeightKey added in v2.11.3

func CreateOnRoadAddressHeightKey(toAddr types.Address, fromAddr types.Address, fromHeight uint64, fromHash types.Hash) OnRoadHeightKey

func NewOnRoadHeightKey added in v2.11.3

func NewOnRoadHeightKey() OnRoadHeightKey

func (OnRoadHeightKey) Bytes added in v2.11.3

func (key OnRoadHeightKey) Bytes() []byte

func (*OnRoadHeightKey) FromAddressRefill added in v2.11.3

func (key *OnRoadHeightKey) FromAddressRefill(addr types.Address)

func (*OnRoadHeightKey) FromHashRefill added in v2.11.3

func (key *OnRoadHeightKey) FromHashRefill(hash types.Hash)

func (*OnRoadHeightKey) FromHeightRefill added in v2.11.3

func (key *OnRoadHeightKey) FromHeightRefill(height uint64)

func (*OnRoadHeightKey) IteratorPrefix added in v2.11.3

func (key *OnRoadHeightKey) IteratorPrefix(toAddress, fromAddress types.Address) []byte

func (OnRoadHeightKey) String added in v2.11.3

func (key OnRoadHeightKey) String() string

func (*OnRoadHeightKey) ToAddressRefill added in v2.11.3

func (key *OnRoadHeightKey) ToAddressRefill(addr types.Address)

type OnRoadKey

type OnRoadKey [1 + types.AddressSize + types.HashSize]byte

--------------------------------

func CreateOnRoadKey

func CreateOnRoadKey(toAddr types.Address, blockHash types.Hash) OnRoadKey

func (*OnRoadKey) AddressRefill

func (key *OnRoadKey) AddressRefill(addr types.Address)

func (OnRoadKey) Bytes

func (key OnRoadKey) Bytes() []byte

func (*OnRoadKey) HashRefill

func (key *OnRoadKey) HashRefill(hash types.Hash)

func (OnRoadKey) String

func (key OnRoadKey) String() string

type ReceiveKey

type ReceiveKey [1 + types.HashSize]byte

-------------------------------

func CreateReceiveKey

func CreateReceiveKey(sendBlockHash *types.Hash) ReceiveKey

func (ReceiveKey) Bytes

func (key ReceiveKey) Bytes() []byte

func (*ReceiveKey) HashRefill

func (key *ReceiveKey) HashRefill(hash types.Hash)

func (ReceiveKey) String

func (key ReceiveKey) String() string

type SnapshotBlockHashKey

type SnapshotBlockHashKey [1 + types.HashSize]byte

--------------------------------

func CreateSnapshotBlockHashKey

func CreateSnapshotBlockHashKey(snapshotBlockHash *types.Hash) SnapshotBlockHashKey

func (SnapshotBlockHashKey) Bytes

func (key SnapshotBlockHashKey) Bytes() []byte

func (*SnapshotBlockHashKey) HashRefill

func (key *SnapshotBlockHashKey) HashRefill(hash types.Hash)

func (SnapshotBlockHashKey) String

func (key SnapshotBlockHashKey) String() string

type SnapshotBlockHeightKey

type SnapshotBlockHeightKey [1 + types.HeightSize]byte

--------------------------------

func CreateSnapshotBlockHeightKey

func CreateSnapshotBlockHeightKey(snapshotBlockHeight uint64) SnapshotBlockHeightKey

func (SnapshotBlockHeightKey) Bytes

func (key SnapshotBlockHeightKey) Bytes() []byte

func (*SnapshotBlockHeightKey) HeightRefill

func (key *SnapshotBlockHeightKey) HeightRefill(height uint64)

func (SnapshotBlockHeightKey) String

func (key SnapshotBlockHeightKey) String() string

type SnapshotKey

type SnapshotKey [1 + types.HeightSize]byte

-------------------------------

func CreateRedoSnapshot

func CreateRedoSnapshot(snapshotHeight uint64) SnapshotKey

func (SnapshotKey) Bytes

func (key SnapshotKey) Bytes() []byte

func (*SnapshotKey) HeightRefill

func (key *SnapshotKey) HeightRefill(height uint64)

func (SnapshotKey) String

func (key SnapshotKey) String() string

type StorageHistoryKey

type StorageHistoryKey [1 + types.AddressSize + types.HashSize + 1 + types.HeightSize]byte

-------------------------------

func CreateHistoryStorageValueKey

func CreateHistoryStorageValueKey(address *types.Address, storageKey []byte, snapshotHeight uint64) StorageHistoryKey

func (*StorageHistoryKey) AddressRefill

func (key *StorageHistoryKey) AddressRefill(addr types.Address)

func (StorageHistoryKey) Bytes

func (key StorageHistoryKey) Bytes() []byte

func (StorageHistoryKey) Construct

func (key StorageHistoryKey) Construct(bytes []byte) *StorageHistoryKey

func (StorageHistoryKey) ExtraAddress

func (key StorageHistoryKey) ExtraAddress() types.Address

func (StorageHistoryKey) ExtraHeight

func (key StorageHistoryKey) ExtraHeight() uint64

func (StorageHistoryKey) ExtraKeyAndLen

func (key StorageHistoryKey) ExtraKeyAndLen() []byte

func (*StorageHistoryKey) HeightRefill

func (key *StorageHistoryKey) HeightRefill(height uint64)

func (*StorageHistoryKey) KeyRefill

func (key *StorageHistoryKey) KeyRefill(real StorageRealKey)

func (StorageHistoryKey) String

func (key StorageHistoryKey) String() string

type StorageKey

type StorageKey [1 + types.AddressSize + types.HashSize + 1]byte

-------------------------------

func CreateStorageValueKey

func CreateStorageValueKey(address *types.Address, storageKey []byte) StorageKey

func (*StorageKey) AddressRefill

func (key *StorageKey) AddressRefill(addr types.Address)

func (StorageKey) Bytes

func (key StorageKey) Bytes() []byte

func (*StorageKey) KeyLenRefill

func (key *StorageKey) KeyLenRefill(len int)

func (*StorageKey) KeyRefill

func (key *StorageKey) KeyRefill(real StorageRealKey)

func (*StorageKey) StorageKeyRefill

func (key *StorageKey) StorageKeyRefill(bytes []byte)

func (StorageKey) String

func (key StorageKey) String() string

type StorageRealKey

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

func (StorageRealKey) Construct

func (key StorageRealKey) Construct(real []byte) StorageRealKey

func (StorageRealKey) ConstructFix

func (key StorageRealKey) ConstructFix(all []byte) StorageRealKey

func (StorageRealKey) Extra

func (key StorageRealKey) Extra() []byte

func (StorageRealKey) String

func (key StorageRealKey) String() string

type VmLogListKey

type VmLogListKey [1 + types.HashSize]byte

-------------------------------

func CreateVmLogListKey

func CreateVmLogListKey(logHash *types.Hash) VmLogListKey

func (VmLogListKey) Bytes

func (key VmLogListKey) Bytes() []byte

func (*VmLogListKey) HashRefill

func (key *VmLogListKey) HashRefill(hash types.Hash)

func (VmLogListKey) String

func (key VmLogListKey) String() string

Jump to

Keyboard shortcuts

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