Documentation
¶
Overview ¶
Package knownRounds tracks which rounds have been checked and which are unchecked using a bit stream.
Index ¶
- type DiskKnownRounds
- type KnownRounds
- func (kr *KnownRounds) Check(rid id.Round)
- func (kr *KnownRounds) Checked(rid id.Round) bool
- func (kr *KnownRounds) ForceCheck(rid id.Round)
- func (kr *KnownRounds) Forward(rid id.Round)
- func (kr KnownRounds) GetBitStream() []uint64
- func (kr KnownRounds) GetFirstUnchecked() id.Round
- func (kr KnownRounds) GetFuPos() int
- func (kr KnownRounds) GetLastChecked() id.Round
- func (kr *KnownRounds) Len() int
- func (kr *KnownRounds) Marshal() []byte
- func (kr KnownRounds) MarshalBitStream1Byte() []byte
- func (kr KnownRounds) MarshalBitStream2Byte() []byte
- func (kr KnownRounds) MarshalBitStream4Byte() []byte
- func (kr KnownRounds) MarshalBitStream8Byte() []byte
- func (kr *KnownRounds) OutputBuffChanges(old []uint64) (KrChanges, id.Round, id.Round, int, error)
- func (kr *KnownRounds) RangeUnchecked(oldestUnknown id.Round, threshold uint, roundCheck func(id id.Round) bool, ...) (earliestRound id.Round, has, unknown []id.Round)
- func (kr *KnownRounds) RangeUncheckedMasked(mask *KnownRounds, roundCheck RoundCheckFunc, maxChecked int)
- func (kr *KnownRounds) RangeUncheckedMaskedRange(mask *KnownRounds, roundCheck RoundCheckFunc, start, end id.Round, ...)
- func (kr *KnownRounds) Truncate(start id.Round) *KnownRounds
- func (kr *KnownRounds) Unmarshal(data []byte) error
- type KrChanges
- type RoundCheckFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiskKnownRounds ¶
DiskKnownRounds structure is used to as an intermediary to marshal and unmarshal KnownRounds.
type KnownRounds ¶
type KnownRounds struct {
// contains filtered or unexported fields
}
KnownRounds structure tracks which rounds are known and which are unknown. Each bit in bitStream corresponds to a round ID and if it is set, it means the round has been checked. All rounds before firstUnchecked are known to be checked. All rounds after lastChecked are unknown.
func NewFromParts ¶
func NewFromParts( buff []uint64, firstUnchecked, lastChecked id.Round, fuPos int) *KnownRounds
NewFromParts creates a new KnownRounds from the given firstUnchecked, lastChecked, fuPos, and uint64 buffer.
func NewKnownRound ¶
func NewKnownRound(roundCapacity int) *KnownRounds
NewKnownRound creates a new empty KnownRounds in the default state with a bit stream that can hold the given number of rounds.
func (*KnownRounds) Check ¶
func (kr *KnownRounds) Check(rid id.Round)
Check denotes a round has been checked. If the passed in round occurred after the last checked round, then every round between them is set as unchecked and the passed in round becomes the last checked round. Will panic if the buffer is not large enough to hold the current data and the new data
func (*KnownRounds) Checked ¶
func (kr *KnownRounds) Checked(rid id.Round) bool
Checked determines if the round has been checked.
func (*KnownRounds) ForceCheck ¶
func (kr *KnownRounds) ForceCheck(rid id.Round)
func (*KnownRounds) Forward ¶
func (kr *KnownRounds) Forward(rid id.Round)
Forward sets all rounds before the given round ID as checked.
func (KnownRounds) GetBitStream ¶
func (kr KnownRounds) GetBitStream() []uint64
func (KnownRounds) GetFirstUnchecked ¶
func (kr KnownRounds) GetFirstUnchecked() id.Round
func (KnownRounds) GetFuPos ¶
func (kr KnownRounds) GetFuPos() int
func (KnownRounds) GetLastChecked ¶
func (kr KnownRounds) GetLastChecked() id.Round
func (*KnownRounds) Len ¶
func (kr *KnownRounds) Len() int
Len returns the max number of round IDs the buffer can hold.
func (*KnownRounds) Marshal ¶
func (kr *KnownRounds) Marshal() []byte
Marshal returns the JSON encoding of DiskKnownRounds, which contains the compressed information from KnownRounds. The bit stream is compressed such that the firstUnchecked occurs in the first block of the bit stream.
func (KnownRounds) MarshalBitStream1Byte ¶
func (kr KnownRounds) MarshalBitStream1Byte() []byte
func (KnownRounds) MarshalBitStream2Byte ¶
func (kr KnownRounds) MarshalBitStream2Byte() []byte
func (KnownRounds) MarshalBitStream4Byte ¶
func (kr KnownRounds) MarshalBitStream4Byte() []byte
func (KnownRounds) MarshalBitStream8Byte ¶
func (kr KnownRounds) MarshalBitStream8Byte() []byte
func (*KnownRounds) OutputBuffChanges ¶
OutputBuffChanges returns the current KnownRounds' firstUnchecked, lastChecked, fuPos, and a list of changes between the given uint64 buffer and the current KnownRounds bit stream. An error is returned if the two buffers are not of the same length.
func (*KnownRounds) RangeUnchecked ¶
func (kr *KnownRounds) RangeUnchecked(oldestUnknown id.Round, threshold uint, roundCheck func(id id.Round) bool, maxPickups int) ( earliestRound id.Round, has, unknown []id.Round)
RangeUnchecked runs the passed function over all rounds starting with oldest unknown and ending with
func (*KnownRounds) RangeUncheckedMasked ¶
func (kr *KnownRounds) RangeUncheckedMasked(mask *KnownRounds, roundCheck RoundCheckFunc, maxChecked int)
RangeUncheckedMasked masks the bit stream with the provided mask.
func (*KnownRounds) RangeUncheckedMaskedRange ¶
func (kr *KnownRounds) RangeUncheckedMaskedRange(mask *KnownRounds, roundCheck RoundCheckFunc, start, end id.Round, maxChecked int)
RangeUncheckedMaskedRange masks the bit stream with the provided mask.
func (*KnownRounds) Truncate ¶
func (kr *KnownRounds) Truncate(start id.Round) *KnownRounds
Truncate returns a subs ample of the KnownRounds buffer from last checked.
func (*KnownRounds) Unmarshal ¶
func (kr *KnownRounds) Unmarshal(data []byte) error
Unmarshal parses the JSON-encoded data and stores it in the KnownRounds. An error is returned if the bit stream data is larger than the KnownRounds bit stream.
type KrChanges ¶
KrChanges map contains a list of changes between two KnownRounds bit streams. The key is the index of the changed word and the value contains the change.