store

package
v0.0.0-...-9faecf3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: LGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AliasPrefix    = "alias"
	AddressStorage = "AddressStorage" //以地址作为KEY的对象存储
)
View Source
const (
	CandidateAddrs = "CandidateAddrs" //参与竞选出块节点的地址集合
	StakeStorage   = "StakeStorage"   //以地址作为KEY,存储stake相关内容

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

Variables

View Source
var (
	ErrRecoverRoot     = errors.New("fail to recover root state")
	ErrUsedAlias       = errors.New("the alias has been used")
	ErrInvalidateAlias = errors.New("set null string as alias")
)

Functions

func GetInterestRate

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

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

func NewStakeStorage

func NewStakeStorage(store *StoreDB) *trieStakeStore

func NewTrieAccoutStore

func NewTrieAccoutStore(store *StoreDB) *trieAccountStore

Types

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) (err error)

func (Store) CancelCandidateCredit

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

func (Store) CancelVoteCredit

func (s Store) CancelVoteCredit(fromAddr, toAddr *crypto.CommonAddress, cancelBalance *big.Int, height uint64) (*types.IntersetDetail, 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) (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.IntersetDetail, 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.IntersetDetail, error)
	GetCandidateData(addr *crypto.CommonAddress) ([]byte, error)
	AddCandidateAddr(addr *crypto.CommonAddress) error
}

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