From 16e9daf057e95f9070964d957dc48a14327d28cf Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 8 Sep 2014 16:25:55 +0100 Subject: [PATCH] Reformatted with 'go fmt' --- connection.go | 6 +++--- connection_maker.go | 18 +++++++++--------- peer_cache.go | 2 +- types.go | 18 +++++++++--------- weaver/main.go | 5 ++--- 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/connection.go b/connection.go index 6567a091..0b8a289f 100644 --- a/connection.go +++ b/connection.go @@ -99,7 +99,7 @@ func (conn *LocalConnection) CheckFatal(err error) error { func (conn *LocalConnection) setEffectivePMTU(pmtu int) { conn.Lock() defer conn.Unlock() - if (conn.effectivePMTU != pmtu) { + if conn.effectivePMTU != pmtu { conn.effectivePMTU = pmtu conn.log("Effective PMTU set to", pmtu) } @@ -345,8 +345,8 @@ func (conn *LocalConnection) handshake(acceptNewPeer bool) error { return err } if !acceptNewPeer { - if _, found := conn.Router.Peers.Fetch(name); !found { - return fmt.Errorf("Found unknown remote name: %s at %s", name, conn.remoteTCPAddr) + if _, found := conn.Router.Peers.Fetch(name); !found { + return fmt.Errorf("Found unknown remote name: %s at %s", name, conn.remoteTCPAddr) } } diff --git a/connection_maker.go b/connection_maker.go index 97476115..d3d5822b 100644 --- a/connection_maker.go +++ b/connection_maker.go @@ -23,16 +23,16 @@ const ( func StartConnectionMaker(router *Router) *ConnectionMaker { queryChan := make(chan *ConnectionMakerInteraction, ChannelSize) state := &ConnectionMaker{ - router: router, - queryChan: queryChan, - targets: make(map[string]*Target)} + router: router, + queryChan: queryChan, + targets: make(map[string]*Target)} go state.queryLoop(queryChan) return state } func (cm *ConnectionMaker) InitiateConnection(address string) { cm.queryChan <- &ConnectionMakerInteraction{ - Interaction: Interaction{code: CMEnsure}, + Interaction: Interaction{code: CMEnsure}, acceptAnyPeer: true, address: address} } @@ -43,9 +43,9 @@ func (cm *ConnectionMaker) EnsureConnection(address string) { address = addrHost } cm.queryChan <- &ConnectionMakerInteraction{ - Interaction: Interaction{code: CMEnsure}, + Interaction: Interaction{code: CMEnsure}, acceptAnyPeer: false, - address: address} + address: address} } func (cm *ConnectionMaker) ConnectionEstablished(address string) { @@ -115,7 +115,7 @@ func (cm *ConnectionMaker) queryLoop(queryChan <-chan *ConnectionMakerInteractio for address, target := range cm.targets { if !target.established && !target.attempting && now.After(target.tryAfter) { target.attemptCount += 1 - target.attempting = true; + target.attempting = true go cm.attemptConnection(address, target.acceptAnyPeer) } } @@ -140,13 +140,13 @@ func (cm *ConnectionMaker) resetTarget(address string) { target.established = false after, interval := tryImmediately() target.tryInterval = interval - target.tryAfter = after + target.tryAfter = after } func (cm *ConnectionMaker) status() string { var buf bytes.Buffer for address, target := range cm.targets { - if (target.established) { + if target.established { buf.WriteString(fmt.Sprintf("%s connected\n", address)) } else if target.attempting { buf.WriteString(fmt.Sprintf("%s (%v attempts, trying since %v)\n", address, target.attemptCount, target.tryAfter)) diff --git a/peer_cache.go b/peer_cache.go index fc0c2b2a..390a164c 100644 --- a/peer_cache.go +++ b/peer_cache.go @@ -11,7 +11,7 @@ import ( type PeerCache struct { sync.RWMutex table map[PeerName]*Peer - onGC func(*Peer) + onGC func(*Peer) } func NewPeerCache(onGC func(*Peer)) *PeerCache { diff --git a/types.go b/types.go index 5a2baa36..e9a8462b 100644 --- a/types.go +++ b/types.go @@ -160,19 +160,19 @@ type ConnectionMakerInteraction struct { } type ConnectionMaker struct { - router *Router - queryChan chan<- *ConnectionMakerInteraction - targets map[string]*Target + router *Router + queryChan chan<- *ConnectionMakerInteraction + targets map[string]*Target } // Information about an address where we may find a peer type Target struct { - acceptAnyPeer bool // was this address given to us on the command line? - attempting bool // are we currently attempting to connect to this address? - established bool // has the connection been established - tryAfter time.Time // next time to try this address - tryInterval time.Duration // backoff time on next failure - attemptCount int + acceptAnyPeer bool // was this address given to us on the command line? + attempting bool // are we currently attempting to connect to this address? + established bool // has the connection been established + tryAfter time.Time // next time to try this address + tryInterval time.Duration // backoff time on next failure + attemptCount int } // UDPSender interface and implementations diff --git a/weaver/main.go b/weaver/main.go index 1b2c2361..63bb60d1 100644 --- a/weaver/main.go +++ b/weaver/main.go @@ -1,13 +1,13 @@ package main import ( - "github.com/zettio/weave" "code.google.com/p/gopacket/layers" "crypto/sha256" "flag" "fmt" - "io" "github.com/davecheney/profile" + "github.com/zettio/weave" + "io" "log" "net" "net/http" @@ -141,7 +141,6 @@ func handleHttp(router *weave.Router) { } } - func handleSignals(router *weave.Router) { sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.SIGQUIT, syscall.SIGUSR1)