blockcache

package
v0.15.3-beta.rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
	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.

Jump to

Keyboard shortcuts

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