mempool

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: Apache-2.0, BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Overview

mempool implements a buffer of requests sent to the ISCP chain, essentially a backlog of requests It contains both on-ledger and off-ledger requests. The mempool consists of 2 parts: the in-buffer and the pool All incoming requests are stored into the in-buffer first. Then they are asynchronously validated and moved to the pool itself.

Index

Constants

View Source
const FallbackDeadlineMinAllowedInterval = time.Minute * 10

don't process any request which deadline will expire within 10 minutes

Variables

This section is empty.

Functions

This section is empty.

Types

type Mempool

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

func New

func New(stateReader state.OptimisticStateReader, blobCache registry.BlobCache, log *logger.Logger, mempoolMetrics metrics.MempoolMetrics, solidificationLoopDelay ...time.Duration) *Mempool

func (*Mempool) Close

func (m *Mempool) Close()

func (*Mempool) GetRequest

func (m *Mempool) GetRequest(id iscp.RequestID) iscp.Request

func (*Mempool) HasRequest

func (m *Mempool) HasRequest(id iscp.RequestID) bool

HasRequest checks if the request is in the pool

func (*Mempool) Info

func (m *Mempool) Info() chain.MempoolInfo

Stats collects mempool stats

func (*Mempool) ReadyFromIDs

func (m *Mempool) ReadyFromIDs(nowis time.Time, reqIDs ...iscp.RequestID) ([]iscp.Request, []int, bool)

ReadyFromIDs if successful, function returns a deterministic list of requests for running on the VM - (a list of missing requests), false if some requests not arrived to the mempool yet. For retry later - (a list of processable requests), true if the list can be deterministically calculated Note that (a list of processable requests) can be empty if none satisfies nowis time constraint (timelock, fallback) For requests which are known and solidified, the result is deterministic

func (*Mempool) ReadyNow

func (m *Mempool) ReadyNow(now ...time.Time) []iscp.Request

ReadyNow returns preliminary batch of requests for consensus. Note that later status of request may change due to the time change and time constraints If there's at least one committee rotation request in the mempool, the ReadyNow returns batch with only one request, the oldest committee rotation request

func (*Mempool) ReceiveRequest

func (m *Mempool) ReceiveRequest(req iscp.Request) bool

ReceiveRequest used to receive off-ledger request

func (*Mempool) ReceiveRequests

func (m *Mempool) ReceiveRequests(reqs ...iscp.Request)

ReceiveRequests places requests into the inBuffer. InBuffer is unordered and non-deterministic

func (*Mempool) RemoveRequests

func (m *Mempool) RemoveRequests(reqs ...iscp.RequestID)

RemoveRequests removes requests from the pool

func (*Mempool) WaitInBufferEmpty

func (m *Mempool) WaitInBufferEmpty(timeout ...time.Duration) bool

WaitAllRequestsIn waits until in buffer becomes empty. Used in synchronous situations when the caller want to be sure all requests were fed into the pool. May create nondeterminism when used from goroutines

func (*Mempool) WaitRequestInPool

func (m *Mempool) WaitRequestInPool(reqid iscp.RequestID, timeout ...time.Duration) bool

WaitRequestInPool waits until the request appears in the pool but no longer than timeout

Jump to

Keyboard shortcuts

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