From 74d26449c98267cb3c06f56ad2752d7d89c5202b Mon Sep 17 00:00:00 2001
From: Juan Batiz-Benet <juan@benet.ai>
Date: Tue, 29 Jul 2014 17:55:19 -0700
Subject: [PATCH] whole project go fmt

---
 bitswap/bitswap.go     | 20 +++++++++++---------
 routing/dht/dht.go     |  5 ++---
 routing/dht/routing.go | 31 ++++++++++++++-----------------
 routing/routing.go     | 36 +++++++++++++++++-------------------
 swarm/swarm.go         | 10 +++++-----
 5 files changed, 49 insertions(+), 53 deletions(-)

diff --git a/bitswap/bitswap.go b/bitswap/bitswap.go
index 737f43e6..f70b4520 100644
--- a/bitswap/bitswap.go
+++ b/bitswap/bitswap.go
@@ -1,24 +1,26 @@
 package bitswap
 
 import (
-  "time"
-  mh "github.com/jbenet/go-multihash"
-  blocks "github.com/jbenet/go-ipfs/blocks"
-  u "github.com/jbenet/go-ipfs/util"
+	blocks "github.com/jbenet/go-ipfs/blocks"
+	peer "github.com/jbenet/go-ipfs/peer"
+	u "github.com/jbenet/go-ipfs/util"
+	mh "github.com/jbenet/go-multihash"
+	"time"
 )
 
 // aliases
 
 type Ledger struct {
-	Owner mh.Multihash
-	Partner mh.Multihash
+	Owner     mh.Multihash
+	Partner   mh.Multihash
 	BytesSent uint64
 	BytesRecv uint64
 	Timestamp *time.Time
 }
 
 type BitSwap struct {
-  Ledgers map[u.Key]*Ledger  // key is peer.ID
-  HaveList map[u.Key]*blocks.Block // key is multihash
-  WantList []*mh.Multihash
+	Ledgers  map[u.Key]*Ledger       // key is peer.ID
+	HaveList map[u.Key]*blocks.Block // key is multihash
+	WantList []*mh.Multihash
+	// todo
 }
diff --git a/routing/dht/dht.go b/routing/dht/dht.go
index 21f054e6..c7e6f3c2 100644
--- a/routing/dht/dht.go
+++ b/routing/dht/dht.go
@@ -7,7 +7,6 @@ import (
 
 // TODO. SEE https://github.com/jbenet/node-ipfs/blob/master/submodules/ipfs-dht/index.js
 
-
 // IpfsDHT is an implementation of Kademlia with Coral and S/Kademlia modifications.
 // It is used to implement the base IpfsRouting module.
 type IpfsDHT struct {
@@ -15,7 +14,7 @@ type IpfsDHT struct {
 
 	network *swarm.Swarm
 
-	listeners map[uint64]chan swarm.Message
+	listeners  map[uint64]chan swarm.Message
 	listenLock sync.RWMutex
 }
 
@@ -35,7 +34,7 @@ func (dht *IpfsDHT) handleMessages() {
 					ch <- mes
 				}
 
-			//case closeChan: or something
+				//case closeChan: or something
 			}
 		}
 	}
diff --git a/routing/dht/routing.go b/routing/dht/routing.go
index bcbdec1d..2bbe93e3 100644
--- a/routing/dht/routing.go
+++ b/routing/dht/routing.go
@@ -1,19 +1,18 @@
 package dht
 
 import (
-  "time"
-  peer "github.com/jbenet/go-ipfs/peer"
-  u "github.com/jbenet/go-ipfs/util"
-  swarm "github.com/jbenet/go-ipfs/swarm"
+	peer "github.com/jbenet/go-ipfs/peer"
+	swarm "github.com/jbenet/go-ipfs/swarm"
+	u "github.com/jbenet/go-ipfs/util"
+	"time"
 )
 
-
 // This file implements the Routing interface for the IpfsDHT struct.
 
 // Basic Put/Get
 
 // PutValue adds value corresponding to given Key.
