Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockCache ¶
type BlockCache struct { Cache *lru.Cache[wire.InvVect, *neutrino.CacheableBlock] HashMutex *multimutex.HashMutex }
BlockCache is an lru cache for blocks.
func NewBlockCache ¶
func NewBlockCache(capacity uint64) *BlockCache
NewBlockCache creates a new BlockCache with the given maximum capacity.
func (*BlockCache) GetBlock ¶
func (bc *BlockCache) GetBlock(hash *chainhash.Hash, getBlockImpl func(hash *chainhash.Hash) (*wire.MsgBlock, error)) (*wire.MsgBlock, error)
GetBlock first checks to see if the BlockCache already contains the block with the given hash. If it does then the block is fetched from the cache and returned. Otherwise the getBlockImpl function is used in order to fetch the new block and then it is stored in the block cache and returned.
Click to show internal directories.
Click to hide internal directories.