db

package
v0.0.0-...-2cf7c70 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2018 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderHashListCount = 2000
	CleanCacheThreshold = 2
	TaskChanCap         = 4
)
View Source
const BITSPERKEY = 10

used to compute the size of bloom filter bits array . too small will lead to high false positive rate.

Variables

View Source
var (
	ErrDBNotFound = errors.New("leveldb: not found")
)

Functions

func NewLedgerStore

func NewLedgerStore() (ILedgerStore, error)

Types

type ChainStore

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

func NewChainStore

func NewChainStore(file string) (*ChainStore, error)

func (*ChainStore) AddHeaders

func (cs *ChainStore) AddHeaders(headers []Header, ledger *Ledger) error

func (*ChainStore) BlockInCache

func (cs *ChainStore) BlockInCache(hash Uint256) bool

func (*ChainStore) CheckBlockHistory

func (cs *ChainStore) CheckBlockHistory(history map[uint32]Uint256) (uint32, bool)

func (*ChainStore) Close

func (cs *ChainStore) Close()

func (*ChainStore) ContainsUnspent

func (cs *ChainStore) ContainsUnspent(txid Uint256, index uint16) (bool, error)

func (*ChainStore) GetAccount

func (cs *ChainStore) GetAccount(programHash Uint160) (*account.AccountState, error)

func (*ChainStore) GetAsset

func (cs *ChainStore) GetAsset(hash Uint256) (*Asset, error)

func (*ChainStore) GetAssets

func (cs *ChainStore) GetAssets() map[Uint256]*Asset

func (*ChainStore) GetBlock

func (cs *ChainStore) GetBlock(hash Uint256) (*Block, error)

func (*ChainStore) GetBlockHash

func (cs *ChainStore) GetBlockHash(height uint32) (Uint256, error)

func (*ChainStore) GetBlockHistory

func (cs *ChainStore) GetBlockHistory(startHeight, blockNum uint32) map[uint32]Uint256

func (*ChainStore) GetBookKeeperList

func (cs *ChainStore) GetBookKeeperList() ([]*crypto.PubKey, []*crypto.PubKey, error)

func (*ChainStore) GetContract

func (cs *ChainStore) GetContract(codeHash Uint160) ([]byte, error)

func (*ChainStore) GetCurrentBlockHash

func (cs *ChainStore) GetCurrentBlockHash() Uint256

func (*ChainStore) GetCurrentHeaderHash

func (cs *ChainStore) GetCurrentHeaderHash() Uint256

func (*ChainStore) GetHeader

func (cs *ChainStore) GetHeader(hash Uint256) (*Header, error)

func (*ChainStore) GetHeaderHashByHeight

func (cs *ChainStore) GetHeaderHashByHeight(height uint32) Uint256

func (*ChainStore) GetHeaderHeight

func (cs *ChainStore) GetHeaderHeight() uint32

func (*ChainStore) GetHeight

func (cs *ChainStore) GetHeight() uint32

func (*ChainStore) GetHeightByBlockHash

func (cs *ChainStore) GetHeightByBlockHash(hash Uint256) (uint32, error)

func (*ChainStore) GetPrepaidInfo

func (cs *ChainStore) GetPrepaidInfo(programHash Uint160) (*Fixed64, *Fixed64, error)

func (*ChainStore) GetQuantityIssued

func (cs *ChainStore) GetQuantityIssued(assetId Uint256) (Fixed64, error)

func (*ChainStore) GetStorage

func (cs *ChainStore) GetStorage(key []byte) ([]byte, error)

func (*ChainStore) GetTransaction

func (cs *ChainStore) GetTransaction(hash Uint256) (*tx.Transaction, error)

func (*ChainStore) GetUnspent

func (cs *ChainStore) GetUnspent(txid Uint256, index uint16) (*tx.TxnOutput, error)

func (*ChainStore) GetUnspentByHeight

func (cs *ChainStore) GetUnspentByHeight(programHash Uint160, assetid Uint256, height uint32) ([]*tx.UTXOUnspent, error)

func (*ChainStore) GetUnspentFromProgramHash

func (cs *ChainStore) GetUnspentFromProgramHash(programHash Uint160, assetid Uint256) ([]*tx.UTXOUnspent, error)

func (*ChainStore) GetUnspentsFromProgramHash

func (cs *ChainStore) GetUnspentsFromProgramHash(programHash Uint160) (map[Uint256][]*tx.UTXOUnspent, error)

func (*ChainStore) GetVotingWeight

func (cs *ChainStore) GetVotingWeight(hash Uint160) (int, error)

TODO get node voting weight form DB

func (*ChainStore) InitLedgerStoreWithGenesisBlock

