modb

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: Apache-2.0 Imports: 13 Imported by: 4

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 added in v0.1.1

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 added in v0.3.3

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 added in v0.1.1

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

type HPFile

type HPFile = datatree.HPFile

type LiteDB added in v0.1.3

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

func NewLiteDB added in v0.1.3

func NewLiteDB(path string) (db *LiteDB)

func (*LiteDB) AddBlock added in v0.1.3

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

func (*LiteDB) BasicQueryLogs added in v0.1.3

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

func (*LiteDB) Close added in v0.1.3

func (db *LiteDB) Close()

func (*LiteDB) GetAllUtxoIds added in v0.4.4

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

func (*LiteDB) GetBlockByHash added in v0.1.3

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

func (*LiteDB) GetBlockByHeight added in v0.1.3

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

func (*LiteDB) GetBlockHashByHeight added in v0.1.3

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

func (*LiteDB) GetLatestHeight added in v0.1.3

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

func (*LiteDB) GetLostAndFoundUtxoIds added in v0.4.4

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

func (*LiteDB) GetRedeemableUtxoIds added in v0.4.4

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

func (*LiteDB) GetRedeemableUtxoIdsByCovenantAddr added in v0.4.4

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

func (*LiteDB) GetRedeemingUtxoIds added in v0.4.4

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

func (*LiteDB) GetTxByHash added in v0.1.3

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

func (*LiteDB) GetTxByHeightAndIndex added in v0.1.3

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

func (*LiteDB) GetTxListByHeight added in v0.1.3

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

func (*LiteDB) GetTxListByHeightWithRange added in v0.2.0

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

func (*LiteDB) GetTxSigByHash added in v0.3.3

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

func (*LiteDB) GetUtxoIdsByCovenantAddr added in v0.4.4

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

func (*LiteDB) GetUtxoInfos added in v0.4.4

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

func (*LiteDB) QueryLogs added in v0.1.3

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

func (*LiteDB) QueryNotificationCounter added in v0.1.3

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

func (*LiteDB) QueryTxByDst added in v0.1.3

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

func (*LiteDB) QueryTxBySrc added in v0.1.3

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

func (*LiteDB) QueryTxBySrcOrDst added in v0.1.3

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

func (*LiteDB) SetDisableComplexIndex added in v0.1.3

func (db *LiteDB) SetDisableComplexIndex(b bool)

func (*LiteDB) SetExtractNotificationFn added in v0.1.3

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

func (*LiteDB) SetMaxEntryCount added in v0.1.3

func (db *LiteDB) SetMaxEntryCount(c int)

func (*LiteDB) SetOpListsForCcUtxo added in v0.4.4

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

type MoDB

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

func CreateEmptyMoDB

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

func NewMoDB

func NewMoDB(path string, logger log.Logger) *MoDB

func (*MoDB) AddBlock

func (db *MoDB) 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 MoDB and cannot be changed by out world!

func (*MoDB) BasicQueryLogs

func (db *MoDB) 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 (*MoDB) Close

func (db *MoDB) Close()

func (*MoDB) GetAllUtxoIds added in v0.4.4

func (db *MoDB) GetAllUtxoIds() [][36]byte

func (*MoDB) GetBlockByHash

func (db *MoDB) 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 (*MoDB) GetBlockByHeight

func (db *MoDB) GetBlockByHeight(height int64) []byte

given a block's height, return serialized information.

func (*MoDB) GetBlockHashByHeight added in v0.1.1

func (db *MoDB) GetBlockHashByHeight(height int64) (res [32]byte)

given a recent block's height, return its blockhash

func (*MoDB) GetLatestHeight

func (db *MoDB) GetLatestHeight() int64

func (*MoDB) GetLostAndFoundUtxoIds added in v0.4.4

func (db *MoDB) GetLostAndFoundUtxoIds() [][36]byte

func (*MoDB) GetRedeemableUtxoIds added in v0.4.4

func (db *MoDB) GetRedeemableUtxoIds() [][36]byte

func (*MoDB) GetRedeemableUtxoIdsByCovenantAddr added in v0.4.4

func (db *MoDB) GetRedeemableUtxoIdsByCovenantAddr(covenantAddr [20]byte) [][36]byte

func (*MoDB) GetRedeemingUtxoIds added in v0.4.4

func (db *MoDB) GetRedeemingUtxoIds() [][36]byte

func (*MoDB) GetTxByHash

func (db *MoDB) 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 (*MoDB) GetTxByHeightAndIndex

func (db *MoDB) GetTxByHeightAndIndex(height int64, index int) []byte

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

func (*MoDB) GetTxListByHeight

func (db *MoDB) GetTxListByHeight(height int64) [][]byte

func (*MoDB) GetTxListByHeightWithRange added in v0.2.0

func (db *MoDB) GetTxListByHeightWithRange(height int64, start, end int) [][]byte

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

