herocache

package
v0.43.1-rc.1.access-me... Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: AGPL-3.0 Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockExecutionData added in v0.30.4

type BlockExecutionData struct {
	*stdmap.Backend[flow.Identifier, *execution_data.BlockExecutionDataEntity]
}

BlockExecutionData implements the block execution data memory pool. Stored execution data are keyed by block id.

func NewBlockExecutionData added in v0.30.4

func NewBlockExecutionData(limit uint32, logger zerolog.Logger, collector module.HeroCacheMetrics) *BlockExecutionData

NewBlockExecutionData implements a block execution data mempool based on hero cache.

type DNSCache

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

DNSCache provides a caching mechanism for DNS IP and TXT records.

The cache stores IP records in ipCache and TXT records in txtCache, using the domain's hashed value as the key.

func NewDNSCache

func NewDNSCache(sizeLimit uint32, logger zerolog.Logger, ipCollector module.HeroCacheMetrics, txtCollector module.HeroCacheMetrics,
) *DNSCache

NewDNSCache creates and returns a new instance of DNSCache. It initializes both the IP and TXT record caches with the provided size limit, logger, and cache metrics collectors for IP and TXT records.

func (*DNSCache) GetDomainIp

func (d *DNSCache) GetDomainIp(domain string) (*mempool.IpRecord, bool)

GetDomainIp returns the ip domain if exists in the cache. The boolean return value determines if domain exists in the cache.

func (*DNSCache) GetTxtRecord

func (d *DNSCache) GetTxtRecord(domain string) (*mempool.TxtRecord, bool)

GetTxtRecord returns the txt record if exists in the cache. The boolean return value determines if record exists in the cache.

func (*DNSCache) LockIPDomain added in v0.27.0

func (d *DNSCache) LockIPDomain(domain string) (bool, error)

LockIPDomain locks an ip address dns record if exists in the cache. The boolean return value determines whether attempt on locking was successful.

A locking attempt is successful when the domain record exists in the cache and has not been locked before. Once a domain record gets locked the only way to unlock it is through updating that record.

The locking process is defined to record that a resolving attempt is ongoing for an expired domain. So the locking happens to avoid any other parallel resolving

func (*DNSCache) LockTxtRecord added in v0.27.0

func (d *DNSCache) LockTxtRecord(txt string) (bool, error)

LockTxtRecord locks a txt address dns record if exists in the cache. The boolean return value determines whether attempt on locking was successful.

A locking attempt is successful when the domain record exists in the cache and has not been locked before. Once a domain record gets locked the only way to unlock it is through updating that record.

The locking process is defined to record that a resolving attempt is ongoing for an expired domain. So the locking happens to avoid any other parallel resolving.

func (*DNSCache) PutIpDomain added in v0.27.0

func (d *DNSCache) PutIpDomain(domain string, addresses []net.IPAddr, timestamp int64) bool

PutIpDomain adds the given ip domain into the cache.

func (*DNSCache) PutTxtRecord

func (d *DNSCache) PutTxtRecord(domain string, record []string, timestamp int64) bool

PutTxtRecord adds the given txt record into the cache.

func (*DNSCache) RemoveIp

func (d *DNSCache) RemoveIp(domain string) bool

RemoveIp removes an ip domain from cache.

func (*DNSCache) RemoveTxt

func (d *DNSCache) RemoveTxt(domain string) bool

RemoveTxt removes a txt record from cache.

func (*DNSCache) Size

func (d *DNSCache) Size() (uint, uint)

Size returns total domains maintained into this cache. The first returned value determines number of ip domains. The second returned value determines number of txt records.

func (*DNSCache) UpdateIPDomain added in v0.27.0

func (d *DNSCache) UpdateIPDomain(domain string, addresses []net.IPAddr, timestamp int64) error

UpdateIPDomain updates the dns record for the given ip domain with the new address and timestamp values.

func (*DNSCache) UpdateTxtRecord added in v0.27.0

func (d *DNSCache) UpdateTxtRecord(txt string, records []string, timestamp int64) error

UpdateTxtRecord updates the dns record for the given txt domain with the new address and timestamp values.

type Transactions

type Transactions struct {
	*stdmap.Backend[flow.Identifier, *flow.TransactionBody]
	// contains filtered or unexported fields
}

func NewTransactions

func NewTransactions(limit uint32, logger zerolog.Logger, collector module.HeroCacheMetrics) *Transactions

NewTransactions implements a transactions mempool based on hero cache.

func (*Transactions) Add

Add adds a transaction to the mempool.

func (*Transactions) ByPayer added in v0.43.0

func (t *Transactions) ByPayer(payer flow.Address) []*flow.TransactionBody

ByPayer retrieves all transactions from the memory pool that are sent by the given payer.

func (*Transactions) Clear

func (t *Transactions) Clear()

Clear removes all transactions stored in this mempool.

func (*Transactions) Remove added in v0.27.0

func (t *Transactions) Remove(id flow.Identifier) bool

Remove removes transaction from mempool.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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