types

package
v0.0.0-...-420fffb Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetWrappedTxs

func GetWrappedTxs(msg *wire.MsgBlock) []*btcutil.Tx

GetWrappedTxs returns transactions from a block message

Types

type BTCCache

type BTCCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

BTCCache represents a thread-safe cache of indexed blocks

func NewBTCCache

func NewBTCCache(maxEntries int64) (*BTCCache, error)

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) IsEmpty

func (cache *BTCCache) IsEmpty() bool

IsEmpty checks if the cache is empty

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

func (cache *BTCCache) RemoveLast() error

RemoveLast removes the most recent block from the cache (last in the queue).

func (*BTCCache) Resize

func (cache *BTCCache) Resize(maxEntries int64) error

Resize updates the maximum number of entries allowed in the cache

func (*BTCCache) Size

func (cache *BTCCache) Size() int64

Size returns the current number of blocks in the cache

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

type IndexedBlock struct {
	MsgBlock    *wire.MsgBlock
	BlockHeight int64
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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