blockcache

package
v0.17.4-beta.rc1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 8 Imported by: 0

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.Mutex[lntypes.Hash]
}

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.

Jump to

Keyboard shortcuts

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