Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jannotti committed Oct 15, 2024
1 parent 018c8e2 commit c2c7262
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ledger/apply/heartbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ import (
func Heartbeat(hb transactions.HeartbeatTxnFields, header transactions.Header, balances Balances, provider HdrProvider, round basics.Round) error {
// Get the account's balance entry
account, err := balances.Get(hb.HeartbeatAddress, false)
if err != nil {
return err
}

sv := account.VoteID
if sv.IsEmpty() {
return fmt.Errorf("HeartbeatAddress %s has has no voting keys\n", hb.HeartbeatAddress)
return fmt.Errorf("heartbeat address %s has no voting keys\n", hb.HeartbeatAddress)
}
id := basics.OneTimeIDForRound(header.LastValid, account.VoteKeyDilution)

Expand Down
2 changes: 1 addition & 1 deletion ledger/apply/mockBalances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,5 @@ func (m mockHeaders) BlockHdr(r basics.Round) (bookkeeping.BlockHeader, error) {
if hdr, ok := m.b[r]; ok {
return hdr, nil
}
return bookkeeping.BlockHeader{}, fmt.Errorf("Round %v is not present\n", r)
return bookkeeping.BlockHeader{}, fmt.Errorf("round %v is not present\n", r)
}
5 changes: 5 additions & 0 deletions ledger/eval/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,9 @@ type headerSource interface {
BlockHdr(round basics.Round) (bookkeeping.BlockHeader, error)
}

// ActiveChallenge returns details about the Challenge that was last issued if
// it is still in effect (that is, between one and two grace periods from
// issue). Otherwise it returns the zero value.
func ActiveChallenge(rules config.ProposerPayoutRules, current basics.Round, headers headerSource) challenge {
// are challenges active?
interval := basics.Round(rules.ChallengeInterval)
Expand All @@ -1736,6 +1739,8 @@ func ActiveChallenge(rules config.ProposerPayoutRules, current basics.Round, hea
return challenge{lastChallenge, challengeHdr.Seed, rules.ChallengeBits}
}

// FailsChallenge returns true iff ch is in effect, matches address, and
// lastSeen is before the challenge issue.
func FailsChallenge(ch challenge, address basics.Address, lastSeen basics.Round) bool {
return ch.round != 0 && bitsMatch(ch.seed[:], address[:], ch.bits) && lastSeen < ch.round
}
Expand Down

0 comments on commit c2c7262

Please sign in to comment.