blockcache

package
v0.13.1-beta Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: MIT Imports: 7 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
	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