Reformatted with 'go fmt'

This commit is contained in:
Bryan Boreham committed 2014-09-08 16:25:55 +01:00
1 parent de7f4df7c9
commit 16e9daf057
5 files changed
+24 -25

No files matched your search

+3 -3
View File
@@ -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)
}
}
+9 -9
View File
@@ -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))
+1 -1
View File
@@ -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 {
+9 -9
View File
@@ -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
+2 -3
View File
@@ -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)