Documentation ¶
Index ¶
- Constants
- Variables
- func GetValidBtcBackends() map[SupportedBtcBackend]bool
- func GetValidNetParams() map[string]bool
- func GetWrappedTxs(msg *wire.MsgBlock) []*btcutil.Tx
- func MustNewMsgInsertBTCSpvProof(submitter sdk.AccAddress, proofs []*btcctypes.BTCSpvProof) *btcctypes.MsgInsertBTCSpvProof
- func NewMsgInsertHeader(prefix string, signer sdk.AccAddress, header *wire.BlockHeader) *btcltypes.MsgInsertHeader
- type BTCCache
- func (b *BTCCache) Add(ib *IndexedBlock)
- func (b *BTCCache) FindBlock(blockHeight uint64) *IndexedBlock
- func (b *BTCCache) GetAllBlocks() []*IndexedBlock
- func (b *BTCCache) GetLastBlocks(stopHeight uint64) ([]*IndexedBlock, error)
- func (b *BTCCache) Init(ibs []*IndexedBlock) error
- func (b *BTCCache) RemoveLast() error
- func (b *BTCCache) Resize(maxEntries uint64) error
- func (b *BTCCache) Size() uint64
- func (b *BTCCache) Tip() *IndexedBlock
- func (b *BTCCache) Trim()
- type BlockEvent
- type CheckpointCache
- func (c *CheckpointCache) AddCheckpoint(ckpt *Ckpt)
- func (c *CheckpointCache) AddSegment(ckptSeg *CkptSegment) error
- func (c *CheckpointCache) HasCheckpoints() bool
- func (c *CheckpointCache) Match()
- func (c *CheckpointCache) NumCheckpoints() int
- func (c *CheckpointCache) NumSegments() int
- func (c *CheckpointCache) PopEarliestCheckpoint() *Ckpt
- type CheckpointInfo
- type Ckpt
- type CkptSegment
- type EventType
- type IndexedBlock
- type SentCheckpoints
- type SupportedBtcBackend
- type SupportedBtcNetwork
- type UTXO
Constants ¶
const ( BtcMainnet SupportedBtcNetwork = "mainnet" BtcTestnet SupportedBtcNetwork = "testnet" BtcSimnet SupportedBtcNetwork = "simnet" BtcRegtest SupportedBtcNetwork = "regtest" BtcSignet SupportedBtcNetwork = "signet" Btcd SupportedBtcBackend = "btcd" Bitcoind SupportedBtcBackend = "bitcoind" )
Variables ¶
Functions ¶
func GetValidBtcBackends ¶ added in v0.2.0
func GetValidBtcBackends() map[SupportedBtcBackend]bool
func GetValidNetParams ¶
func MustNewMsgInsertBTCSpvProof ¶
func MustNewMsgInsertBTCSpvProof(submitter sdk.AccAddress, proofs []*btcctypes.BTCSpvProof) *btcctypes.MsgInsertBTCSpvProof
MustNewMsgInsertBTCSpvProof returns a MsgInsertBTCSpvProof msg given the submitter address and SPV proofs of two BTC txs
func NewMsgInsertHeader ¶
func NewMsgInsertHeader(prefix string, signer sdk.AccAddress, header *wire.BlockHeader) *btcltypes.MsgInsertHeader
Types ¶
type BTCCache ¶
func NewBTCCache ¶
func (*BTCCache) Add ¶
func (b *BTCCache) Add(ib *IndexedBlock)
Add adds a new block to the cache. Thread-safe.
func (*BTCCache) FindBlock ¶
func (b *BTCCache) FindBlock(blockHeight uint64) *IndexedBlock
FindBlock uses binary search to find the block with the given height in cache
func (*BTCCache) GetAllBlocks ¶
func (b *BTCCache) GetAllBlocks() []*IndexedBlock
GetAllBlocks returns list of all blocks in cache
func (*BTCCache) GetLastBlocks ¶
func (b *BTCCache) GetLastBlocks(stopHeight uint64) ([]*IndexedBlock, error)
GetLastBlocks returns list of blocks between the given stopHeight and the tip of the chain in cache
func (*BTCCache) Init ¶
func (b *BTCCache) Init(ibs []*IndexedBlock) error
Init initializes the cache with the given blocks. Input blocks should be sorted by height. Thread-safe.
func (*BTCCache) RemoveLast ¶
RemoveLast deletes the last block in cache
func (*BTCCache) Tip ¶
func (b *BTCCache) Tip() *IndexedBlock
type BlockEvent ¶
type BlockEvent struct { EventType EventType Height int32 Header *wire.BlockHeader }
func NewBlockEvent ¶
func NewBlockEvent(eventType EventType, height int32, header *wire.BlockHeader) *BlockEvent
type CheckpointCache ¶
type CheckpointCache struct { Tag btctxformatter.BabylonTag Version btctxformatter.FormatVersion // list that contains matched checkpoints Checkpoints []*Ckpt // map that contains checkpoint segments // first key: index of the segment in the checkpoint (0 or 1) // second key: hash of the OP_RETURN data in this ckpt segment Segments map[uint8]map[string]*CkptSegment }
func NewCheckpointCache ¶
func NewCheckpointCache(tag btctxformatter.BabylonTag, version btctxformatter.FormatVersion) CheckpointCache
func (*CheckpointCache) AddCheckpoint ¶
func (c *CheckpointCache) AddCheckpoint(ckpt *Ckpt)
func (*CheckpointCache) AddSegment ¶
func (c *CheckpointCache) AddSegment(ckptSeg *CkptSegment) error
func (*CheckpointCache) HasCheckpoints ¶
func (c *CheckpointCache) HasCheckpoints() bool
func (*CheckpointCache) Match ¶
func (c *CheckpointCache) Match()
TODO: generalise to NumExpectedProofs > 2 TODO: optimise the complexity by hashmap
func (*CheckpointCache) NumCheckpoints ¶
func (c *CheckpointCache) NumCheckpoints() int
func (*CheckpointCache) NumSegments ¶
func (c *CheckpointCache) NumSegments() int
func (*CheckpointCache) PopEarliestCheckpoint ¶
func (c *CheckpointCache) PopEarliestCheckpoint() *Ckpt
type CheckpointInfo ¶
type CheckpointInfo struct {
// contains filtered or unexported fields
}
type Ckpt ¶
type Ckpt struct { Segments []*CkptSegment Epoch uint64 }
func NewCkpt ¶
func NewCkpt(ckptSeg1 *CkptSegment, ckptSeg2 *CkptSegment, epochNumber uint64) *Ckpt
func (*Ckpt) MustGenSPVProofs ¶
func (ckpt *Ckpt) MustGenSPVProofs() []*btcctypes.BTCSpvProof
type CkptSegment ¶
type CkptSegment struct { *btctxformatter.BabylonData TxIdx int AssocBlock *IndexedBlock }
CkptSegment is a segment of the Babylon checkpoint, including - Data: actual OP_RETURN data excluding the Babylon header - Index: index of the segment in the checkpoint - TxIdx: index of the tx in AssocBlock - AssocBlock: pointer to the block that contains the tx that carries the ckpt segment
func NewCkptSegment ¶
func NewCkptSegment(tag btctxformatter.BabylonTag, version btctxformatter.FormatVersion, block *IndexedBlock, tx *btcutil.Tx) *CkptSegment
type IndexedBlock ¶
type IndexedBlock struct { Height int32 Header *wire.BlockHeader Txs []*btcutil.Tx }
IndexedBlock is a BTC block with some extra information compared to wire.MsgBlock, including: - block height - txHash, txHashWitness, txIndex for each Tx These are necessary for generating Merkle proof (and thus the `MsgInsertBTCSpvProof` message in babylon) of a certain tx
func NewIndexedBlock ¶
func NewIndexedBlock(height int32, header *wire.BlockHeader, txs []*btcutil.Tx) *IndexedBlock
func NewIndexedBlockFromMsgBlock ¶
func NewIndexedBlockFromMsgBlock(height int32, block *wire.MsgBlock) *IndexedBlock
func (*IndexedBlock) BlockHash ¶
func (ib *IndexedBlock) BlockHash() chainhash.Hash
func (*IndexedBlock) GenSPVProof ¶
func (ib *IndexedBlock) GenSPVProof(txIdx int) (*btcctypes.BTCSpvProof, error)
GenSPVProof generates a Merkle proof of a certain tx with index txIdx
func (*IndexedBlock) MsgBlock ¶
func (ib *IndexedBlock) MsgBlock() *wire.MsgBlock
type SentCheckpoints ¶
type SentCheckpoints struct {
// contains filtered or unexported fields
}
func NewSentCheckpoints ¶
func NewSentCheckpoints(interval uint) SentCheckpoints
func (*SentCheckpoints) ShouldSend ¶
func (sc *SentCheckpoints) ShouldSend(epoch uint64) bool
ShouldSend returns true if 1. no checkpoint was sent for the epoch 2. the last sent time is outdated by resendIntervalSeconds
type SupportedBtcBackend ¶ added in v0.2.0
type SupportedBtcBackend string
func (SupportedBtcBackend) String ¶ added in v0.2.0
func (c SupportedBtcBackend) String() string
type SupportedBtcNetwork ¶
type SupportedBtcNetwork string
func (SupportedBtcNetwork) String ¶
func (c SupportedBtcNetwork) String() string