drr

package
v1.0.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

Types

type BasicBuffer

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

BasicBuffer represents a buffer of IssuerQueue.

func NewBasicBuffer

func NewBasicBuffer() *BasicBuffer

NewBasicBuffer returns a new BasicBuffer.

func (*BasicBuffer) Clear

func (b *BasicBuffer) Clear()

func (*BasicBuffer) CreateIssuerQueue

func (b *BasicBuffer) CreateIssuerQueue(issuerID iotago.AccountID) *IssuerQueue

func (*BasicBuffer) Current

func (b *BasicBuffer) Current() *IssuerQueue

Current returns the current IssuerQueue in round-robin order.

func (*BasicBuffer) ForEach

func (b *BasicBuffer) ForEach(consumer func(*IssuerQueue) bool)

ForEach applies a consumer function to each IssuerQueue in the BasicBuffer.

func (*BasicBuffer) GetOrCreateIssuerQueue

func (b *BasicBuffer) GetOrCreateIssuerQueue(issuerID iotago.AccountID) *IssuerQueue

func (*BasicBuffer) IssuerIDs

func (b *BasicBuffer) IssuerIDs() []iotago.AccountID

IssuerIDs returns the issuerIDs of all issuers.

func (*BasicBuffer) IssuerQueue

func (b *BasicBuffer) IssuerQueue(issuerID iotago.AccountID) *IssuerQueue

IssuerQueue returns the queue for the corresponding issuer.

func (*BasicBuffer) IssuerQueueBlockCount

func (b *BasicBuffer) IssuerQueueBlockCount(issuerID iotago.AccountID) int

IssuerQueueSize returns the number of blocks in the queue for the corresponding issuer.

func (*BasicBuffer) IssuerQueueWork

func (b *BasicBuffer) IssuerQueueWork(issuerID iotago.AccountID) iotago.WorkScore

IssuerQueueWork returns the total WorkScore of block in the queue for the corresponding issuer.

func (*BasicBuffer) Next

func (b *BasicBuffer) Next() *IssuerQueue

Next returns the next IssuerQueue in round-robin order.

func (*BasicBuffer) NumActiveIssuers

func (b *BasicBuffer) NumActiveIssuers() int

NumActiveIssuers returns the number of active issuers in b.

func (*BasicBuffer) PopFront

func (b *BasicBuffer) PopFront() *blocks.Block

PopFront removes the first ready block from the queue of the current issuer.

func (*BasicBuffer) Ready

func (b *BasicBuffer) Ready(block *blocks.Block) bool

Ready marks a previously submitted block as ready to be scheduled.

func (*BasicBuffer) ReadyBlocksCount

func (b *BasicBuffer) ReadyBlocksCount() (readyBlocksCount int)

ReadyBlocksCount returns the number of ready blocks in the buffer.

func (*BasicBuffer) RemoveIssuerQueue

func (b *BasicBuffer) RemoveIssuerQueue(issuerID iotago.AccountID)

RemoveIssuerQueue removes all blocks (submitted and ready) for the given issuer and deletes the issuer queue.

func (*BasicBuffer) RemoveIssuerQueueIfEmpty

func (b *BasicBuffer) RemoveIssuerQueueIfEmpty(issuerID iotago.AccountID)

RemoveIssuerQueueIfEmpty removes all blocks (submitted and ready) for the given issuer and deletes the issuer queue if it is empty.

func (*BasicBuffer) Submit

func (b *BasicBuffer) Submit(blk *blocks.Block, issuerQueue *IssuerQueue, quantumFunc func(iotago.AccountID) Deficit, maxBuffer int) ([]*blocks.Block, bool)

Submit submits a block. Return blocks dropped from the scheduler to make room for the submitted block. The submitted block can also be returned as dropped if the issuer does not have enough mana.

func (*BasicBuffer) TotalBlocksCount

func (b *BasicBuffer) TotalBlocksCount() (blocksCount int)

TotalBlocksCount returns the number of blocks in the buffer.

type Deficit

type Deficit int64

type IssuerQueue

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

IssuerQueue keeps the submitted blocks of an issuer.

func NewIssuerQueue

func NewIssuerQueue(issuerID iotago.AccountID, sizeChangedCallback func(totalSizeDelta int64, readySizeDelta int64)) *IssuerQueue

NewIssuerQueue returns a new IssuerQueue.

func (*IssuerQueue) Clear

func (q *IssuerQueue) Clear()

Clear removes all blocks from the queue.

func (*IssuerQueue) Front

func (q *IssuerQueue) Front() *blocks.Block

Front returns the first ready block in the queue.

func (*IssuerQueue) IDs

func (q *IssuerQueue) IDs() (ids []iotago.BlockID)

IDs returns the IDs of all submitted blocks (ready or not).

func (*IssuerQueue) IssuerID

func (q *IssuerQueue) IssuerID() iotago.AccountID

IssuerID returns the ID of the issuer belonging to the queue.

func (*IssuerQueue) PopFront

func (q *IssuerQueue) PopFront() *blocks.Block

PopFront removes the first ready block from the queue.

func (*IssuerQueue) Ready

func (q *IssuerQueue) Ready(block *blocks.Block) bool

Ready marks a previously submitted block as ready to be scheduled.

func (*IssuerQueue) RemoveTail

func (q *IssuerQueue) RemoveTail() *blocks.Block

RemoveTail removes the oldest block from the queue.

