slotnotarization

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: Apache-2.0, BSD-2-Clause Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrefixAttestations byte = iota
	PrefixAttestationsLastCommittedSlot
	PrefixAttestationsWeight
)

Variables

This section is empty.

Functions

func WithMinCommittableSlotAge

func WithMinCommittableSlotAge(age slot.Index) options.Option[Manager]

WithMinCommittableSlotAge specifies how old a slot has to be for it to be committable.

Types

type Attestations

type Attestations struct {
	traits.Committable
	module.Module
	// contains filtered or unexported fields
}

func NewAttestations

func NewAttestations(persistentStorage func(optRealm ...byte) kvstore.KVStore, bucketedStorage func(index slot.Index) kvstore.KVStore, weightsProviderFunc func() *sybilprotection.Weights, slotTimeProviderFunc func() *slot.TimeProvider) *Attestations

func (*Attestations) Add

func (a *Attestations) Add(attestation *notarization.Attestation) (added bool, err error)

func (*Attestations) Commit

func (a *Attestations) Commit(index slot.Index) (attestations *ads.Map[identity.ID, notarization.Attestation, *identity.ID, *notarization.Attestation], weight int64, err error)

func (*Attestations) Delete

func (a *Attestations) Delete(attestation *notarization.Attestation) (deleted bool, err error)

func (*Attestations) Export

func (a *Attestations) Export(writer io.WriteSeeker, targetSlot slot.Index) (err error)

func (*Attestations) Get

func (*Attestations) Import

func (a *Attestations) Import(reader io.ReadSeeker) (err error)

func (*Attestations) Weight

func (a *Attestations) Weight(index slot.Index) (weight int64, err error)

type Manager

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

Manager is the component that manages the slot commitments.

func (*Manager) Attestations

func (m *Manager) Attestations() notarization.Attestations

func (*Manager) Events

func (m *Manager) Events() *notarization.Events

func (*Manager) Export

func (m *Manager) Export(writer io.WriteSeeker, targetSlot slot.Index) (err error)

func (*Manager) Import

func (m *Manager) Import(reader io.ReadSeeker) (err error)

func (*Manager) IsFullyCommitted

func (m *Manager) IsFullyCommitted() bool

IsFullyCommitted returns if the Manager finished committing all pending slots up to the current acceptance time.

func (*Manager) MinCommittableSlotAge

func (m *Manager) MinCommittableSlotAge() slot.Index

MinCommittableSlotAge returns the minimum age of a slot to be committable.

func (*Manager) NotarizeAcceptedBlock

func (m *Manager) NotarizeAcceptedBlock(block *models.Block) (err error)

func (*Manager) NotarizeOrphanedBlock

func (m *Manager) NotarizeOrphanedBlock(block *models.Block) (err error)

func (*Manager) PerformLocked

func (m *Manager) PerformLocked(perform func(m notarization.Notarization))

func (*Manager) TryCommitUntil

func (m *Manager) TryCommitUntil(acceptanceTime time.Time)

TryCommitUntil tries to create slot commitments until the new provided acceptance time.

type SlotMutations

type SlotMutations struct {
	AcceptedBlockRemoved *event.Event1[models.BlockID]
	// contains filtered or unexported fields
}

SlotMutations is an in-memory data structure that enables the collection of mutations for uncommitted slots.

func NewSlotMutations

func NewSlotMutations(weights *sybilprotection.Weights, lastCommittedSlot slot.Index) (newMutationFactory *SlotMutations)

NewSlotMutations creates a new SlotMutations instance.

func (*SlotMutations) AddAcceptedBlock

func (m *SlotMutations) AddAcceptedBlock(block *models.Block) (err error)

AddAcceptedBlock adds the given block to the set of accepted blocks.

func (*SlotMutations) AddAcceptedTransaction

func (m *SlotMutations) AddAcceptedTransaction(metadata *mempool.TransactionMetadata) (err error)

AddAcceptedTransaction adds the given transaction to the set of accepted transactions.

func (*SlotMutations) Evict

func (m *SlotMutations) Evict(index slot.Index) (acceptedBlocks *ads.Set[models.BlockID, *models.BlockID], acceptedTransactions *ads.Set[utxo.TransactionID, *utxo.TransactionID], err error)

Evict evicts the given slot and returns the corresponding mutation sets.

func (*SlotMutations) RemoveAcceptedBlock

func (m *SlotMutations) RemoveAcceptedBlock(block *models.Block) (err error)

RemoveAcceptedBlock removes the given block from the set of accepted blocks.

func (*SlotMutations) RemoveAcceptedTransaction

func (m *SlotMutations) RemoveAcceptedTransaction(metadata *mempool.TransactionMetadata) (err error)

RemoveAcceptedTransaction removes the given transaction from the set of accepted transactions.

func (*SlotMutations) Reset

func (m *SlotMutations) Reset(index slot.Index)

func (*SlotMutations) UpdateTransactionInclusion

func (m *SlotMutations) UpdateTransactionInclusion(txID utxo.TransactionID, oldSlot, newSlot slot.Index) (err error)

UpdateTransactionInclusion moves a transaction from a later slot to the given slot.

type TestFramework

type TestFramework struct {
	MutationFactory *SlotMutations

	syncutils.RWMutexFake
	// contains filtered or unexported fields
}

func NewTestFramework

func NewTestFramework(test *testing.T, slotTimeProvider *slot.TimeProvider) *TestFramework

func (*TestFramework) AddAcceptedBlock

func (t *TestFramework) AddAcceptedBlock(alias string) (err error)

func (*TestFramework) AddAcceptedTransaction

func (t *TestFramework) AddAcceptedTransaction(alias string) (err error)

func (*TestFramework) AssertCommit

func (t *TestFramework) AssertCommit(index slot.Index, expectedBlocks []string, expectedTransactions []string, expectedValidators []string, expectedCumulativeWeight int64, optShouldError ...bool)

func (*TestFramework) Block

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

func (*TestFramework) CreateBlock

func (t *TestFramework) CreateBlock(alias string, index slot.Index, blockOpts ...options.Option[models.Block]) (block *models.Block)

func (*TestFramework) CreateIssuer

func (t *TestFramework) CreateIssuer(alias string, issuerWeight ...int64) (issuer ed25519.PublicKey)

func (*TestFramework) CreateTransaction

func (t *TestFramework) CreateTransaction(alias string, index slot.Index) (metadata *mempool.TransactionMetadata)

func (*TestFramework) Issuer

func (t *TestFramework) Issuer(alias string) (issuer ed25519.PublicKey)

func (*TestFramework) RemoveAcceptedBlock

func (t *TestFramework) RemoveAcceptedBlock(alias string) (err error)

func (*TestFramework) RemoveAcceptedTransaction

func (t *TestFramework) RemoveAcceptedTransaction(alias string) (err error)

func (*TestFramework) Transaction

func (t *TestFramework) Transaction(alias string) *mempool.TransactionMetadata

func (*TestFramework) UpdateTransactionInclusion

func (t *TestFramework) UpdateTransactionInclusion(alias string, oldSlot, newSlot slot.Index) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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