cache

package
v0.78.2 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashCache

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

HashCache is a payload cache which is used to store last consensus payloads.

func NewFIFOCache

func NewFIFOCache(capacity int) *HashCache

NewFIFOCache returns new FIFO cache with the specified capacity.

func (*HashCache) Add

func (c *HashCache) Add(p Hashable)

Add adds payload into a cache if it doesn't already exist.

func (*HashCache) Get

func (c *HashCache) Get(h util.Uint256) Hashable

Get returns payload with the specified hash from cache.

func (*HashCache) Has

func (c *HashCache) Has(h util.Uint256) bool

Has checks if an item is already in cache.

type Hashable

type Hashable interface {
	Hash() util.Uint256
}

Hashable is a type of items which can be stored in the HashCache.

Jump to

Keyboard shortcuts

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