blockgadget

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewEvents = event.CreateGroupConstructor(func() (newEvents *Events) {
	return &Events{
		BlockAccepted:  event.New1[*Block](),
		BlockConfirmed: event.New1[*Block](),
		SlotClosed:     event.New1[*shrinkingmap.ShrinkingMap[models.BlockID, *Block]](),
		Error:          event.New1[error](),
	}
})

NewEvents contains the constructor of the Events object (it is generated by a generic factory).

Functions

func WithAccepted

func WithAccepted(accepted bool) options.Option[Block]

func WithConfirmed

func WithConfirmed(confirmed bool) options.Option[Block]

func WithQueued

func WithQueued(queued bool) options.Option[Block]

Types

type Block

type Block struct {
	*booker.Block
	// contains filtered or unexported fields
}

Block represents a Block annotated with OTV related metadata.

func NewBlock

func NewBlock(virtualVotingBlock *booker.Block, opts ...options.Option[Block]) (newBlock *Block)

NewBlock creates a new Block with the given options.

func NewRootBlock

func NewRootBlock(blockID models.BlockID, slotTimeProvider *slot.TimeProvider) *Block

func (*Block) IsAcceptanceQueued

func (b *Block) IsAcceptanceQueued() bool

func (*Block) IsAccepted

func (b *Block) IsAccepted() bool

IsAccepted returns true if the Block was accepted.

func (*Block) IsConfirmationQueued

func (b *Block) IsConfirmationQueued() bool

func (*Block) IsConfirmed

func (b *Block) IsConfirmed() bool

func (*Block) IsStronglyAccepted

func (b *Block) IsStronglyAccepted() bool

IsStronglyAccepted returns true if the Block was accepted through strong children.

func (*Block) IsStronglyConfirmed

func (b *Block) IsStronglyConfirmed() bool

func (*Block) SetAcceptanceQueued

func (b *Block) SetAcceptanceQueued() (wasUpdated bool)

func (*Block) SetAccepted

func (b *Block) SetAccepted(weakly bool) (wasUpdated bool)

SetAccepted sets the Block as accepted.

func (*Block) SetConfirmationQueued

func (b *Block) SetConfirmationQueued() (wasUpdated bool)

func (*Block) SetConfirmed

func (b *Block) SetConfirmed(weakly bool) (wasUpdated bool)

type Events

type Events struct {
	BlockAccepted  *event.Event1[*Block]
	BlockConfirmed *event.Event1[*Block]
	SlotClosed     *event.Event1[*shrinkingmap.ShrinkingMap[models.BlockID, *Block]]
	Error          *event.Event1[error]

	event.Group[Events, *Events]
}

type Gadget

type Gadget interface {
	Events() *Events

	// IsBlockAccepted returns whether the given block is accepted.
	IsBlockAccepted(blockID models.BlockID) (accepted bool)

	IsBlockConfirmed(blockID models.BlockID) bool

	// IsMarkerAccepted returns whether the given marker is accepted.
	IsMarkerAccepted(marker markers.Marker) (accepted bool)

	FirstUnacceptedIndex(sequenceID markers.SequenceID) (firstUnacceptedIndex markers.Index)

	module.Interface
}

type MockBlockGadget

type MockBlockGadget struct {
	AcceptedBlocks  models.BlockIDs
	AcceptedMarkers *markers.Markers

	module.Module
	// contains filtered or unexported fields
}

MockBlockGadget mocks a block gadget marking all blocks as confirmed.

func NewMockAcceptanceGadget

func NewMockAcceptanceGadget() *MockBlockGadget

func (*MockBlockGadget) AcceptedBlocksInSlot

func (m *MockBlockGadget) AcceptedBlocksInSlot(index slot.Index) (blocks models.BlockIDs)

func (*MockBlockGadget) Events

func (m *MockBlockGadget) Events() *Events

func (*MockBlockGadget) FirstUnacceptedIndex

func (m *MockBlockGadget) FirstUnacceptedIndex(sequenceID markers.SequenceID) (firstUnacceptedIndex markers.Index)

func (*MockBlockGadget) IsBlockAccepted

func (m *MockBlockGadget) IsBlockAccepted(blockID models.BlockID) bool

IsBlockAccepted mocks its interface function returning that all blocks are confirmed.

func (*MockBlockGadget) IsBlockConfirmed

func (m *MockBlockGadget) IsBlockConfirmed(blockID models.BlockID) bool

func (*MockBlockGadget) IsMarkerAccepted

func (m *MockBlockGadget) IsMarkerAccepted(marker markers.Marker) (accepted bool)

func (*MockBlockGadget) SetBlockAccepted

func (m *MockBlockGadget) SetBlockAccepted(block *Block)

func (*MockBlockGadget) SetMarkersAccepted

func (m *MockBlockGadget) SetMarkersAccepted(markers ...markers.Marker)

type TestFramework

type TestFramework struct {
	Gadget        Gadget
	Mesh          *mesh.TestFramework
	VirtualVoting *booker.VirtualVotingTestFramework
	MemPool       *mempool.TestFramework
	BlockDAG      *blockdag.TestFramework
	Votes         *votes.TestFramework
	// contains filtered or unexported fields
}

func NewTestFramework

func NewTestFramework(test *testing.T, gadget Gadget, meshTF *mesh.TestFramework) *TestFramework

func (*TestFramework) AssertBlockAccepted

func (t *TestFramework) AssertBlockAccepted(blocksAccepted uint32)

func (*TestFramework) AssertBlockConfirmed

func (t *TestFramework) AssertBlockConfirmed(blocksConfirmed uint32)

func (*TestFramework) AssertConflictsAccepted

func (t *TestFramework) AssertConflictsAccepted(conflictsAccepted uint32)

func (*TestFramework) AssertConflictsRejected

func (t *TestFramework) AssertConflictsRejected(conflictsRejected uint32)

func (*TestFramework) ValidateAcceptedBlocks

func (t *TestFramework) ValidateAcceptedBlocks(expectedAcceptedBlocks map[string]bool)

func (*TestFramework) ValidateAcceptedMarker

func (t *TestFramework) ValidateAcceptedMarker(expectedConflictIDs map[markers.Marker]bool)

func (*TestFramework) ValidateConfirmedBlocks

func (t *TestFramework) ValidateConfirmedBlocks(expectedConfirmedBlocks map[string]bool)

func (*TestFramework) ValidateConflictAcceptance

func (t *TestFramework) ValidateConflictAcceptance(expectedConflictIDs map[string]confirmation.State)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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