store

package
v0.0.0-...-a173fca Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: LGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//AliasPrefix storage alias used prefix
	AliasPrefix = "alias"
	//AddressStorage Object stored with the address as the KEY
	AddressStorage = "AddressStorage"
)
View Source
const (
	//CandidateAddrs Participates in the selection of the address set of block nodes
	CandidateAddrs = "CandidateAddrs"
	//StakeStorage With the address as the KEY, the relevant content is stored
	StakeStorage = "StakeStorage"

	RegisterPledgeLimit uint64 = 50000000 //The candidate node needs the total number of collateral COINS, unit 1drep

)
View Source
const (
	MODULENAME     = "store"
	ChangeInterval = "changeInterval"
)

Variables

View Source
var (
	//ErrRecoverRoot recover root err
	ErrRecoverRoot = errors.New("fail to recover root state")
	//ErrUsedAlias the alias has been used
	ErrUsedAlias = errors.New("the alias has been used")
	//ErrInvalidateAlias set null string as alias
	ErrInvalidateAlias = errors.New("set null string as alias")
)
View Source
var (
	MetaDataPrefix   = []byte("metaData_")
	ChainStatePrefix = []byte("chainState_")
	BlockPrefix      = []byte("block_")
	BlockNodePrefix  = []byte("blockNode_")
)

Functions

func GetInterestRate

func GetInterestRate() (threeMonth, sixMonth, oneYear, moreOneYear uint64)

Show interest rates in 3 months, 3-6 months, 6-12 months and more

Types

type ChainStore

type ChainStore struct {
	dbinterface.KeyValueStore
}

func (*ChainStore) BlockNodeCount

func (chainStore *ChainStore) BlockNodeCount() int64

func (*ChainStore) BlockNodeIterator

func (chainStore *ChainStore) BlockNodeIterator(handle func(*types.BlockHeader, types.BlockStatus) error) error

func (*ChainStore) DeleteReceipts

func (chainStore *ChainStore) DeleteReceipts(blockHash crypto.Hash) error

func (*ChainStore) GetBlock

func (chainStore *ChainStore) GetBlock(hash *crypto.Hash) (*types.Block, error)

func (*ChainStore) GetBlockHeader

func (chainStore *ChainStore) GetBlockHeader(hash *crypto.Hash) (*types.BlockHeader, error)

func (*ChainStore) GetBlockNode

func (chainStore *ChainStore) GetBlockNode(hash *crypto.Hash, height uint64) (*types.BlockHeader, types.BlockStatus, error)

func (*ChainStore) GetReceipt

func (chainStore *ChainStore) GetReceipt(txHash crypto.Hash) *types.Receipt

func (*ChainStore) GetReceipts

func (chainStore *ChainStore) GetReceipts(blockHash crypto.Hash) []*types.Receipt

func (*ChainStore) HasBlock

func (chainStore *ChainStore) HasBlock(hash *crypto.Hash) bool

func (*ChainStore) PutBlock

func (chainStore *ChainStore) PutBlock(block *types.Block) error

func (*ChainStore) PutBlockNode

func (chainStore *ChainStore) PutBlockNode(blockNode *types.BlockNode) error

func (*ChainStore) PutReceipt

func (chainStore *ChainStore) PutReceipt(txHash crypto.Hash, receipt *types.Receipt) error

func (*ChainStore) PutReceipts

func (chainStore *ChainStore) PutReceipts(blockHash crypto.Hash, receipts []*types.Receipt) error

func (*ChainStore) RollBack

func (chainStore *ChainStore) RollBack(height uint64, hash *crypto.Hash) (error, int64)

type Store

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

func (Store) AddBalance

func (s Store) AddBalance(addr *crypto.CommonAddress, height uint64, amount *big.Int) error

func (Store) AddCandidateAddr

func (s Store) AddCandidateAddr(addr *crypto.CommonAddress) error

func (Store) AliasExist

func (s Store) AliasExist(alias string) bool

func (Store) AliasGet

func (s Store) AliasGet(alias string) (*crypto.CommonAddress, error)

func (Store) AliasSet

func (s Store) AliasSet(addr *crypto.CommonAddress, alias string, height uint64) (err error)

func (Store) CancelCandidateCredit

func (s Store) CancelCandidateCredit(fromAddr *crypto.CommonAddress, cancelBalance *big.Int, height uint64) (*types.CancelCreditDetail, error)

func (Store) CancelVoteCredit

func (s Store) CancelVoteCredit(fromAddr, toAddr *crypto.CommonAddress, cancelBalance *big.Int, height uint64) (*types.CancelCreditDetail, error)

func (Store) CandidateCredit

func (s Store) CandidateCredit(fromAddr *crypto.CommonAddress, addBalance *big.Int, data []byte, height uint64) error

func (Store) Commit

func (s Store) Commit()

func (Store) CopyState

func (s Store) CopyState() *database.SnapShot

func (Store) DeleteStorage

func (s Store) DeleteStorage(addr *crypto.CommonAddress) error

func (Store) Empty

func (s Store) Empty(addr *crypto.CommonAddress) bool

func (Store) Get

func (s Store) Get(key []byte) ([]byte, error)

func (Store) GetBalance

func (s Store) GetBalance(addr *crypto.CommonAddress, height uint64) *big.Int

func (Store) GetByteCode

func (s Store) GetByteCode(addr *crypto.CommonAddress) []byte

func (Store) GetCandidateAddrs

func (s Store) GetCandidateAddrs() ([]crypto.CommonAddress, error)

func (Store) GetCandidateData

