db

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxExpandedSize      = 64
	MaxMatchedTx         = 50000
	DB_PARA_READ_THREADS = 8
)
View Source
const (
	Redeemable   = byte(0)
	LostAndFound = byte(1)
	Redeeming    = byte(2)
	Burn         = byte(9)
	Addr2Utxo    = byte(10)
	UTXO         = byte(255)
)

Variables

View Source
var (
	ErrQueryConditionExpandedTooLarge = errors.New("query condition expanded too large")
	ErrTooManyPotentialResults        = errors.New("too many potential results")
)

Functions

func AppendAtKey

func AppendAtKey(m map[uint64][]uint32, key uint64, value uint32)

append value at a slice at 'key'. If the slice does not exist, create it.

func DefaultExtractNotificationFromTxFn

func DefaultExtractNotificationFromTxFn(tx types.Tx, notiMap map[string]int64)

To-address of TX From-address of SEP20-Transfer To-address of SEP20-Transfer

func EncodeToHex

func EncodeToHex(b []byte) string

func GetId56

func GetId56(height uint32, i int) uint64

func GetRealOffset

func GetRealOffset(offset, size int64) int64

offset40 can represent 32TB range, but a hpfile's virual size can be larger than it. calculate a real offset from offset40 which pointing to a valid position in hpfile.

func Padding32

func Padding32(length int) (n int)

make sure (length+n)%32 == 0

func Sum48

func Sum48(seed [8]byte, key []byte) uint64

returns the short hash of the key

Types

type BlockHeightAndHash

type BlockHeightAndHash struct {
	Height    uint32
	BlockHash [32]byte
}

type DB

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

func CreateEmptyDB

func CreateEmptyDB(path string, seed [8]byte, logger log.Logger) *DB

func NewDB

func NewDB(path string, logger log.Logger) *DB

func (*DB) AddBlock

func (d *DB) AddBlock(blk *types.Block, pruneTillHeight int64, txid2sigMap map[[32]byte][65]byte)

Add a new block for indexing, and prune the index information for blocks before pruneTillHeight The ownership of 'blk' will be transferred to DB and cannot be changed by out world!

func (*DB) BasicQueryLogs

func (d *DB) BasicQueryLogs(addr *[20]byte, topics [][32]byte,
	startHeight, endHeight uint32, fn func([]byte) bool) error

Given 0~1 addr and 0~4 topics, feed the possibly-matching transactions to 'fn'; the return value of 'fn' indicates whether it wants more data.

func (*DB) Close

func (d *DB) Close()

func (*DB) GetAllUtxoIds

func (d *DB) GetAllUtxoIds() [][36]byte

func (*DB) GetBlockByHash

func (d *DB) GetBlockByHash(hash [32]byte, collectResult func([]byte) bool)

given a block's hash, feed possibly-correct serialized information to collectResult; if collectResult confirms the information is correct by returning true, this function stops loop.

func (*DB) GetBlockByHeight

func (d *DB) GetBlockByHeight(height int64) []byte

given a block's height, return serialized information.

func (*DB) GetBlockHashByHeight

func (d *DB) GetBlockHashByHeight(height int64) (res [32]byte)

given a recent block's height, return its blockhash

func (*DB) GetLatestHeight

func (d *DB) GetLatestHeight() int64

func (*DB) GetLostAndFoundUtxoIds

func (d *DB) GetLostAndFoundUtxoIds() [][36]byte

func (*DB) GetRedeemableUtxoIds

func (d *DB) GetRedeemableUtxoIds() [][36]byte

func (*DB) GetRedeemableUtxoIdsByCovenantAddr

func (d *DB) GetRedeemableUtxoIdsByCovenantAddr(covenantAddr [20]byte) [][36]byte

func (*DB) GetRedeemingUtxoIds

func (d *DB) GetRedeemingUtxoIds() [][36]byte

func (*DB) GetTxByHash

func (d *DB) GetTxByHash(hash [32]byte, collectResult func([]byte) bool)

given a block's hash, feed possibly-correct serialized information to collectResult; if collectResult confirms the information is correct by returning true, this function stops loop.

func (*DB) GetTxByHeightAndIndex

func (d *DB) GetTxByHeightAndIndex(height int64, index int) []byte

given a transaction's height+index, return serialized information.

func (*DB) GetTxListByHeight

func (d *DB) GetTxListByHeight(height int64) [][]byte

func (*DB) GetTxListByHeightWithRange

func (d *DB) GetTxListByHeightWithRange(height int64, start, end int) [][]byte

given a blocks's height, return serialized information of its transactions.

func (*DB) GetUtxoIdsByCovenantAddr

func (d *DB) GetUtxoIdsByCovenantAddr(covenantAddr [20]byte) [][36]byte

func (*DB) GetUtxoInfos

func (d *DB) GetUtxoInfos() (infos [][36 + 1 + 20]byte)

