booker

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: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewEvents = event.CreateGroupConstructor(func() (newEvents *Events) {
	return &Events{
		BlockBooked:         event.New1[*BlockBookedEvent](),
		AttachmentCreated:   event.New1[*Block](),
		AttachmentOrphaned:  event.New1[*Block](),
		BlockConflictAdded:  event.New1[*BlockConflictAddedEvent](),
		MarkerConflictAdded: event.New1[*MarkerConflictAddedEvent](),
		Error:               event.New1[error](),

		BlockTracked:    event.New1[*Block](),
		SequenceEvicted: event.New1[markers.SequenceID](),
		VirtualVoting:   NewVirtualVotingEvents(),
		SequenceTracker: sequencetracker.NewEvents(),
		SlotTracker:     slottracker.NewEvents(),
	}
})

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

View Source
var NewVirtualVotingEvents = event.CreateGroupConstructor(func() (newEvents *VirtualVotingEvents) {
	return &VirtualVotingEvents{
		ConflictTracker: conflicttracker.NewEvents[utxo.TransactionID](),
	}
})

NewVirtualVotingEvents contains the constructor of the VirtualVotingEvents object (it is generated by a generic factory).

Functions

func WithBooked

func WithBooked(missing bool) options.Option[Block]

WithBooked is a constructor Option for Blocks that initializes the given block with a specific missing flag.

func WithStructureDetails

func WithStructureDetails(structureDetails *markers.StructureDetails) options.Option[Block]

WithStructureDetails is a constructor Option for Blocks that initializes the given block with a specific structure details.

Types

type Block

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

func NewBlock

func NewBlock(block *blockdag.Block, opts ...options.Option[Block]) (newBlock *Block)

func NewRootBlock

func NewRootBlock(id models.BlockID, slotTimeProvider *slot.TimeProvider, opts ...options.Option[models.Block]) *Block

func (*Block) AddAllAddedConflictIDs

func (b *Block) AddAllAddedConflictIDs(addedConflictIDs utxo.TransactionIDs)

func (*Block) AddAllSubtractedConflictIDs

func (b *Block) AddAllSubtractedConflictIDs(subtractedConflictIDs utxo.TransactionIDs)

func (*Block) AddConflictID

func (b *Block) AddConflictID(conflictID utxo.TransactionID) (modified bool)

AddConflictID sets the ConflictIDs of the added Conflicts.

func (*Block) AddedConflictIDs

func (b *Block) AddedConflictIDs() utxo.TransactionIDs

AddedConflictIDs returns the ConflictIDs of the added Conflicts of the Block.

func (*Block) IsBooked

func (b *Block) IsBooked() (isBooked bool)

func (*Block) IsSubjectivelyInvalid

func (b *Block) IsSubjectivelyInvalid() bool

func (*Block) SetBooked

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

func (*Block) SetStructureDetails

func (b *Block) SetStructureDetails(structureDetails *markers.StructureDetails)

func (*Block) SetSubjectivelyInvalid

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

func (*Block) String

func (b *Block) String() string

func (*Block) StructureDetails

func (b *Block) StructureDetails() *markers.StructureDetails

func (*Block) SubtractedConflictIDs

func (b *Block) SubtractedConflictIDs() utxo.TransactionIDs

SubtractedConflictIDs returns the ConflictIDs of the subtracted Conflicts of the Block.

func (*Block) Transaction

func (b *Block) Transaction() (tx utxo.Transaction, isTransaction bool)

type BlockBookedEvent

type BlockBookedEvent struct {
	Block       *Block
	ConflictIDs utxo.TransactionIDs
}

type BlockConflictAddedEvent

type BlockConflictAddedEvent struct {
	Block             *Block
	ConflictID        utxo.TransactionID
	ParentConflictIDs utxo.TransactionIDs
}

type BlockVotePower

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

func NewBlockVotePower

func NewBlockVotePower(id models.BlockID, time time.Time) BlockVotePower

func (BlockVotePower) Compare

func (v BlockVotePower) Compare(other BlockVotePower) int

type Blocks

type Blocks = *advancedset.AdvancedSet[*Block]

Blocks represents a collection of Block.

func NewBlocks

func NewBlocks(blocks ...*Block) (newBlocks Blocks)

NewBlocks returns a new Block collection with the given elements.

type Booker