func (s Store) GetCandidateData(addr *crypto.CommonAddress) ([]byte, error)

func (Store) GetChangeInterval

func (s Store) GetChangeInterval() (uint64, error)

func (Store) GetCodeHash

func (s Store) GetCodeHash(addr *crypto.CommonAddress) crypto.Hash

func (*Store) GetCreditDetails

func (s *Store) GetCreditDetails(addr *crypto.CommonAddress) map[crypto.CommonAddress]big.Int

func (Store) GetNonce

func (s Store) GetNonce(addr *crypto.CommonAddress) uint64

func (Store) GetReputation

func (s Store) GetReputation(addr *crypto.CommonAddress) *big.Int

func (Store) GetStateRoot

func (s Store) GetStateRoot() []byte

func (Store) GetStorageAlias

func (s Store) GetStorageAlias(addr *crypto.CommonAddress) string

func (Store) GetVoteCreditCount

func (s Store) GetVoteCreditCount(addr *crypto.CommonAddress) *big.Int

func (Store) Put

func (s Store) Put(key []byte, value []byte) error

func (Store) PutBalance

func (s Store) PutBalance(addr *crypto.CommonAddress, height uint64, balance *big.Int) error

func (Store) PutByteCode

func (s Store) PutByteCode(addr *crypto.CommonAddress, byteCode []byte) error

func (Store) PutNonce

func (s Store) PutNonce(addr *crypto.CommonAddress, nonce uint64) error

func (*Store) RecoverTrie

func (s *Store) RecoverTrie(root []byte) bool

func (*Store) RevertState

func (s *Store) RevertState(shot *database.SnapShot)

func (Store) SubBalance

func (s Store) SubBalance(addr *crypto.CommonAddress, height uint64, amount *big.Int) error

func (Store) TrieDB

func (s Store) TrieDB() *trie.Database

func (Store) VoteCredit

func (s Store) VoteCredit(fromAddr *crypto.CommonAddress, to *crypto.CommonAddress, addBalance *big.Int, height uint64) error

type StoreDB

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

func NewStoreDB

func NewStoreDB(store dbinterface.KeyValueStore, cache *database.TransactionStore, trie *trie.SecureTrie, trieDb *trie.Database) *StoreDB

func (*StoreDB) CopyState

func (s *StoreDB) CopyState() *database.SnapShot

func (*StoreDB) Delete

func (s *StoreDB) Delete(key []byte) error

func (*StoreDB) Flush

func (s *StoreDB) Flush()

func (*StoreDB) Get

func (s *StoreDB) Get(key []byte) ([]byte, error)

func (*StoreDB) Put

func (s *StoreDB) Put(key []byte, value []byte) error

func (*StoreDB) RecoverTrie

func (s *StoreDB) RecoverTrie(root []byte) bool

func (*StoreDB) RevertState

func (s *StoreDB) RevertState(shot *database.SnapShot)

type StoreInterface

type StoreInterface interface {
	DeleteStorage(addr *crypto.CommonAddress) error

	GetStorageAlias(addr *crypto.CommonAddress) string
	AliasGet(alias string) (*crypto.CommonAddress, error)
	AliasExist(alias string) bool
	AliasSet(addr *crypto.CommonAddress, alias string, height uint64) (err error)

	GetBalance(addr *crypto.CommonAddress, height uint64) *big.Int
	PutBalance(addr *crypto.CommonAddress, height uint64, balance *big.Int) error
	AddBalance(addr *crypto.CommonAddress, height uint64, amount *big.Int) error
	SubBalance(addr *crypto.CommonAddress, height uint64, amount *big.Int) error

	GetNonce(addr *crypto.CommonAddress) uint64
	PutNonce(addr *crypto.CommonAddress, nonce uint64) error

	GetByteCode(addr *crypto.CommonAddress) []byte
	GetCodeHash(addr *crypto.CommonAddress) crypto.Hash
	PutByteCode(addr *crypto.CommonAddress, byteCode []byte) error

	GetReputation(addr *crypto.CommonAddress) *big.Int
	GetStateRoot() []byte
	RecoverTrie(root []byte) bool

	TrieDB() *trie.Database
	Get(key []byte) ([]byte, error)
	Put(key []byte, value []byte) error
	Commit()

	CopyState() *database.SnapShot
	RevertState(shot *database.SnapShot)

	Empty(addr *crypto.CommonAddress) bool
	GetChangeInterval() (uint64, error)

	//pos
	GetCandidateAddrs() ([]crypto.CommonAddress, error)
	GetVoteCreditCount(addr *crypto.CommonAddress) *big.Int
	CancelVoteCredit(fromAddr, toAddr *crypto.CommonAddress, cancelBalance *big.Int, height uint64) (*types.CancelCreditDetail, error)
	VoteCredit(addresses *crypto.CommonAddress, to *crypto.CommonAddress, addBalance *big.Int, height uint64) error
	CandidateCredit(addresses *crypto.CommonAddress, addBalance *big.Int, data []byte, height uint64) error
	CancelCandidateCredit(fromAddr *crypto.CommonAddress, cancelBalance *big.Int, height uint64) (*types.CancelCreditDetail, error)
	GetCandidateData(addr *crypto.CommonAddress) ([]byte, error)
	AddCandidateAddr(addr *crypto.CommonAddress) error
	GetCreditDetails(addr *crypto.CommonAddress) map[crypto.CommonAddress]big.Int
}

func TrieStoreFromStore

func TrieStoreFromStore(diskDB dbinterface.KeyValueStore, stateRoot []byte) (StoreInterface, error)

Jump to

Keyboard shortcuts

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