slot

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BpMaxTime

func BpMaxTime() time.Duration

BpMaxTime returns the max time limit for block production in nsec.

func Equal

func Equal(s1, s2 *Slot) bool

Equal reports whether s1 has the same index as s2 or not.

func Init

func Init(blockIntervalSec int64)

Init initializes various slot parameters

func IsNextTo

func IsNextTo(s1, s2 *Slot) bool

IsNextTo reports whether s1 corresponds to the slot next to s2.

func LessEqual

func LessEqual(s1, s2 *Slot) bool

LessEqual reports whether s1.nextIndex is less than or equal to s2.nextIndex

Types

type Slot

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

Slot is a DPoS slot implementation.

func NewFromUnixNano

func NewFromUnixNano(ns int64) *Slot

NewFromUnixNano returns a Slot corresponding to a UNIX time value (ns).

func Now

func Now() *Slot

Now returns a Slot corresponding to the current local time.

func Time

func Time(t time.Time) *Slot

Time returns a Slot corresponding to the given time.

func (*Slot) GetBpTimeout

func (s *Slot) GetBpTimeout() int64

GetBpTimeout returns the time available for block production in milliseconds.

func (*Slot) IsFor

func (s *Slot) IsFor(bpIdx bp.Index, bpCount uint16) bool

IsFor reports whether s corresponds to myBpIdx (block producer index).

func (*Slot) IsFuture

func (s *Slot) IsFuture() bool

IsFuture reports whether s

func (*Slot) IsValidNow

func (s *Slot) IsValidNow() bool

IsValidNow reports whether s is still valid at the time when it's called.

func (*Slot) NextBpIndex

func (s *Slot) NextBpIndex(bpCount uint16) int64

NextBpIndex returns BP index for s.nextIndex.

func (*Slot) RemainingTimeMS

func (s *Slot) RemainingTimeMS() int64

RemainingTimeMS returns the remaining duration until the next block generation time.

func (Slot) TimesUp

func (s Slot) TimesUp() bool

TimesUp reports whether the remaining time <= BpMinTimeLimitMs

func (*Slot) UnixNano

func (s *Slot) UnixNano() int64

UnixNano returns UNIX time in ns.

Jump to

Keyboard shortcuts

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