types

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: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FROM_ADDR_KEY       byte = 9
	TO_ADDR_KEY         byte = 10
	TRANS_FROM_ADDR_KEY byte = 11
	TRANS_TO_ADDR_KEY   byte = 12
)

Variables

View Source
var TransferEvent = [32]byte{
	0xdd, 0xf2, 0x52, 0xad, 0x1b, 0xe2, 0xc8, 0x9b,
	0x69, 0xc2, 0xb0, 0x68, 0xfc, 0x37, 0x8d, 0xaa,
	0x95, 0x2b, 0xa7, 0xf1, 0x63, 0xc4, 0xa1, 0x16,
	0x28, 0xf5, 0x5a, 0x4d, 0xf5, 0x23, 0xb3, 0xef,
}

Functions

This section is empty.

Types

type Block

type Block struct {
	Height    int64    `msg:"ht"`
	BlockHash [32]byte `msg:"bh"`
	BlockInfo []byte   `msg:"bi"` // the pre-serialized payload
	TxList    []Tx     `msg:"tx"`
}

To index a block, we need its height and hash

func (Block) Clone

func (blk Block) Clone() (res Block)

func (*Block) DecodeMsg

func (z *Block) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Block) EncodeMsg

func (z *Block) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Block) MarshalMsg

func (z *Block) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Block) Msgsize

func (z *Block) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Block) UnmarshalMsg

func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type BlockIndex

type BlockIndex struct {
	Height       uint32   `msg:"ht"`
	BlockHash    [32]byte `msg:"bH"`
	BlockHash48  uint64   `msg:"bh"`
	TxHash48List []uint64 `msg:"thl"`
	BeginOffset  int64    `msg:"bo"`
	TxPosList    []int64  `msg:"tpl"`

	SrcHashes   []uint64   `msg:"sh"`
	SrcPosLists [][]uint32 `msg:"sp"`
	DstHashes   []uint64   `msg:"dh"`
	DstPosLists [][]uint32 `msg:"dp"`

	AddrHashes    []uint64   `msg:"ah"`
	AddrPosLists  [][]uint32 `msg:"ap"`
	TopicHashes   []uint64   `msg:"th"`
	TopicPosLists [][]uint32 `msg:"tp"`
}

the index information for a block. we use it to build in-memory index for a block, and erase the index when this block is considered too old.

func (*BlockIndex) DecodeMsg

func (z *BlockIndex) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*BlockIndex) EncodeMsg

func (z *BlockIndex) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*BlockIndex) MarshalMsg

func (z *BlockIndex) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*BlockIndex) Msgsize

func (z *BlockIndex) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*BlockIndex) UnmarshalMsg

func (z *BlockIndex) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type ConvertedOp

type ConvertedOp struct {
	PrevUtxoId      [36]byte
	UtxoId          [36]byte
	OldCovenantAddr [20]byte
	NewCovenantAddr [20]byte
}

type DB

type DB interface {
	Close()
	SetExtractNotificationFn(fn ExtractNotificationFromTxFn)
	SetDisableComplexIndex(b bool)
	GetLatestHeight() int64
	AddBlock(blk *Block, pruneTillHeight int64, txid2sigMap map[[32]byte][65]byte)
	GetBlockHashByHeight(height int64) [32]byte
	GetBlockByHeight(height int64) []byte
	GetTxByHeightAndIndex(height int64, index int) []byte
	GetTxListByHeight(height int64) [][]byte
	GetTxListByHeightWithRange(height int64, start, end int) [][]byte
	GetBlockByHash(hash [32]byte, collectResult func([]byte) bool)
	GetTxByHash(hash [32]byte, collectResult func([]byte) bool)
	BasicQueryLogs(addr *[20]byte, topics [][32]byte, startHeight, endHeight uint32, fn func([]byte) bool) error
	QueryLogs(addrOrList [][20]byte, topicsOrList [][][32]byte, startHeight, endHeight uint32, fn func([]byte) bool) error
	QueryTxBySrc(addr [20]byte, startHeight, endHeight uint32, fn func([]byte) bool) error
	QueryTxByDst(addr [20]byte, startHeight, endHeight uint32, fn func([]byte) bool) error
	QueryTxBySrcOrDst(addr [20]byte, startHeight, endHeight uint32, fn func([]byte) bool) error
	QueryNotificationCounter(key []byte) int64

	SetOpListsForCcUtxo(opListsForCcUtxo OpListsForCcUtxo)
	GetUtxoInfos() (infos [][36 + 1 + 20]byte)
	GetAllUtxoIds() [][36]byte
	GetRedeemableUtxoIds() [][36]byte
	GetLostAndFoundUtxoIds() [][36]byte
	GetRedeemingUtxoIds() [][36]byte
	GetUtxoIdsByCovenantAddr(covenantAddr [20]byte) [][36]byte
	GetRedeemableUtxoIdsByCovenantAddr(covenantAddr [20]byte) [][36]byte

	// This function's parameter limits these functions' returned entry count: BasicQueryLogs, QueryLogs, QueryTxBySrc, QueryTxByDst, QueryTxBySrcOrDst
	SetMaxEntryCount(c int)
}

