Documentation
¶
Index ¶
- func GetWrappedTxs(msg *wire.MsgBlock) []*btcutil.Tx
- type BTCCache
- func (cache *BTCCache) Add(block *IndexedBlock) error
- func (cache *BTCCache) FindBlock(height int64) (*IndexedBlock, error)
- func (cache *BTCCache) First() *IndexedBlock
- func (cache *BTCCache) GetAllBlocks() []*IndexedBlock
- func (cache *BTCCache) Init(blocks []*IndexedBlock) error
- func (cache *BTCCache) IsEmpty() bool
- func (cache *BTCCache) Last() *IndexedBlock
- func (cache *BTCCache) RemoveAll()
- func (cache *BTCCache) RemoveLast() error
- func (cache *BTCCache) Resize(maxEntries int64) error
- func (cache *BTCCache) Size() int64
- func (cache *BTCCache) Trim()
- func (cache *BTCCache) TrimConfirmedBlocks(k int) []*IndexedBlock
- type IndexedBlock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BTCCache ¶
BTCCache represents a thread-safe cache of indexed blocks
func NewBTCCache ¶
NewBTCCache creates a new BTCCache with the specified max entries
func (*BTCCache) Add ¶
func (cache *BTCCache) Add(block *IndexedBlock) error
Add adds a new block to the cache
func (*BTCCache) FindBlock ¶
func (cache *BTCCache) FindBlock(height int64) (*IndexedBlock, error)
FindBlock returns an error if no block is found in the cache. return error when not block not found in cache
func (*BTCCache) First ¶
func (cache *BTCCache) First() *IndexedBlock
First returns the oldest block in the cache (first in the queue). Returns nil when cache is empty.
func (*BTCCache) GetAllBlocks ¶
func (cache *BTCCache) GetAllBlocks() []*IndexedBlock
GetAllBlocks returns all blocks in the cache
func (*BTCCache) Init ¶
func (cache *BTCCache) Init(blocks []*IndexedBlock) error
Init initializes the cache with a slice of indexed blocks
func (*BTCCache) Last ¶
func (cache *BTCCache) Last() *IndexedBlock
Last returns the most recent block in the cache (last in the queue). Returns nil when cache is empty.
func (*BTCCache) RemoveAll ¶
func (cache *BTCCache) RemoveAll()
RemoveAll removes all blocks from the cache
func (*BTCCache) RemoveLast ¶
RemoveLast removes the most recent block from the cache (last in the queue).
func (*BTCCache) Trim ¶
func (cache *BTCCache) Trim()
Trim removes oldest blocks to keep cache size within maxEntries limit
func (*BTCCache) TrimConfirmedBlocks ¶
func (cache *BTCCache) TrimConfirmedBlocks(k int) []*IndexedBlock
TrimConfirmedBlocks removes confirmed blocks keeping only k most recent
type IndexedBlock ¶
IndexedBlock represents a BTC block with additional metadata including block height and transaction details needed for Merkle proof generation
func CreateTestIndexedBlocks ¶
func CreateTestIndexedBlocks(t *testing.T, count int64, startHeight int64) []*IndexedBlock
CreateTestIndexedBlocks is a test helper function that generates a slice of mock IndexedBlock objects.
func NewIndexedBlock ¶
func NewIndexedBlock( blockHeight int64, msgBlock *wire.MsgBlock, ) *IndexedBlock
NewIndexedBlock creates a new IndexedBlock instance with the given block height, header and transactions
func (*IndexedBlock) BlockHash ¶
func (indexedBlock *IndexedBlock) BlockHash() chainhash.Hash
BlockHash returns the hash of this block's header