type Booker interface {
	Events() *Events

	VirtualVoting() VirtualVoting

	// Block retrieves a Block with metadata from the in-memory storage of the Booker.
	Block(id models.BlockID) (block *Block, exists bool)

	// BlockCeiling returns the smallest Index that is >= the given Marker and a boolean value indicating if it exists.
	BlockCeiling(marker markers.Marker) (ceilingMarker markers.Marker, exists bool)

	// BlockFromMarker retrieves the Block of the given Marker.
	BlockFromMarker(marker markers.Marker) (block *Block, exists bool)

	// BlockConflicts returns the Conflict related details of the given Block.
	BlockConflicts(block *Block) (blockConflictIDs utxo.TransactionIDs)

	// BlockBookingDetails returns the Conflict and Marker related details of the given Block.
	BlockBookingDetails(block *Block) (pastMarkersConflictIDs, blockConflictIDs utxo.TransactionIDs)

	// TransactionConflictIDs returns the ConflictIDs of the Transaction contained in the given Block including conflicts from the UTXO past cone.
	TransactionConflictIDs(block *Block) (conflictIDs utxo.TransactionIDs)

	// GetEarliestAttachment returns the earliest attachment for a given transaction ID.
	// returnOrphaned parameter specifies whether the returned attachment may be orphaned.
	GetEarliestAttachment(txID utxo.TransactionID) (attachment *Block)

	// GetLatestAttachment returns the latest attachment for a given transaction ID.
	// returnOrphaned parameter specifies whether the returned attachment may be orphaned.
	GetLatestAttachment(txID utxo.TransactionID) (attachment *Block)

	SequenceManager() *markers.SequenceManager

	SequenceTracker() *sequencetracker.SequenceTracker[BlockVotePower]

	// MarkerVotersTotalWeight retrieves Validators supporting a given marker.
	MarkerVotersTotalWeight(marker markers.Marker) (totalWeight int64)

	// SlotVotersTotalWeight retrieves the total weight of the Validators voting for a given slot.
	SlotVotersTotalWeight(slotIndex slot.Index) (totalWeight int64)

	GetAllAttachments(txID utxo.TransactionID) (attachments *advancedset.AdvancedSet[*Block])

	module.Interface
}

type Events

type Events struct {
	BlockBooked         *event.Event1[*BlockBookedEvent]
	AttachmentCreated   *event.Event1[*Block]
	AttachmentOrphaned  *event.Event1[*Block]
	BlockConflictAdded  *event.Event1[*BlockConflictAddedEvent]
	MarkerConflictAdded *event.Event1[*MarkerConflictAddedEvent]
	Error               *event.Event1[error]

	SequenceEvicted *event.Event1[markers.SequenceID]

	BlockTracked    *event.Event1[*Block]
	VirtualVoting   *VirtualVotingEvents
	SequenceTracker *sequencetracker.Events
	SlotTracker     *slottracker.Events

	event.Group[Events, *Events]
}

type MarkerConflictAddedEvent

type MarkerConflictAddedEvent struct {
	Marker            markers.Marker
	ConflictID        utxo.TransactionID
	ParentConflictIDs utxo.TransactionIDs
}

type TestFramework

type TestFramework struct {
	Test            *testing.T
	Workers         *workerpool.Group
	Instance        Booker
	Ledger          *mempool.TestFramework
	BlockDAG        *blockdag.TestFramework
	ConflictDAG     *conflictdag.TestFramework
	VirtualVoting   *VirtualVotingTestFramework
	SequenceTracker *sequencetracker.TestFramework[BlockVotePower]
	Votes           *votes.TestFramework
	// contains filtered or unexported fields
}

func NewTestFramework

func NewTestFramework(test *testing.T, workers *workerpool.Group, instance Booker, blockDAG blockdag.BlockDAG, memPool mempool.MemPool, validators *sybilprotection.WeightedSet, slotTimeProviderFunc func() *slot.TimeProvider) *TestFramework

func (*TestFramework) AssertBlock

func (t *TestFramework) AssertBlock(alias string, callback func(block *Block))

func (*TestFramework) AssertBlockConflictsUpdateCount

func (t *TestFramework) AssertBlockConflictsUpdateCount(blockConflictsUpdateCount int32, msgAndArgs ...interface{})

func (*TestFramework) AssertBlockTracked

