Documentation
¶
Index ¶
- Constants
- Variables
- func GetValidNetParams() map[string]bool
- type BTCCache
- func (b *BTCCache) Add(ib *IndexedBlock)
- func (b *BTCCache) FindBlock(blockHeight uint64) *IndexedBlock
- func (b *BTCCache) First() *IndexedBlock
- func (b *BTCCache) GetAllBlocks() []*IndexedBlock
- func (b *BTCCache) GetLastBlocks(stopHeight uint64) ([]*IndexedBlock, error)
- func (b *BTCCache) Init(ibs []*IndexedBlock) error
- func (b *BTCCache) RemoveAll()
- 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()
- func (b *BTCCache) TrimConfirmedBlocks(k int) []*IndexedBlock
- type BTCHeaderHashBytes
- func (m *BTCHeaderHashBytes) Eq(hash *BTCHeaderHashBytes) bool
- func (m *BTCHeaderHashBytes) FromChainhash(hash *chainhash.Hash)
- func (m BTCHeaderHashBytes) Marshal() ([]byte, error)
- func (m *BTCHeaderHashBytes) MarshalHex() string
- func (m BTCHeaderHashBytes) MarshalJSON() ([]byte, error)
- func (m BTCHeaderHashBytes) MarshalTo(data []byte) (int, error)
- func (m BTCHeaderHashBytes) MustMarshal() []byte
- func (m *BTCHeaderHashBytes) Size() int
- func (m *BTCHeaderHashBytes) String() string
- func (m BTCHeaderHashBytes) ToChainhash() *chainhash.Hash
- func (m *BTCHeaderHashBytes) Unmarshal(bz []byte) error
- func (m *BTCHeaderHashBytes) UnmarshalHex(hash string) error
- func (m *BTCHeaderHashBytes) UnmarshalJSON(bz []byte) error
- type IndexedBlock
- type RelayerConfig
- type SupportedBtcNetwork
Constants ¶
const BTCHeaderHashLen = 32
Variables ¶
var ( ErrEmptyCache = errors.New("empty cache") ErrInvalidMaxEntries = errors.New("invalid max entries") ErrTooManyEntries = errors.New("the number of blocks is more than maxEntries") ErrorUnsortedBlocks = errors.New("blocks are not sorted by height") ErrInvalidMultiSig = errors.New("invalid multi-sig") ErrInsufficientPower = errors.New("insufficient power") ErrInvalidEpochNum = errors.New("invalid epoch number") ErrInconsistentBlockHash = errors.New("inconsistent BlockHash") ErrLivenessAttack = errors.New("liveness attack") )
Functions ¶
func GetValidNetParams ¶
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) First ¶
func (b *BTCCache) First() *IndexedBlock
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) RemoveAll ¶
func (b *BTCCache) RemoveAll()
RemoveAll deletes all the blocks in cache
func (*BTCCache) RemoveLast ¶
RemoveLast deletes the last block in cache
func (*BTCCache) Tip ¶
func (b *BTCCache) Tip() *IndexedBlock
func (*BTCCache) Trim ¶
func (b *BTCCache) Trim()
Trim trims BTCCache to only keep the latest `maxEntries` blocks, and set `maxEntries` to be the cache size
func (*BTCCache) TrimConfirmedBlocks ¶
func (b *BTCCache) TrimConfirmedBlocks(k int) []*IndexedBlock
TrimConfirmedBlocks keeps the last <=k blocks in the cache and returns the rest in the same order the returned blocks are considered confirmed
type BTCHeaderHashBytes ¶
type BTCHeaderHashBytes []byte
func NewBTCHeaderHashBytesFromBytes ¶
func NewBTCHeaderHashBytesFromBytes(hash []byte) (BTCHeaderHashBytes, error)
func NewBTCHeaderHashBytesFromChainhash ¶
func NewBTCHeaderHashBytesFromChainhash(chHash *chainhash.Hash) BTCHeaderHashBytes
func NewBTCHeaderHashBytesFromHex ¶
func NewBTCHeaderHashBytesFromHex(hex string) (BTCHeaderHashBytes, error)
func (*BTCHeaderHashBytes) Eq ¶
func (m *BTCHeaderHashBytes) Eq(hash *BTCHeaderHashBytes) bool
func (*BTCHeaderHashBytes) FromChainhash ¶
func (m *BTCHeaderHashBytes) FromChainhash(hash *chainhash.Hash)
func (BTCHeaderHashBytes) Marshal ¶
func (m BTCHeaderHashBytes) Marshal() ([]byte, error)
func (*BTCHeaderHashBytes) MarshalHex ¶
func (m *BTCHeaderHashBytes) MarshalHex() string
func (BTCHeaderHashBytes) MarshalJSON ¶
func (m BTCHeaderHashBytes) MarshalJSON() ([]byte, error)
func (BTCHeaderHashBytes) MarshalTo ¶
func (m BTCHeaderHashBytes) MarshalTo(data []byte) (int, error)
func (BTCHeaderHashBytes) MustMarshal ¶
func (m BTCHeaderHashBytes) MustMarshal() []byte
func (*BTCHeaderHashBytes) Size ¶
func (m *BTCHeaderHashBytes) Size() int
func (*BTCHeaderHashBytes) String ¶
func (m *BTCHeaderHashBytes) String() string
func (BTCHeaderHashBytes) ToChainhash ¶
func (m BTCHeaderHashBytes) ToChainhash() *chainhash.Hash
func (*BTCHeaderHashBytes) Unmarshal ¶
func (m *BTCHeaderHashBytes) Unmarshal(bz []byte) error
func (*BTCHeaderHashBytes) UnmarshalHex ¶
func (m *BTCHeaderHashBytes) UnmarshalHex(hash string) error
func (*BTCHeaderHashBytes) UnmarshalJSON ¶
func (m *BTCHeaderHashBytes) UnmarshalJSON(bz []byte) error
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 RelayerConfig ¶
type RelayerConfig struct { NetParams string `mapstructure:"netparams"` // should be mainnet|testnet|simnet|signet BTCCacheSize uint64 `mapstructure:"btc_cache_size"` // size of the BTC cache MaxHeadersInMsg uint32 `mapstructure:"max_headers_in_msg"` // maximum number of headers in a MsgInsertHeaders message }
RelayerConfig defines configuration for the reporter.
func DefaultRelayerConfig ¶
func DefaultRelayerConfig() RelayerConfig
func (*RelayerConfig) Validate ¶
func (cfg *RelayerConfig) Validate() error
type SupportedBtcNetwork ¶
type SupportedBtcNetwork string
const ( BtcMainnet SupportedBtcNetwork = "mainnet" BtcTestnet SupportedBtcNetwork = "testnet" BtcSimnet SupportedBtcNetwork = "simnet" BtcRegtest SupportedBtcNetwork = "regtest" BtcSignet SupportedBtcNetwork = "signet" )
func (SupportedBtcNetwork) String ¶
func (c SupportedBtcNetwork) String() string