From 4de05a3a439e629a2aeece1944e24d03bbc7b8bf Mon Sep 17 00:00:00 2001 From: Vlad Date: Wed, 6 Mar 2019 17:03:58 +0400 Subject: [PATCH] swarm/pss: gofmt applied --- swarm/network/simulation/kademlia.go | 4 +- swarm/pss/snapshot_test.go | 58 +++++++++++++--------------- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/swarm/network/simulation/kademlia.go b/swarm/network/simulation/kademlia.go index e9d34790ce..16752c4586 100644 --- a/swarm/network/simulation/kademlia.go +++ b/swarm/network/simulation/kademlia.go @@ -169,7 +169,7 @@ func isAllDeployed(expected []uint64, actual []uint64) bool { } func removeListElement(arr []uint64, i int) []uint64 { - last := len(arr)-1 + last := len(arr) - 1 arr[i] = arr[last] arr = arr[:last] return arr @@ -178,7 +178,7 @@ func removeListElement(arr []uint64, i int) []uint64 { func removeDuplicatesAndSingletons(arr []uint64) []uint64 { for i := 0; i < len(arr); { found := false - for j := i+1; j < len(arr); j++ { + for j := i + 1; j < len(arr); j++ { if arr[i] == arr[j] { arr = removeListElement(arr, j) // remove duplicate found = true diff --git a/swarm/pss/snapshot_test.go b/swarm/pss/snapshot_test.go index abf0823a24..efca60b60c 100644 --- a/swarm/pss/snapshot_test.go +++ b/swarm/pss/snapshot_test.go @@ -46,28 +46,28 @@ var ( runNodes = flag.Int("nodes", 0, "nodes to start in the network") runMessages = flag.Int("messages", 0, "messages to send during test") - pof = pot.DefaultPof(256) // generate messages and index them - topic = BytesToTopic([]byte{0x00, 0x00, 0x06, 0x82}) - mu sync.Mutex // keeps handlerDonc in sync - sim *simulation.Simulation + pof = pot.DefaultPof(256) // generate messages and index them + topic = BytesToTopic([]byte{0x00, 0x00, 0x06, 0x82}) + mu sync.Mutex // keeps handlerDonc in sync + sim *simulation.Simulation handlerDone bool // set to true on termination of the simulation run msgsToReceive int // total count of messages to receive, used for terminating the simulation run maxMessages int msgCnt int - kademlias map[enode.ID]*network.Kademlia - nodeAddrs map[enode.ID][]byte // make predictable overlay addresses from the generated random enode ids - recipients map[int][]enode.ID // for logging output only - allowed map[int][]enode.ID // allowed recipients - expectedMsgs map[enode.ID][]uint64 // message serials we expect respective nodes to receive - allowedMsgs map[enode.ID][]uint64 // message serials we expect respective nodes to receive - senders map[int]enode.ID // originating nodes of the messages (intention is to choose as far as possible from the receiving neighborhood) - handlerC chan handlerNotification // passes message from pss message handler to simulation driver - doneC chan struct{} // terminates the handler channel listener - errC chan error // error to pass to main sim thread - msgC chan handlerNotification // message receipt notification to main sim thread - msgs [][]byte // recipient addresses of messages + kademlias map[enode.ID]*network.Kademlia + nodeAddrs map[enode.ID][]byte // make predictable overlay addresses from the generated random enode ids + recipients map[int][]enode.ID // for logging output only + allowed map[int][]enode.ID // allowed recipients + expectedMsgs map[enode.ID][]uint64 // message serials we expect respective nodes to receive + allowedMsgs map[enode.ID][]uint64 // message serials we expect respective nodes to receive + senders map[int]enode.ID // originating nodes of the messages (intention is to choose as far as possible from the receiving neighborhood) + handlerC chan handlerNotification // passes message from pss message handler to simulation driver + doneC chan struct{} // terminates the handler channel listener + errC chan error // error to pass to main sim thread + msgC chan handlerNotification // message receipt notification to main sim thread + msgs [][]byte // recipient addresses of messages ) func resetTestVariables() { @@ -78,21 +78,17 @@ func resetTestVariables() { msgs = nil sim = nil - kademlias = make(map[enode.ID]*network.Kademlia) - nodeAddrs = make(map[enode.ID][]byte) - recipients = make(map[int][]enode.ID) - allowed = make(map[int][]enode.ID) - expectedMsgs = make(map[enode.ID][]uint64) - allowedMsgs = make(map[enode.ID][]uint64) - senders = make(map[int]enode.ID) - handlerC = make(chan handlerNotification) - doneC = make(chan struct{}) - errC = make(chan error) - msgC = make(chan handlerNotification) -} - -func init() { - log.Root().SetHandler(log.LvlFilterHandler(log.LvlTrace, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + kademlias = make(map[enode.ID]*network.Kademlia) + nodeAddrs = make(map[enode.ID][]byte) + recipients = make(map[int][]enode.ID) + allowed = make(map[int][]enode.ID) + expectedMsgs = make(map[enode.ID][]uint64) + allowedMsgs = make(map[enode.ID][]uint64) + senders = make(map[int]enode.ID) + handlerC = make(chan handlerNotification) + doneC = make(chan struct{}) + errC = make(chan error) + msgC = make(chan handlerNotification) } func isDone() bool {