func (*MoDB) GetUtxoIdsByCovenantAddr added in v0.4.4

func (db *MoDB) GetUtxoIdsByCovenantAddr(covenantAddr [20]byte) [][36]byte

func (*MoDB) GetUtxoInfos added in v0.4.4

func (db *MoDB) GetUtxoInfos() (infos [][36 + 1 + 20]byte)

func (*MoDB) QueryLogs

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

func (*MoDB) QueryNotificationCounter added in v0.1.1

func (db *MoDB) QueryNotificationCounter(key []byte) int64

func (*MoDB) QueryTxByDst

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

func (*MoDB) QueryTxBySrc

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

func (*MoDB) QueryTxBySrcOrDst

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

func (*MoDB) SetDisableComplexIndex added in v0.1.1

func (db *MoDB) SetDisableComplexIndex(b bool)

func (*MoDB) SetExtractNotificationFn added in v0.1.1

func (db *MoDB) SetExtractNotificationFn(fn types.ExtractNotificationFromTxFn)

func (*MoDB) SetMaxEntryCount

func (db *MoDB) SetMaxEntryCount(c int)

func (*MoDB) SetOpListsForCcUtxo added in v0.4.3

func (db *MoDB) SetOpListsForCcUtxo(opListsForCcUtxo types.OpListsForCcUtxo)

type MockMoDB

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

func (*MockMoDB) AddBlock

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

func (*MockMoDB) BasicQueryLogs

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

func (*MockMoDB) Close

func (db *MockMoDB) Close()

func (*MockMoDB) GetAllUtxoIds added in v0.4.4

func (db *MockMoDB) GetAllUtxoIds() [][36]byte

func (*MockMoDB) GetBlockByHash

func (db *MockMoDB) GetBlockByHash(hash [32]byte, collectResult func([]byte) bool)

func (*MockMoDB) GetBlockByHeight

func (db *MockMoDB) GetBlockByHeight(height int64) []byte

func (*MockMoDB) GetBlockHashByHeight added in v0.1.1

func (db *MockMoDB) GetBlockHashByHeight(height int64) (res [32]byte)

func (*MockMoDB) GetLatestHeight

func (db *MockMoDB) GetLatestHeight() int64

func (*MockMoDB) GetLostAndFoundUtxoIds added in v0.4.4

func (db *MockMoDB) GetLostAndFoundUtxoIds() [][36]byte

func (*MockMoDB) GetRedeemableUtxoIds added in v0.4.4

func (db *MockMoDB) GetRedeemableUtxoIds() [][36]byte

func (*MockMoDB) GetRedeemableUtxoIdsByCovenantAddr added in v0.4.4

func (db *MockMoDB) GetRedeemableUtxoIdsByCovenantAddr(covenantAddr [20]byte) [][36]byte

func (*MockMoDB) GetRedeemingUtxoIds added in v0.4.4

func (db *MockMoDB) GetRedeemingUtxoIds() [][36]byte

func (*MockMoDB) GetTxByHash

func (db *MockMoDB) GetTxByHash(hash [32]byte, collectResult func([]byte) bool)

func (*MockMoDB) GetTxByHeightAndIndex

func (db *MockMoDB) GetTxByHeightAndIndex(height int64, index int) []byte

func (*MockMoDB) GetTxListByHeight

func (db *MockMoDB) GetTxListByHeight(height int64) (res [][]byte)

func (*MockMoDB) GetTxListByHeightWithRange added in v0.2.0

func (db *MockMoDB) GetTxListByHeightWithRange(height int64, start, end int) [][]byte

func (*MockMoDB) GetUtxoIdsByCovenantAddr added in v0.4.4

func (db *MockMoDB) GetUtxoIdsByCovenantAddr(covenantAddr [20]byte) [][36]byte

func (*MockMoDB) GetUtxoInfos added in v0.4.4

func (db *MockMoDB) GetUtxoInfos() (infos [][57]byte)

func (*MockMoDB) QueryLogs

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

func (*MockMoDB) QueryNotificationCounter added in v0.1.1

func (db *MockMoDB) QueryNotificationCounter(key []byte) (counter int64)

func (*MockMoDB) QueryTxByDst

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

func (*MockMoDB) QueryTxBySrc

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

func (*MockMoDB) QueryTxBySrcOrDst

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

func (*MockMoDB) SetDisableComplexIndex added in v0.1.1

func (db *MockMoDB) SetDisableComplexIndex(b bool)

func (*MockMoDB) SetExtractNotificationFn added in v0.1.1

func (db *MockMoDB) SetExtractNotificationFn(fn types.ExtractNotificationFromTxFn)

func (*MockMoDB) SetMaxEntryCount

func (db *MockMoDB) SetMaxEntryCount(c int)

func (*MockMoDB) SetOpListsForCcUtxo added in v0.4.4

func (db *MockMoDB) 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