func (*DB) QueryLogs

func (d *DB) QueryLogs(addrOrList [][20]byte, topicsOrList [][][32]byte,
	startHeight, endHeight uint32, fn func([]byte) bool) error

func (*DB) QueryNotificationCounter

func (d *DB) QueryNotificationCounter(key []byte) int64

func (*DB) QueryTxByDst

func (d *DB) QueryTxByDst(addr [20]byte, startHeight, endHeight uint32, fn func([]byte) bool) error

func (*DB) QueryTxBySrc

func (d *DB) QueryTxBySrc(addr [20]byte, startHeight, endHeight uint32, fn func([]byte) bool) error

func (*DB) QueryTxBySrcOrDst

func (d *DB) QueryTxBySrcOrDst(addr [20]byte, startHeight, endHeight uint32, fn func([]byte) bool) error

func (*DB) SetDisableComplexIndex

func (d *DB) SetDisableComplexIndex(b bool)

func (*DB) SetExtractNotificationFn

func (d *DB) SetExtractNotificationFn(fn types.ExtractNotificationFromTxFn)

func (*DB) SetMaxEntryCount

func (d *DB) SetMaxEntryCount(c int)

func (*DB) SetOpListsForCcUtxo

func (d *DB) SetOpListsForCcUtxo(opListsForCcUtxo types.OpListsForCcUtxo)

type HPFile

type HPFile = datatree.HPFile

type LiteDB

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

func NewLiteDB

func NewLiteDB(path string) (d *LiteDB)

func (*LiteDB) AddBlock

func (d *LiteDB) AddBlock(blk *types.Block, pruneTillHeight int64, txid2sigMap map[[32]byte][65]byte)

func (*LiteDB) BasicQueryLogs

func (d *LiteDB) BasicQueryLogs(addr *[20]byte, topics [][32]byte, startHeight, endHeight uint32, fn func([]byte) bool) error

func (*LiteDB) Close

func (d *LiteDB) Close()

func (*LiteDB) GetAllUtxoIds

func (d *LiteDB) GetAllUtxoIds() [][36]byte

func (*LiteDB) GetBlockByHash

func (d *LiteDB) GetBlockByHash(hash [32]byte, collectResult func([]byte) bool)

func (*LiteDB) GetBlockByHeight

func (d *LiteDB) GetBlockByHeight(height int64) []byte

func (*LiteDB) GetBlockHashByHeight

func (d *LiteDB) GetBlockHashByHeight(height int64) (res [32]byte)

func (*LiteDB) GetLatestHeight

func (d *LiteDB) GetLatestHeight() (latestHeight int64)

func (*LiteDB) GetLostAndFoundUtxoIds

func (d *LiteDB) GetLostAndFoundUtxoIds() [][36]byte

func (*LiteDB) GetRedeemableUtxoIds

func (d *LiteDB) GetRedeemableUtxoIds() [][36]byte

func (*LiteDB) GetRedeemableUtxoIdsByCovenantAddr

func (d *LiteDB) GetRedeemableUtxoIdsByCovenantAddr(covenantAddr [20]byte) [][36]byte

func (*LiteDB) GetRedeemingUtxoIds

func (d *LiteDB) GetRedeemingUtxoIds() [][36]byte

func (*LiteDB) GetTxByHash

func (d *LiteDB) GetTxByHash(hash [32]byte, collectResult func([]byte) bool)

func (*LiteDB) GetTxByHeightAndIndex

func (d *LiteDB) GetTxByHeightAndIndex(height int64, index int) []byte

func (*LiteDB) GetTxListByHeight

func (d *LiteDB) GetTxListByHeight(height int64) [][]byte

func (*LiteDB) GetTxListByHeightWithRange

func (d *LiteDB) GetTxListByHeightWithRange(height int64, start, end int) [][]byte

func (*LiteDB) GetTxSigByHash

func (d *LiteDB) GetTxSigByHash(hash [32]byte) (res [65]byte)

func (*LiteDB) GetUtxoIdsByCovenantAddr

func (d *LiteDB) GetUtxoIdsByCovenantAddr(covenantAddr [20]byte) [][36]byte

func (*LiteDB) GetUtxoInfos

func (d *LiteDB) GetUtxoInfos() (infos [][36 + 1 + 20]byte)

func (*LiteDB) QueryLogs

func (d *LiteDB) QueryLogs(addrOrList [][20]byte, topicsOrList [][][32]byte, startHeight, endHeight uint32, fn func([]byte) bool) error

func (*LiteDB) QueryNotificationCounter

func (d *LiteDB) QueryNotificationCounter(key []byte) int64

func (*LiteDB) QueryTxByDst

func (d *LiteDB) QueryTxByDst(addr [20]byte, startHeight, endHeight uint32, fn func([]byte) bool) error

func (*LiteDB) QueryTxBySrc