func (t *TestFramework) AssertBlockTracked(blocksTracked uint32)

func (*TestFramework) AssertBooked

func (t *TestFramework) AssertBooked(expectedValues map[string]bool)

func (*TestFramework) AssertBookedCount

func (t *TestFramework) AssertBookedCount(bookedCount int32, msgAndArgs ...interface{})

func (*TestFramework) AssertMarkerConflictsAddCount

func (t *TestFramework) AssertMarkerConflictsAddCount(markerConflictsAddCount int32, msgAndArgs ...interface{})

func (*TestFramework) Block

func (t *TestFramework) Block(alias string) (block *Block)

Block retrieves the Blocks that is associated with the given alias.

func (*TestFramework) CheckBlockMetadataDiffConflictIDs

func (t *TestFramework) CheckBlockMetadataDiffConflictIDs(expectedDiffConflictIDs map[string][]utxo.TransactionIDs)

func (*TestFramework) CheckConflictIDs

func (t *TestFramework) CheckConflictIDs(expectedConflictIDs map[string]utxo.TransactionIDs)

func (*TestFramework) CheckMarkers

func (t *TestFramework) CheckMarkers(expectedMarkers map[string]*markers.Markers)

func (*TestFramework) CheckNormalizedConflictIDsContained

func (t *TestFramework) CheckNormalizedConflictIDsContained(expectedContainedConflictIDs map[string]utxo.TransactionIDs)

func (*TestFramework) ValidateMarkerVoters

func (t *TestFramework) ValidateMarkerVoters(expectedVoters map[markers.Marker]*advancedset.AdvancedSet[identity.ID])

type VirtualVoting

type VirtualVoting interface {
	Events() *VirtualVotingEvents

	ConflictTracker() *conflicttracker.ConflictTracker[utxo.TransactionID, utxo.OutputID, BlockVotePower]

	// ConflictVotersTotalWeight retrieves the total weight of the Validators voting for a given conflict.
	ConflictVotersTotalWeight(conflictID utxo.TransactionID) (totalWeight int64)

	// ConflictVoters retrieves Validators voting for a given conflict.
	ConflictVoters(conflictID utxo.TransactionID) (voters *sybilprotection.WeightedSet)
}

type VirtualVotingEvents

type VirtualVotingEvents struct {
	ConflictTracker *conflicttracker.Events[utxo.TransactionID]
	event.Group[VirtualVotingEvents, *VirtualVotingEvents]
}

type VirtualVotingTestFramework

type VirtualVotingTestFramework struct {
	Instance VirtualVoting

	ConflictDAG     *conflictdag.TestFramework
	Votes           *votes.TestFramework
	ConflictTracker *conflicttracker.TestFramework[BlockVotePower]
	// contains filtered or unexported fields
}

func NewVirtualVotingTestFramework

func NewVirtualVotingTestFramework(test *testing.T, virtualVotingInstance VirtualVoting, memPool mempool.MemPool, validators *sybilprotection.WeightedSet) *VirtualVotingTestFramework

func (*VirtualVotingTestFramework) CreateIdentity

func (t *VirtualVotingTestFramework) CreateIdentity(alias string, weight int64, skipWeightUpdate ...bool)

func (*VirtualVotingTestFramework) Identities

func (t *VirtualVotingTestFramework) Identities(aliases ...string) (identities *advancedset.AdvancedSet[*identity.Identity])

func (*VirtualVotingTestFramework) Identity

func (t *VirtualVotingTestFramework) Identity(alias string) (v *identity.Identity)

func (*VirtualVotingTestFramework) RegisterIdentity

func (t *VirtualVotingTestFramework) RegisterIdentity(alias string, id *identity.Identity)

func (*VirtualVotingTestFramework) ValidateConflictVoters

func (t *VirtualVotingTestFramework) ValidateConflictVoters(expectedVoters map[utxo.TransactionID]*advancedset.AdvancedSet[identity.ID])

func (*VirtualVotingTestFramework) ValidatorsSet

func (t *VirtualVotingTestFramework) ValidatorsSet(aliases ...string) (validators *advancedset.AdvancedSet[identity.ID])

func (*VirtualVotingTestFramework) ValidatorsWithWeights

func (t *VirtualVotingTestFramework) ValidatorsWithWeights(aliases ...string) map[identity.ID]uint64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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