db

package
v0.0.0-...-c8e9c26 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2018 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenBestBlockHeaderKey

func GenBestBlockHeaderKey() *pool.ByteBuffer

func GenDataTransactionKey

func GenDataTransactionKey(hash common.Uint256) *pool.ByteBuffer

func GenGenesisBlockKey

func GenGenesisBlockKey() *pool.ByteBuffer

func GenTxMetaKey

func GenTxMetaKey(hash common.Uint256) *pool.ByteBuffer

Types

type BestBlock

type BestBlock struct {
	Height uint32
	Hash   common.Uint256
}

type BestStateProvider

type BestStateProvider interface {
	GetBestBlock() (BestBlock, error)
	GetBestHeader() (*types.Header, error)
}

type FixedBitMap

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

第一个为长度

func NewFixedBitMap

func NewFixedBitMap(nbits uint32) *FixedBitMap

创建指定初始化大小的bitSet

func (*FixedBitMap) Deserialize

func (self *FixedBitMap) Deserialize(r io.Reader) error

func (*FixedBitMap) Get

func (self *FixedBitMap) Get(bitIndex uint32) bool

获取指定位置的值

func (*FixedBitMap) IsFullSet

func (self *FixedBitMap) IsFullSet() bool

func (*FixedBitMap) Serialize

func (self *FixedBitMap) Serialize(w io.Writer) error

func (*FixedBitMap) Set

func (self *FixedBitMap) Set(bitIndex uint32)

把指定位置设为ture

func (*FixedBitMap) ToString

func (self *FixedBitMap) ToString() string

以二进制串的格式打印bitMap内容

func (*FixedBitMap) Unset

func (self *FixedBitMap) Unset(bitIndex uint32)

设置指定位置为false

type KeyPrefix

type KeyPrefix byte

DataEntryPrefix

const (
	//SYSTEM
	SYS_VERSION       KeyPrefix = 0
	SYS_GENESIS_BLOCK KeyPrefix = 1 // key: prefix, value: gensisBlock

	SYS_BEST_BLOCK        KeyPrefix = 2 // key : prefix, value: bestblock
	SYS_BEST_BLOCK_HEADER KeyPrefix = 3 // key: prefix, value: BlockHeader

	// DATA
	//DATA_Block KeyPrefix = iota
	//DATA_Header
	DATA_TRANSACTION KeyPrefix = 10 // key: prefix+txid, value: height + tx

	TX_META KeyPrefix = 20 // key: TX_META + txid, value: height + spend bits
)

type Store

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

func NewStore

func NewStore(path string) (*Store, error)

func (*Store) Close

func (self *Store) Close() error

func (*Store) ContainTransaction

func (self *Store) ContainTransaction(hash common.Uint256) bool

implement TransactionProvider interface

func (*Store) GetBestBlock

func (self *Store) GetBestBlock() (BestBlock, error)

func (*Store) GetBestHeader

func (self *Store) GetBestHeader() (*types.Header, error)

func (*Store) GetTransaction

func (self *Store) GetTransaction(hash common.Uint256) (*tx.Transaction, error)

func (*Store) GetTransactionBytes

func (self *Store) GetTransactionBytes(hash common.Uint256) ([]byte, error)

func (*Store) GetTransactionMeta

func (self *Store) GetTransactionMeta(hash common.Uint256) (TransactionMeta, error)

implement TransactionMetaProvider interface

func (*Store) PersistBlock

func (self *Store) PersistBlock(block *types.Block) error

type TransactionMeta

type TransactionMeta struct {
	BlockHeight uint32
	Spend       *FixedBitMap
}

func NewTransactionMeta

func NewTransactionMeta(height uint32, outputs uint32) TransactionMeta

func (*TransactionMeta) DenoteSpent

func (self *TransactionMeta) DenoteSpent(index uint32)

func (*TransactionMeta) DenoteUnspent

func (self *TransactionMeta) DenoteUnspent(index uint32)

func (*TransactionMeta) Deserialize

func (self *TransactionMeta) Deserialize(r io.Reader) error

func (*TransactionMeta) Height

func (self *TransactionMeta) Height() uint32

func (*TransactionMeta) IsFullSpent

func (self *TransactionMeta) IsFullSpent() bool

func (*TransactionMeta) IsSpent

func (self *TransactionMeta) IsSpent(idx uint32) bool

func (*TransactionMeta) Serialize

func (self *TransactionMeta) Serialize(w io.Writer) error

type TransactionMetaProvider

type TransactionMetaProvider interface {
	BestStateProvider
	GetTransactionMeta(hash common.Uint256) (TransactionMeta, error)
}

type TransactionProvider

type TransactionProvider interface {
	BestStateProvider
	ContainTransaction(hash common.Uint256) bool
	GetTransactionBytes(hash common.Uint256) ([]byte, error)
	GetTransaction(hash common.Uint256) (*types.Transaction, error)
	PersistBlock(block *types.Block) error
}

Jump to

Keyboard shortcuts

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