common

package
v1.9.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2020 License: LGPL-3.0 Imports: 3 Imported by: 62

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type DataEntryPrefix

type DataEntryPrefix byte

DataEntryPrefix

const (
	// DATA
	DATA_BLOCK             DataEntryPrefix = 0x00 //Block height => block hash key prefix
	DATA_HEADER                            = 0x01 //Block hash => block hash key prefix
	DATA_TRANSACTION                       = 0x02 //Transction hash = > transaction key prefix
	DATA_STATE_MERKLE_ROOT                 = 0x21 // block height => write set hash + state merkle root

	// Transaction
	ST_BOOKKEEPER DataEntryPrefix = 0x03 //BookKeeper state key prefix
	ST_CONTRACT   DataEntryPrefix = 0x04 //Smart contract state key prefix
	ST_STORAGE    DataEntryPrefix = 0x05 //Smart contract storage key prefix
	ST_VALIDATOR  DataEntryPrefix = 0x07 //no use
	ST_VOTE       DataEntryPrefix = 0x08 //Vote state key prefix

	IX_HEADER_HASH_LIST DataEntryPrefix = 0x09 //Block height => block hash key prefix

	//SYSTEM
	SYS_CURRENT_BLOCK        DataEntryPrefix = 0x10 //Current block key prefix
	SYS_VERSION              DataEntryPrefix = 0x11 //Store version key prefix
	SYS_CURRENT_CROSS_STATES DataEntryPrefix = 0x12 //Block cross states
	SYS_BLOCK_MERKLE_TREE    DataEntryPrefix = 0x13 // Block merkle tree root key prefix
	SYS_STATE_MERKLE_TREE    DataEntryPrefix = 0x20 // state merkle tree root key prefix
	SYS_CROSS_CHAIN_MSG      DataEntryPrefix = 0x22 // state merkle tree root key prefix

	EVENT_NOTIFY DataEntryPrefix = 0x14 //Event notify key prefix
)

type EventStore

type EventStore interface {
	//SaveEventNotifyByTx save event notify gen by smart contract execution
	SaveEventNotifyByTx(txHash common.Uint256, notify *event.ExecuteNotify) error
	//Save transaction hashes which have event notify gen
	SaveEventNotifyByBlock(height uint32, txHashs []common.Uint256)
	//GetEventNotifyByTx return event notify by transaction hash
	GetEventNotifyByTx(txHash common.Uint256) (*event.ExecuteNotify, error)
	//Commit event notify to store
	CommitTo() error
}

EventStore save event notify

type PersistStore

type PersistStore interface {
	Put(key []byte, value []byte) error      //Put the key-value pair to store
	Get(key []byte) ([]byte, error)          //Get the value if key in store
	Has(key []byte) (bool, error)            //Whether the key is exist in store
	Delete(key []byte) error                 //Delete the key in store
	NewBatch()                               //Start commit batch
	BatchPut(key []byte, value []byte)       //Put a key-value pair to batch
	BatchDelete(key []byte)                  //Delete the key in batch
	BatchCommit() error                      //Commit batch to store
	Close() error                            //Close store
	NewIterator(prefix []byte) StoreIterator //Return the iterator of store
}

PersistStore of ledger

type StoreIterator

type StoreIterator interface {
	Next() bool //Next item. If item available return true, otherwise return false
	//Prev() bool           //previous item. If item available return true, otherwise return false
	First() bool //First item. If item available return true, otherwise return false
	//Last() bool           //Last item. If item available return true, otherwise return false
	//Seek(key []byte) bool //Seek key. If item available return true, otherwise return false
	Key() []byte   //Return the current item key
	Value() []byte //Return the current item value
	Release()      //Close iterator
	Error() error  // Error returns any accumulated error.
}

Store iterator for iterate store

Jump to

Keyboard shortcuts

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