func (cs *ChainStore) InitLedgerStoreWithGenesisBlock(genesisBlock *Block, defaultBookKeeper []*crypto.PubKey) (uint32, error)

func (*ChainStore) IsBlockInStore

func (cs *ChainStore) IsBlockInStore(hash Uint256) bool

func (*ChainStore) IsDoubleSpend

func (cs *ChainStore) IsDoubleSpend(tx *tx.Transaction) bool

func (*ChainStore) IsTxHashDuplicate

func (cs *ChainStore) IsTxHashDuplicate(txhash Uint256) bool

func (*ChainStore) SaveAsset

func (cs *ChainStore) SaveAsset(assetId Uint256, asset *Asset) error

func (*ChainStore) SaveBlock

func (cs *ChainStore) SaveBlock(b *Block, ledger *Ledger) error

func (*ChainStore) SaveTransaction

func (cs *ChainStore) SaveTransaction(tx *tx.Transaction, height uint32) error

func (*ChainStore) UpdatePrepaidInfo

func (cs *ChainStore) UpdatePrepaidInfo(programHash Uint160, amount, rates Fixed64) error

func (*ChainStore) UpdateWithdrawInfo

func (cs *ChainStore) UpdateWithdrawInfo(programHash Uint160, amount Fixed64) error

type DataEntryPrefix

type DataEntryPrefix byte
const (
	// DATA
	DATA_BlockHash   DataEntryPrefix = 0x00
	DATA_Header      DataEntryPrefix = 0x01
	DATA_Transaction DataEntryPrefix = 0x02

	// INDEX
	IX_HeaderHashList DataEntryPrefix = 0x80
	IX_Unspent        DataEntryPrefix = 0x90
	IX_Unspent_UTXO   DataEntryPrefix = 0x91

	// ASSET
	ST_Info           DataEntryPrefix = 0xc0
	ST_QuantityIssued DataEntryPrefix = 0xc1
	ST_Contract       DataEntryPrefix = 0xc2
	ST_Storage        DataEntryPrefix = 0xc3
	ST_Account        DataEntryPrefix = 0xc4
	ST_Prepaid        DataEntryPrefix = 0xc7

	//SYSTEM
	SYS_CurrentBlock      DataEntryPrefix = 0x40
	SYS_CurrentBookKeeper DataEntryPrefix = 0x42

	//CONFIG
	CFG_Version DataEntryPrefix = 0xf0
)

type IIterator

type IIterator interface {
	Next() bool
	Prev() bool
	First() bool
	Last() bool
	Seek(key []byte) bool
	Key() []byte
	Value() []byte
	Release()
}

type IStore

type IStore interface {
	Put(key []byte, value []byte) error
	Get(key []byte) ([]byte, error)
	Delete(key []byte) error
	NewBatch() error
	BatchPut(key []byte, value []byte) error
	BatchDelete(key []byte) error
	BatchCommit() error
	Close() error
	NewIterator(prefix []byte) IIterator
}

func NewStore

func NewStore(file string) (IStore, error)

type Iterator

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

func (*Iterator) First

func (it *Iterator) First() bool

func (*Iterator) Key

func (it *Iterator) Key() []byte

func (*Iterator) Last

func (it *Iterator) Last() bool

func (*Iterator) Next

func (it *Iterator) Next() bool

func (*Iterator) Prev

func (it *Iterator) Prev() bool

func (*Iterator) Release

func (it *Iterator) Release()

func (*Iterator) Seek

func (it *Iterator) Seek(key []byte) bool

func (*Iterator) Value

func (it *Iterator) Value() []byte

type LevelDBStore

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

func NewLevelDBStore

func NewLevelDBStore(file string) (*LevelDBStore, error)

func (*LevelDBStore) BatchCommit

func (self *LevelDBStore) BatchCommit() error

func (*LevelDBStore) BatchDelete

func (self *LevelDBStore) BatchDelete(key []byte) error

func (*LevelDBStore) BatchPut

func (self *LevelDBStore) BatchPut(key []byte, value []byte) error

func (*LevelDBStore) Close

func (self *LevelDBStore) Close() error

func (*LevelDBStore) Delete

func (self *LevelDBStore) Delete(key []byte) error

func (*LevelDBStore) Get

func (self *LevelDBStore) Get(key []byte) ([]byte, error)

func (*LevelDBStore) NewBatch

func (self *LevelDBStore) NewBatch() error

func (*LevelDBStore) NewIterator

func (self *LevelDBStore) NewIterator(prefix []byte) IIterator

func (*LevelDBStore) Put

func (self *LevelDBStore) Put(key []byte, value []byte) error

type UTXOs

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

Jump to

Keyboard shortcuts

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