db

package
v0.8.4-alpha Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderHashListCount = 2000
	CleanCacheThreshold = 2
)
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) error

func (*ChainStore) BlockInCache

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

func (*ChainStore) CancelKeyExpirationAtBlock

func (cs *ChainStore) CancelKeyExpirationAtBlock(height uint32, key []byte) error

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) DeleteName

func (cs *ChainStore) DeleteName(registrant []byte) error

func (*ChainStore) ExpireKeyAtBlock

func (cs *ChainStore) ExpireKeyAtBlock(height uint32, key []byte) 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) GetBlockByHeight

func (cs *ChainStore) GetBlockByHeight(height uint32) (*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) 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) GetExpiredKeys

func (cs *ChainStore) GetExpiredKeys(height uint32) [][]byte

func (*ChainStore) GetFirstAvailableTopicBucket

func (cs *ChainStore) GetFirstAvailableTopicBucket(topic string) int

func (*ChainStore) GetHeader

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

func (*ChainStore) GetHeaderByHeight

func (cs *ChainStore) GetHeaderByHeight(height uint32) (*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) GetName

func (cs *ChainStore) GetName(registrant []byte) (*string, 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) GetRegistrant

func (cs *ChainStore) GetRegistrant(name string) ([]byte, error)

func (*ChainStore) GetStorage

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

func (*ChainStore) GetSubscribers

func (cs *ChainStore) GetSubscribers(topic string, bucket uint32) map[string]string

func (*ChainStore) GetSubscribersCount

func (cs *ChainStore) GetSubscribersCount(topic string, bucket uint32) int

func (*ChainStore) GetTopicBucketsCount

func (cs *ChainStore) GetTopicBucketsCount(topic string) uint32

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) (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) IsSubscribed

func (cs *ChainStore) IsSubscribed(subscriber []byte, identifier string, topic string, bucket uint32) (bool, error)

func (*ChainStore) IsTxHashDuplicate

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

func (*ChainStore) RemoveExpiredKey

func (cs *ChainStore) RemoveExpiredKey(key []byte) error

func (*ChainStore) Rollback

func (cs *ChainStore) Rollback(b *ledger.Block) error

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) SaveName

func (cs *ChainStore) SaveName(registrant []byte, name string) error

func (*ChainStore) SaveTransaction

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

func (*ChainStore) Subscribe

func (cs *ChainStore) Subscribe(subscriber []byte, identifier string, topic string, bucket uint32, duration uint32, meta string, height uint32) error

func (*ChainStore) Unsubscribe

func (cs *ChainStore) Unsubscribe(subscriber []byte, identifier string, topic string, bucket uint32, duration uint32, 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_Prepaid        DataEntryPrefix = 0xc7

	//SYSTEM
	SYS_CurrentBlock DataEntryPrefix = 0x40
	SYS_ExpireKey    DataEntryPrefix = 0x41

	// NAME
	NS_Registrant DataEntryPrefix = 0x50
	NS_Name       DataEntryPrefix = 0x51

	// PUBSUB
	PS_Topic DataEntryPrefix = 0x60

	//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)
	Has(key []byte) (bool, 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) Has

func (self *LevelDBStore) Has(key []byte) (bool, 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