cache

package
v0.0.0-...-864a747 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilTransaction                          = errors.New("cannot cache a nil transaction")
	ErrFailedDecodingTrxKeyWrongNumOfParts     = errors.New("failed decoding transaction key, wrong number of parts")
	ErrFailedDecodingAddressKeyWrongNumOfParts = errors.New("failed decoding address key, wrong number of parts")
	ErrTrxAlreadyExists                        = errors.New("transaction already exists")
	ErrTransactionNotFound                     = errors.New("transaction not found")
	ErrProcessingFailed                        = errors.New("processing unexpected failure")
	ErrUnauthorized                            = errors.New("unauthorized")
)
View Source
var ErrWrongHashSizeInFlash = errors.New("wrong error size supplied to flashback has hash")

Functions

This section is empty.

Types

type Flashback

type Flashback struct {
	// contains filtered or unexported fields
}

func NewFlash

func NewFlash() (*Flashback, error)

NewFlash creates the new Hippocampus on success or returns an error otherwise.

func (*Flashback) Close

func (f *Flashback) Close() error

Close closes the cache in a safe way allowing all the goroutines to finish their jobs and cleaning the heap.

func (*Flashback) HasAddress

func (f *Flashback) HasAddress(a string) (bool, error)

HasAddress checks if flashback received given address request.

func (*Flashback) HasHash

func (f *Flashback) HasHash(h []byte) (bool, error)

HasHash checks if flashback received given hash in last ten seconds.

func (*Flashback) RemoveAddress

func (f *Flashback) RemoveAddress(a string) error

RemoveAddress removes address from the cache.

type Hippocampus

type Hippocampus struct {
	// contains filtered or unexported fields
}

Hippocampus is a short lived memory that can transmit memorized entities to other long lived memory.

func New

func New(maxEntrySize, maxCacheSizeMB int) (*Hippocampus, error)

New creates the new Hippocampus on success or returns an error otherwise.

func (*Hippocampus) Close

func (h *Hippocampus) Close() error

Close closes the cache in a safe way allowing all the goroutines to finish their jobs and cleaning the heap.

func (*Hippocampus) ReadBalance

func (h *Hippocampus) ReadBalance(a string) (spice.Melange, error)

ReadBalance reads balance from the mem cache.

func (*Hippocampus) ReadTransactions

func (h *Hippocampus) ReadTransactions(address string) ([]transaction.Transaction, error)

func (*Hippocampus) RemoveAwaitedTransaction

func (h *Hippocampus) RemoveAwaitedTransaction(hash [32]byte, address string) (transaction.Transaction, error)

RemoveAwaitedTransaction removes awaited transaction and the issuer and receiver address reference to the transaction.

func (*Hippocampus) RemoveBalance

func (h *Hippocampus) RemoveBalance(a string) error

RemoveBalance removes balance from the cache.

func (*Hippocampus) SaveAwaitedTransaction

func (h *Hippocampus) SaveAwaitedTransaction(trx *transaction.Transaction) error

SaveAwaitedTrx caches awaited transaction and reference of issuer and receiver address to the transaction hash.

func (*Hippocampus) SaveBalance

func (h *Hippocampus) SaveBalance(a string, s spice.Melange) error

SaveBalance saves balance in to the mem cache.

Jump to

Keyboard shortcuts

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