func (d *LiteDB) QueryTxBySrc(addr [20]byte, startHeight, endHeight uint32, fn func([]byte) bool) error

func (*LiteDB) QueryTxBySrcOrDst

func (d *LiteDB) QueryTxBySrcOrDst(addr [20]byte, startHeight, endHeight uint32, fn func([]byte) bool) error

func (*LiteDB) SetDisableComplexIndex

func (d *LiteDB) SetDisableComplexIndex(b bool)

func (*LiteDB) SetExtractNotificationFn

func (d *LiteDB) SetExtractNotificationFn(fn types.ExtractNotificationFromTxFn)

func (*LiteDB) SetMaxEntryCount

func (d *LiteDB) SetMaxEntryCount(c int)

func (*LiteDB) SetOpListsForCcUtxo

func (d *LiteDB) SetOpListsForCcUtxo(opListsForCcUtxo types.OpListsForCcUtxo)

type MockDB

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

func (*MockDB) AddBlock

func (d *MockDB) AddBlock(blk *types.Block, pruneTillHeight int64, txid2sigMap map[[32]byte][65]byte)

func (*MockDB) BasicQueryLogs

func (d *MockDB) BasicQueryLogs(addr *[20]byte, topics [][32]byte, startHeight, endHeight uint32, fn func([]byte) bool) error

func (*MockDB) Close

func (d *MockDB) Close()

func (*MockDB) GetAllUtxoIds

func (d *MockDB) GetAllUtxoIds() [][36]byte

func (*MockDB) GetBlockByHash

func (d *MockDB) GetBlockByHash(hash [32]byte, collectResult func([]byte) bool)

func (*MockDB) GetBlockByHeight

func (d *MockDB) GetBlockByHeight(height int64) []byte

func (*MockDB) GetBlockHashByHeight

func (d *MockDB) GetBlockHashByHeight(height int64) (res [32]byte)

func (*MockDB) GetLatestHeight

func (d *MockDB) GetLatestHeight() int64

func (*MockDB) GetLostAndFoundUtxoIds

func (d *MockDB) GetLostAndFoundUtxoIds() [][36]byte

func (*MockDB) GetRedeemableUtxoIds

func (d *MockDB) GetRedeemableUtxoIds() [][36]byte

func (*MockDB) GetRedeemableUtxoIdsByCovenantAddr

func (d *MockDB) GetRedeemableUtxoIdsByCovenantAddr(covenantAddr [20]byte) [][36]byte

func (*MockDB) GetRedeemingUtxoIds

func (d *MockDB) GetRedeemingUtxoIds() [][36]byte

func (*MockDB) GetTxByHash

func (d *MockDB) GetTxByHash(hash [32]byte, collectResult func([]byte) bool)

func (*MockDB) GetTxByHeightAndIndex

func (d *MockDB) GetTxByHeightAndIndex(height int64, index int) []byte

func (*MockDB) GetTxListByHeight

func (d *MockDB) GetTxListByHeight(height int64) (res [][]byte)

func (*MockDB) GetTxListByHeightWithRange

func (d *MockDB) GetTxListByHeightWithRange(height int64, start, end int) [][]byte

func (*MockDB) GetUtxoIdsByCovenantAddr

func (d *MockDB) GetUtxoIdsByCovenantAddr(covenantAddr [20]byte) [][36]byte

func (*MockDB) GetUtxoInfos

func (d *MockDB) GetUtxoInfos() (infos [][57]byte)

func (*MockDB) QueryLogs

func (d *MockDB) QueryLogs(addrOrList [][20]byte, topicsOrList [][][32]byte, startHeight, endHeight uint32, fn func([]byte) bool) error

func (*MockDB) QueryNotificationCounter

func (d *MockDB) QueryNotificationCounter(key []byte) (counter int64)

func (*MockDB) QueryTxByDst

func (d *MockDB) QueryTxByDst(addr [20]byte, startHeight, endHeight uint32, fn func([]byte) bool) error

func (*MockDB) QueryTxBySrc

func (d *MockDB) QueryTxBySrc(addr [20]byte, startHeight, endHeight uint32, fn func([]byte) bool) error

func (*MockDB) QueryTxBySrcOrDst

func (d *MockDB) QueryTxBySrcOrDst(addr [20]byte, startHeight, endHeight uint32, fn func([]byte) bool) error

func (*MockDB) SetDisableComplexIndex

func (d *MockDB) SetDisableComplexIndex(b bool)

func (*MockDB) SetExtractNotificationFn

func (d *MockDB) SetExtractNotificationFn(fn types.ExtractNotificationFromTxFn)

func (*MockDB) SetMaxEntryCount

func (d *MockDB) SetMaxEntryCount(c int)

func (*MockDB) SetOpListsForCcUtxo

func (d *MockDB) SetOpListsForCcUtxo(opListsForCcUtxo types.OpListsForCcUtxo)

type RocksDB

type RocksDB = indextree.RocksDB

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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