From fc0da15da695ca399a3790052f8c7d6c74706d16 Mon Sep 17 00:00:00 2001 From: Hans Moog <3293976+hmoog@users.noreply.github.com> Date: Sat, 28 Oct 2023 02:22:21 +0200 Subject: [PATCH] Feat: addressed more linter warnings --- pkg/protocol/chain.go | 12 ------------ pkg/protocol/chain_manager.go | 7 ++++--- pkg/protocol/commitment_verifier.go | 2 +- pkg/protocol/protocol_warp_sync.go | 2 +- 4 files changed, 6 insertions(+), 17 deletions(-) diff --git a/pkg/protocol/chain.go b/pkg/protocol/chain.go index 01690a697..8d13709f3 100644 --- a/pkg/protocol/chain.go +++ b/pkg/protocol/chain.go @@ -226,18 +226,6 @@ func (c *Chain) DispatchBlock(block *model.Block, src peer.ID) (success bool) { return success } -func (c *Chain) earliestUncommittedSlot() iotago.SlotIndex { - if latestVerifiedCommitment := c.LatestVerifiedCommitment.Get(); latestVerifiedCommitment != nil { - return latestVerifiedCommitment.Slot() + 1 - } - - if forkingPoint := c.ForkingPoint.Get(); forkingPoint != nil { - return forkingPoint.Slot() - } - - return 0 -} - func (c *Chain) InSyncRange(slot iotago.SlotIndex) bool { if latestVerifiedCommitment := c.LatestVerifiedCommitment.Get(); latestVerifiedCommitment != nil { return slot > latestVerifiedCommitment.Slot() && slot < c.SyncThreshold.Get() diff --git a/pkg/protocol/chain_manager.go b/pkg/protocol/chain_manager.go index 4eef9391d..5910232ab 100644 --- a/pkg/protocol/chain_manager.go +++ b/pkg/protocol/chain_manager.go @@ -262,11 +262,12 @@ func (c *ChainManager) publishEngineCommitments(chain *Chain) { return engine.LatestCommitment.OnUpdate(func(_, latestCommitment *model.Commitment) { for latestPublishedSlot < latestCommitment.Slot() { - if commitmentToPublish, err := engine.Storage.Commitments().Load(latestPublishedSlot + 1); err != nil { + commitmentToPublish, err := engine.Storage.Commitments().Load(latestPublishedSlot + 1) + if err != nil { panic(err) // this should never happen, but we panic to get a stack trace if it does - } else { - publishCommitment(commitmentToPublish) } + + publishCommitment(commitmentToPublish) } }) }) diff --git a/pkg/protocol/commitment_verifier.go b/pkg/protocol/commitment_verifier.go index 2fa667638..8e49f4c42 100644 --- a/pkg/protocol/commitment_verifier.go +++ b/pkg/protocol/commitment_verifier.go @@ -37,7 +37,7 @@ func (c *CommitmentVerifier) verifyCommitment(commitment *Commitment, attestatio } } - if !iotago.VerifyProof(merkleProof, iotago.Identifier(tree.Root()), commitment.RootsID()) { + if !iotago.VerifyProof(merkleProof, tree.Root(), commitment.RootsID()) { return nil, 0, ierrors.Errorf("invalid merkle proof for attestations for commitment %s", commitment.ID()) } diff --git a/pkg/protocol/protocol_warp_sync.go b/pkg/protocol/protocol_warp_sync.go index 9c81c07db..6a2d8dbbd 100644 --- a/pkg/protocol/protocol_warp_sync.go +++ b/pkg/protocol/protocol_warp_sync.go @@ -110,7 +110,7 @@ func (w *WarpSyncProtocol) ProcessResponse(commitmentID iotago.CommitmentID, blo _ = acceptedTransactionIDs.Add(transactionID) // a mapdb can never return an error } - if !iotago.VerifyProof(mutationProof, iotago.Identifier(acceptedTransactionIDs.Root()), commitment.RootsID()) { + if !iotago.VerifyProof(mutationProof, acceptedTransactionIDs.Root(), commitment.RootsID()) { w.LogError("failed to verify mutations proof", "commitment", commitment.LogName(), "transactionIDs", transactionIDs, "proof", mutationProof, "fromPeer", from) return false