the interface provided by DB

type DeletedOp

type DeletedOp struct {
	UtxoId       [36]byte
	CovenantAddr [20]byte
	SourceType   byte
}

type ExtendedBlock

type ExtendedBlock struct {
	Block
	Txid2sigMap map[string][65]byte `msg:"t2s"`
	UpdateOfADS map[string]string   `msg:"ua"`
}

Extend the 'Block' type to include txid2sigMap and ads's update data

func (*ExtendedBlock) DecodeMsg

func (z *ExtendedBlock) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*ExtendedBlock) EncodeMsg

func (z *ExtendedBlock) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*ExtendedBlock) MarshalMsg

func (z *ExtendedBlock) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*ExtendedBlock) Msgsize

func (z *ExtendedBlock) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*ExtendedBlock) UnmarshalMsg

func (z *ExtendedBlock) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type ExtractNotificationFromTxFn

type ExtractNotificationFromTxFn func(tx Tx, notiMap map[string]int64)

type IndexEntry

type IndexEntry struct {
	Hash48  uint64   `msg:"h"`
	PosList []uint32 `msg:"l"`
}

an entry for address index or topic index

func (*IndexEntry) DecodeMsg

func (z *IndexEntry) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*IndexEntry) EncodeMsg

func (z *IndexEntry) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*IndexEntry) MarshalMsg

func (z *IndexEntry) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*IndexEntry) Msgsize

func (z *IndexEntry) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*IndexEntry) UnmarshalMsg

func (z *IndexEntry) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Log

type Log struct {
	Address [20]byte   `msg:"a"`
	Topics  [][32]byte `msg:"t"`
}

To index an EVM Log, we need its smartcontract's Address, and hashes of the Topics

func (Log) Clone

func (log Log) Clone() Log

func (*Log) DecodeMsg

func (z *Log) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Log) EncodeMsg

func (z *Log) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Log) MarshalMsg

func (z *Log) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Log) Msgsize

func (z *Log) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Log) UnmarshalMsg

func (z *Log) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type NewLostAndFoundOp

type NewLostAndFoundOp struct {
	UtxoId       [36]byte
	CovenantAddr [20]byte
}

type NewRedeemableOp

type NewRedeemableOp struct {
	UtxoId       [36]byte
	CovenantAddr [20]byte
}

type OpListsForCcUtxo

type OpListsForCcUtxo struct {
	NewRedeemableOps   []NewRedeemableOp
	NewLostAndFoundOps []NewLostAndFoundOp
	RedeemOps          []RedeemOp
	ConvertedOps       []ConvertedOp
	DeletedOps         []DeletedOp
}

type RedeemOp

type RedeemOp struct {
	UtxoId       [36]byte
	CovenantAddr [20]byte
	SourceType   byte
}

type Tx

type Tx struct {
	HashId  [32]byte `msg:"h"`
	SrcAddr [20]byte `msg:"s"`
	DstAddr [20]byte `msg:"d"`
	Content []byte   `msg:"c"` // the pre-serialized payload
	LogList []Log    `msg:"l"`
}

To index a transaction, we need its SrcAddr, DstAddr, HashId and the Logs in it

func (Tx) Clone

func (tx Tx) Clone() (res Tx)

func (*Tx) DecodeMsg

func (z *Tx) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Tx) EncodeMsg

func (z *Tx) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Tx) MarshalMsg

func (z *Tx) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Tx) Msgsize

func (z *Tx) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Tx) UnmarshalMsg

func (z *Tx) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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