Skip to content

Commit

Permalink
Remove custom min/max functions in favor of golang built-ins.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmalouf committed Nov 14, 2024
1 parent 2522f3a commit 72634c5
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 27 deletions.
8 changes: 0 additions & 8 deletions ledger/eval/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 0 additions & 11 deletions network/gossipNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 1 addition & 8 deletions network/wsNetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 72634c5

Please sign in to comment.