-func (s *IpfsDHT) PutValue(key u.Key, value []byte) (error) {
+func (s *IpfsDHT) PutValue(key u.Key, value []byte) error {
 	var p *peer.Peer
 	p = s.routes.NearestNode(key)
 
@@ -48,35 +47,33 @@ func (s *IpfsDHT) GetValue(key u.Key, timeout time.Duration) ([]byte, error) {
 	// Wait for either the response or a timeout
 	timeup := time.After(timeout)
 	select {
-		case <-timeup:
-			// TODO: unregister listener
-			return nil, timeoutError
-		case resp := <-response_chan:
-			return resp.Data, nil
+	case <-timeup:
+		// TODO: unregister listener
+		return nil, timeoutError
+	case resp := <-response_chan:
+		return resp.Data, nil
 	}
 
 	// Should never be hit
 	return nil, nil
 }
 
-
 // Value provider layer of indirection.
 // This is what DSHTs (Coral and MainlineDHT) do to store large values in a DHT.
 
 // Announce that this node can provide value for given key
-func (s *IpfsDHT) Provide(key u.Key) (error) {
-  return u.ErrNotImplemented
+func (s *IpfsDHT) Provide(key u.Key) error {
+	return u.ErrNotImplemented
 }
 
 // FindProviders searches for peers who can provide the value for given key.
 func (s *IpfsDHT) FindProviders(key u.Key, timeout time.Duration) (*peer.Peer, error) {
-  return nil, u.ErrNotImplemented
+	return nil, u.ErrNotImplemented
 }
 
-
 // Find specific Peer
 
 // FindPeer searches for a peer with given ID.
 func (s *IpfsDHT) FindPeer(id peer.ID, timeout time.Duration) (*peer.Peer, error) {
-  return nil, u.ErrNotImplemented
+	return nil, u.ErrNotImplemented
 }
diff --git a/routing/routing.go b/routing/routing.go
index 4a924018..933032f4 100644
--- a/routing/routing.go
+++ b/routing/routing.go
@@ -1,36 +1,34 @@
 package routing
 
 import (
-  "time"
-  peer "github.com/jbenet/go-ipfs/peer"
-  u "github.com/jbenet/go-ipfs/util"
+	peer "github.com/jbenet/go-ipfs/peer"
+	u "github.com/jbenet/go-ipfs/util"
+	"time"
 )
 
 // IpfsRouting is the routing module interface
 // It is implemented by things like DHTs, etc.
 type IpfsRouting interface {
 
-  // Basic Put/Get
+	// Basic Put/Get
 
-  // PutValue adds value corresponding to given Key.
-  PutValue(key u.Key, value []byte) (error)
+	// PutValue adds value corresponding to given Key.
+	PutValue(key u.Key, value []byte) error
 
-  // GetValue searches for the value corresponding to given Key.
-  GetValue(key u.Key, timeout time.Duration) ([]byte, error)
+	// GetValue searches for the value corresponding to given Key.
+	GetValue(key u.Key, timeout time.Duration) ([]byte, error)
 
+	// Value provider layer of indirection.
+	// This is what DSHTs (Coral and MainlineDHT) do to store large values in a DHT.
 
-  // Value provider layer of indirection.
-  // This is what DSHTs (Coral and MainlineDHT) do to store large values in a DHT.
+	// Announce that this node can provide value for given key
+	Provide(key u.Key) error
 
-  // Announce that this node can provide value for given key
-  Provide(key u.Key) (error)
+	// FindProviders searches for peers who can provide the value for given key.
+	FindProviders(key u.Key, timeout time.Duration) (*peer.Peer, error)
 
-  // FindProviders searches for peers who can provide the value for given key.
-  FindProviders(key u.Key, timeout time.Duration) (*peer.Peer, error)
+	// Find specific Peer
 
-
-  // Find specific Peer
-
-  // FindPeer searches for a peer with given ID.
-  FindPeer(id peer.ID, timeout time.Duration) (*peer.Peer, error)
+	// FindPeer searches for a peer with given ID.
+	FindPeer(id peer.ID, timeout time.Duration) (*peer.Peer, error)
 }
diff --git a/swarm/swarm.go b/swarm/swarm.go
index 441779b3..1e23a8e7 100644
--- a/swarm/swarm.go
+++ b/swarm/swarm.go
@@ -3,10 +3,10 @@ package swarm
 import (
 	"fmt"
 	peer "github.com/jbenet/go-ipfs/peer"
-	ma "github.com/jbenet/go-multiaddr"
 	u "github.com/jbenet/go-ipfs/util"
-	"sync"
+	ma "github.com/jbenet/go-multiaddr"
 	"net"
+	"sync"
 )
 
 // Message represents a packet of information sent to or received from a
@@ -46,7 +46,7 @@ type Swarm struct {
 	conns     ConnMap
 	connsLock sync.RWMutex
 
-	local	  *peer.Peer
+	local *peer.Peer
 }
 
 // NewSwarm constructs a Swarm, with a Chan.
@@ -62,7 +62,7 @@ func NewSwarm(local *peer.Peer) *Swarm {
 
 // Open listeners for each network the swarm should listen on
 func (s *Swarm) Listen() {
-	for _,addr := range s.local.Addresses {
+	for _, addr := range s.local.Addresses {
 		err := s.connListen(addr)
 		if err != nil {
 			u.PErr("Failed to listen on: %s [%s]", addr, err)
@@ -85,7 +85,7 @@ func (s *Swarm) connListen(maddr *ma.Multiaddr) error {
 	// Accept and handle new connections on this listener until it errors
 	go func() {
 		for {
-			nconn,err := list.Accept()
+			nconn, err := list.Accept()
 			if err != nil {
 				u.PErr("Failed to accept connection: %s - %s", netstr, addr)
 				return
-- 
GitLab