From 72634c5dbab0d237819b0d744f65debcb742d96b Mon Sep 17 00:00:00 2001 From: Gary Malouf <982483+gmalouf@users.noreply.github.com> Date: Wed, 13 Nov 2024 22:50:29 -0500 Subject: [PATCH] Remove custom min/max functions in favor of golang built-ins. --- ledger/eval/eval.go | 8 -------- network/gossipNode.go | 11 ----------- network/wsNetwork.go | 9 +-------- 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/ledger/eval/eval.go b/ledger/eval/eval.go index 859b62922f..8bf7f8ce7d 100644 --- a/ledger/eval/eval.go +++ b/ledger/eval/eval.go @@ -1658,14 +1658,6 @@ func (eval *BlockEvaluator) generateKnockOfflineAccountsList() { } } -// delete me in Go 1.21 -func max(a, b basics.Round) basics.Round { - if a > b { - return a - } - return b -} - // bitsMatch checks if the first n bits of two byte slices match. Written to // work on arbitrary slices, but we expect that n is small. Only user today // calls with n=5. diff --git a/network/gossipNode.go b/network/gossipNode.go index 91fb3506bc..68a5e36d88 100644 --- a/network/gossipNode.go +++ b/network/gossipNode.go @@ -231,17 +231,6 @@ func Propagate(msg IncomingMessage) OutgoingMessage { return OutgoingMessage{Action: Broadcast, Tag: msg.Tag, Payload: msg.Data, Topics: nil} } -// find the max value across the given uint64 numbers. -func max(numbers ...uint64) (maxNum uint64) { - maxNum = 0 // this is the lowest uint64 value. - for _, num := range numbers { - if num > maxNum { - maxNum = num - } - } - return -} - // SubstituteGenesisID substitutes the "{genesisID}" with their network-specific genesisID. func SubstituteGenesisID(net GossipNode, rawURL string) string { return strings.Replace(rawURL, "{genesisID}", net.GetGenesisID(), -1) diff --git a/network/wsNetwork.go b/network/wsNetwork.go index 1c5774aa6e..675e425573 100644 --- a/network/wsNetwork.go +++ b/network/wsNetwork.go @@ -1493,13 +1493,6 @@ type meshRequest struct { done chan struct{} } -func imin(a, b int) int { - if a < b { - return a - } - return b -} - // meshThread maintains the network, e.g. that we have sufficient connectivity to peers func (wn *WebsocketNetwork) meshThread() { defer wn.wg.Done() @@ -1568,7 +1561,7 @@ func (wn *WebsocketNetwork) refreshRelayArchivePhonebookAddresses() { func (wn *WebsocketNetwork) updatePhonebookAddresses(relayAddrs []string, archiveAddrs []string) { if len(relayAddrs) > 0 { - wn.log.Debugf("got %d relay dns addrs, %#v", len(relayAddrs), relayAddrs[:imin(5, len(relayAddrs))]) + wn.log.Debugf("got %d relay dns addrs, %#v", len(relayAddrs), relayAddrs[:min(5, len(relayAddrs))]) wn.phonebook.ReplacePeerList(relayAddrs, string(wn.NetworkID), phonebook.PhoneBookEntryRelayRole) } else { wn.log.Infof("got no relay DNS addrs for network %s", wn.NetworkID)