From 07c98dcea9728bba1876d32c55eb902a3b65254c Mon Sep 17 00:00:00 2001 From: Andrea V <1577639+karimodm@users.noreply.github.com> Date: Thu, 5 Oct 2023 11:04:32 +0200 Subject: [PATCH] Moar renames --- .../engine/mempool/v1/inclusion_flags.go | 24 +++++++++---------- pkg/protocol/engine/mempool/v1/mempool.go | 2 +- .../engine/mempool/v1/state_metadata.go | 4 ++-- .../engine/mempool/v1/transaction_metadata.go | 8 +++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/pkg/protocol/engine/mempool/v1/inclusion_flags.go b/pkg/protocol/engine/mempool/v1/inclusion_flags.go index ce4225556..3b8213690 100644 --- a/pkg/protocol/engine/mempool/v1/inclusion_flags.go +++ b/pkg/protocol/engine/mempool/v1/inclusion_flags.go @@ -11,24 +11,24 @@ type inclusionFlags struct { // accepted gets triggered when the entity gets marked as accepted. accepted reactive.Variable[bool] - // committedOnSlot gets set to the slot in which the entity gets marked as committed. - committedOnSlot reactive.Variable[iotago.SlotIndex] + // committedSlot gets set to the slot in which the entity gets marked as committed. + committedSlot reactive.Variable[iotago.SlotIndex] // rejected gets triggered when the entity gets marked as rejected. rejected *promise.Event - // orphanedOnSlot gets set to the slot in which the entity gets marked as orphaned. - orphanedOnSlot reactive.Variable[iotago.SlotIndex] + // orphanedSlot gets set to the slot in which the entity gets marked as orphaned. + orphanedSlot reactive.Variable[iotago.SlotIndex] } // newInclusionFlags creates a new inclusionFlags instance. func newInclusionFlags() *inclusionFlags { return &inclusionFlags{ - accepted: reactive.NewVariable[bool](), - committedOnSlot: reactive.NewVariable[iotago.SlotIndex](), - rejected: promise.NewEvent(), + accepted: reactive.NewVariable[bool](), + committedSlot: reactive.NewVariable[iotago.SlotIndex](), + rejected: promise.NewEvent(), // Make sure the oldest orphaned index doesn't get overridden by newer TX spending the orphaned conflict further. - orphanedOnSlot: reactive.NewVariable[iotago.SlotIndex](func(currentValue, newValue iotago.SlotIndex) iotago.SlotIndex { + orphanedSlot: reactive.NewVariable[iotago.SlotIndex](func(currentValue, newValue iotago.SlotIndex) iotago.SlotIndex { if currentValue != 0 { return currentValue } @@ -77,24 +77,24 @@ func (s *inclusionFlags) OnRejected(callback func()) { // IsCommitted returns true if the entity was committed. func (s *inclusionFlags) CommittedSlot() (slot iotago.SlotIndex, isCommitted bool) { - return s.committedOnSlot.Get(), s.committedOnSlot.Get() != 0 + return s.committedSlot.Get(), s.committedSlot.Get() != 0 } // OnCommitted registers a callback that gets triggered when the entity gets committed. func (s *inclusionFlags) OnCommittedSlotUpdated(callback func(slot iotago.SlotIndex)) { - s.committedOnSlot.OnUpdate(func(_, newValue iotago.SlotIndex) { + s.committedSlot.OnUpdate(func(_, newValue iotago.SlotIndex) { callback(newValue) }) } // IsOrphaned returns true if the entity was orphaned. func (s *inclusionFlags) OrphanedSlot() (slot iotago.SlotIndex, isOrphaned bool) { - return s.orphanedOnSlot.Get(), s.orphanedOnSlot.Get() != 0 + return s.orphanedSlot.Get(), s.orphanedSlot.Get() != 0 } // OnOrphaned registers a callback that gets triggered when the entity gets orphaned. func (s *inclusionFlags) OnOrphanedSlotUpdated(callback func(slot iotago.SlotIndex)) { - s.orphanedOnSlot.OnUpdate(func(_, newValue iotago.SlotIndex) { + s.orphanedSlot.OnUpdate(func(_, newValue iotago.SlotIndex) { callback(newValue) }) } diff --git a/pkg/protocol/engine/mempool/v1/mempool.go b/pkg/protocol/engine/mempool/v1/mempool.go index 2345b4707..4f1905cd1 100644 --- a/pkg/protocol/engine/mempool/v1/mempool.go +++ b/pkg/protocol/engine/mempool/v1/mempool.go @@ -331,7 +331,7 @@ func (m *MemPool[VoteRank]) forkTransaction(transactionMetadata *TransactionMeta if err := m.conflictDAG.UpdateConflictingResources(transactionMetadata.ID(), resourceIDs); err != nil { // this is a hack, as with a reactive.Variable we cannot set it to 0 and still check if it was orphaned. - transactionMetadata.orphanedOnSlot.Set(1) + transactionMetadata.orphanedSlot.Set(1) m.errorHandler(err) } diff --git a/pkg/protocol/engine/mempool/v1/state_metadata.go b/pkg/protocol/engine/mempool/v1/state_metadata.go index a5933f284..80b30f3de 100644 --- a/pkg/protocol/engine/mempool/v1/state_metadata.go +++ b/pkg/protocol/engine/mempool/v1/state_metadata.go @@ -54,8 +54,8 @@ func (s *StateMetadata) setup(optSource ...*TransactionMetadata) *StateMetadata source.OnPending(func() { s.accepted.Set(false) }) source.OnAccepted(func() { s.accepted.Set(true) }) source.OnRejected(func() { s.rejected.Trigger() }) - source.OnCommittedSlotUpdated(lo.Void(s.committedOnSlot.Set)) - source.OnOrphanedSlotUpdated(lo.Void(s.orphanedOnSlot.Set)) + source.OnCommittedSlotUpdated(lo.Void(s.committedSlot.Set)) + source.OnOrphanedSlotUpdated(lo.Void(s.orphanedSlot.Set)) return s } diff --git a/pkg/protocol/engine/mempool/v1/transaction_metadata.go b/pkg/protocol/engine/mempool/v1/transaction_metadata.go index 01348df86..a976dcf92 100644 --- a/pkg/protocol/engine/mempool/v1/transaction_metadata.go +++ b/pkg/protocol/engine/mempool/v1/transaction_metadata.go @@ -215,7 +215,7 @@ func (t *TransactionMetadata) markInputSolid() (allInputsSolid bool) { } func (t *TransactionMetadata) Commit() { - t.committedOnSlot.Set(t.earliestIncludedValidAttachment.Get().Slot()) + t.committedSlot.Set(t.earliestIncludedValidAttachment.Get().Slot()) } func (t *TransactionMetadata) IsConflicting() bool { @@ -251,7 +251,7 @@ func (t *TransactionMetadata) setupInput(input *StateMetadata) { input.OnRejected(func() { t.rejected.Trigger() }) input.OnOrphanedSlotUpdated(func(slot iotago.SlotIndex) { - t.orphanedOnSlot.Set(slot) + t.orphanedSlot.Set(slot) }) input.OnAccepted(func() { if atomic.AddUint64(&t.unacceptedInputsCount, ^uint64(0)) == 0 { @@ -279,7 +279,7 @@ func (t *TransactionMetadata) setupInput(input *StateMetadata) { input.OnSpendCommitted(func(spender mempool.TransactionMetadata) { if spender != t { spender.OnCommittedSlotUpdated(func(slot iotago.SlotIndex) { - t.orphanedOnSlot.Set(slot) + t.orphanedSlot.Set(slot) }) } }) @@ -296,7 +296,7 @@ func (t *TransactionMetadata) setup() (self *TransactionMetadata) { t.allValidAttachmentsEvicted.OnUpdate(func(_, slot iotago.SlotIndex) { if !lo.Return2(t.CommittedSlot()) { - t.orphanedOnSlot.Set(slot) + t.orphanedSlot.Set(slot) } })