func (*IssuerQueue) Size

func (q *IssuerQueue) Size() int

Size returns the total number of blocks in the queue. This function is thread-safe.

func (*IssuerQueue) Submit

func (q *IssuerQueue) Submit(element *blocks.Block) bool

Submit submits a block for the queue. Return true if submitted and false if it was already submitted.

func (*IssuerQueue) Work

func (q *IssuerQueue) Work() iotago.WorkScore

Work returns the total work of the blocks in the queue. This function is thread-safe.

type Scheduler

type Scheduler struct {
	module.Module
	// contains filtered or unexported fields
}

func New

func New(subModule module.Module, apiProvider iotago.APIProvider, opts ...options.Option[Scheduler]) *Scheduler

func (*Scheduler) AddBlock

func (s *Scheduler) AddBlock(block *blocks.Block)

func (*Scheduler) BasicBufferSize

func (s *Scheduler) BasicBufferSize() int

BasicBufferSize returns the current buffer size of the Scheduler as block count.

func (*Scheduler) IsBlockIssuerReady

func (s *Scheduler) IsBlockIssuerReady(accountID iotago.AccountID, workScores ...iotago.WorkScore) bool

func (*Scheduler) IsShutdown

func (s *Scheduler) IsShutdown() bool

func (*Scheduler) IssuerQueueBlockCount

func (s *Scheduler) IssuerQueueBlockCount(issuerID iotago.AccountID) int

IssuerQueueBlockCount returns the number of blocks in the queue of the given issuer.

func (*Scheduler) IssuerQueueWork

func (s *Scheduler) IssuerQueueWork(issuerID iotago.AccountID) iotago.WorkScore

IssuerQueueWork returns the queue size of the given issuer in work units.

func (*Scheduler) MaxBufferSize

func (s *Scheduler) MaxBufferSize() int

MaxBufferSize returns the max buffer size of the Scheduler as block count.

func (*Scheduler) ReadyBlocksCount

func (s *Scheduler) ReadyBlocksCount() int

ReadyBlocksCount returns the number of ready blocks.

func (*Scheduler) Reset

func (s *Scheduler) Reset()

Reset resets the component to a clean state as if it was created at the last commitment.

func (*Scheduler) Start

func (s *Scheduler) Start()

Start starts the scheduler.

func (*Scheduler) ValidatorBufferSize

func (s *Scheduler) ValidatorBufferSize() int

func (*Scheduler) ValidatorQueueBlockCount

func (s *Scheduler) ValidatorQueueBlockCount(issuerID iotago.AccountID) int

ValidatorQueueBlockCount returns the number of validation blocks in the validator queue of the given issuer.

type SubSlotIndex

type SubSlotIndex int

type ValidatorBuffer

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

func NewValidatorBuffer

func NewValidatorBuffer() *ValidatorBuffer

func (*ValidatorBuffer) Clear

func (b *ValidatorBuffer) Clear()

func (*ValidatorBuffer) Delete

func (b *ValidatorBuffer) Delete(predicate func(element *ValidatorQueue) bool)

Delete removes all validator queues that match the predicate.

func (*ValidatorBuffer) ForEachValidatorQueue

func (b *ValidatorBuffer) ForEachValidatorQueue(consumer func(accountID iotago.AccountID, validatorQueue *ValidatorQueue) bool)

ForEachValidatorQueue iterates over all validator queues.

func (*ValidatorBuffer) Get

func (b *ValidatorBuffer) Get(accountID iotago.AccountID) (*ValidatorQueue, bool)

func (*ValidatorBuffer) GetOrCreate

func (b *ValidatorBuffer) GetOrCreate(accountID iotago.AccountID, onCreateCallback func(*ValidatorQueue)) *ValidatorQueue

func (*ValidatorBuffer) Ready

func (b *ValidatorBuffer) Ready(block *blocks.Block)

Ready marks a previously submitted block as ready to be scheduled.

func (*ValidatorBuffer) Size

func (b *ValidatorBuffer) Size() int

type ValidatorQueue

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

func NewValidatorQueue

func NewValidatorQueue(accountID iotago.AccountID, sizeChangedCallback func(totalSizeDelta int64)) *ValidatorQueue

func (*ValidatorQueue) AccountID

func (q *ValidatorQueue) AccountID() iotago.AccountID

func (*ValidatorQueue) Clear

func (q *ValidatorQueue) Clear()

Clear removes all blocks from the queue.

func (*ValidatorQueue) PopFront

func (q *ValidatorQueue) PopFront() *blocks.Block

PopFront removes the first ready block from the queue.

func (*ValidatorQueue) Ready

func (q *ValidatorQueue) Ready(block *blocks.Block) bool

func (*ValidatorQueue) RemoveTail

func (q *ValidatorQueue) RemoveTail() *blocks.Block

func (*ValidatorQueue) ScheduleNext

func (q *ValidatorQueue) ScheduleNext() bool

ScheduleNext schedules the next block.

func (ValidatorQueue) Shutdown

func (q ValidatorQueue) Shutdown()

Shutdown stops the queue and clears all blocks.

func (*ValidatorQueue) Size

func (q *ValidatorQueue) Size() int

func (*ValidatorQueue) Submit

func (q *ValidatorQueue) Submit(block *blocks.Block, maxBuffer int) (*blocks.Block, bool)

Jump to

Keyboard shortcuts

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