From 35d32b06e85b866354c5b375c7055859f8c452f4 Mon Sep 17 00:00:00 2001 From: John Jannotti Date: Thu, 5 Dec 2024 13:09:12 -0500 Subject: [PATCH] code review --- data/transactions/heartbeat.go | 8 ++++---- ledger/apply/challenge.go | 2 +- ledger/apply/heartbeat.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/data/transactions/heartbeat.go b/data/transactions/heartbeat.go index 48a4df6c69..5a36343339 100644 --- a/data/transactions/heartbeat.go +++ b/data/transactions/heartbeat.go @@ -34,9 +34,9 @@ type HeartbeatTxnFields struct { // HbProof is a signature using HeartbeatAddress's partkey, thereby showing it is online. HbProof crypto.HeartbeatProof `codec:"hbprf"` - // HbSeed must be the block seed for the block before this transaction's - // firstValid. It is supplied in the transaction so that Proof can be - // checked at submit time without a ledger lookup, and must be checked at - // evaluation time for equality with the actual blockseed. + // HbSeed must be the block seed for the this transaction's firstValid + // block. It is supplied in the transaction so that Proof can be checked at + // submit time without a ledger lookup, and must be checked at evaluation + // time for equality with the actual blockseed. HbSeed committee.Seed `codec:"hbsd"` } diff --git a/ledger/apply/challenge.go b/ledger/apply/challenge.go index fa060879e6..6dc5fb1a2b 100644 --- a/ledger/apply/challenge.go +++ b/ledger/apply/challenge.go @@ -72,7 +72,7 @@ func FindChallenge(rules config.ProposerPayoutRules, current basics.Round, heade } challengeHdr, err := headers.BlockHdr(lastChallenge) if err != nil { - panic(err) + return challenge{} } challengeProto := config.Consensus[challengeHdr.CurrentProtocol] // challenge is not considered if rules have changed since that round diff --git a/ledger/apply/heartbeat.go b/ledger/apply/heartbeat.go index ec6bc3a768..806c79e2cf 100644 --- a/ledger/apply/heartbeat.go +++ b/ledger/apply/heartbeat.go @@ -62,7 +62,7 @@ func Heartbeat(hb transactions.HeartbeatTxnFields, header transactions.Header, b return fmt.Errorf("%s heartbeat is not allowed when not IncentiveEligible %+v", kind, hb.HbAddress) } ch := FindChallenge(proto.Payouts, round, provider, ChRisky) - if ch.round == 0 { + if ch.IsZero() { return fmt.Errorf("%s heartbeat for %s is not allowed with no challenge", kind, hb.HbAddress) } if !ch.Failed(hb.HbAddress, account.LastSeen()) {