Commit 74d26449 authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

whole project go fmt

parent 550971fb
package bitswap
import (
"time"
mh "github.com/jbenet/go-multihash"
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
......@@ -21,4 +22,5 @@ type BitSwap struct {
Ledgers map[u.Key]*Ledger // key is peer.ID
HaveList map[u.Key]*blocks.Block // key is multihash
WantList []*mh.Multihash
// todo
}
......@@ -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 {
......
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"
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)
......@@ -59,12 +58,11 @@ func (s *IpfsDHT) GetValue(key u.Key, timeout time.Duration) ([]byte, error) {
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) {
func (s *IpfsDHT) Provide(key u.Key) error {
return u.ErrNotImplemented
}
......@@ -73,7 +71,6 @@ func (s *IpfsDHT) FindProviders(key u.Key, timeout time.Duration) (*peer.Peer, e
return nil, u.ErrNotImplemented
}
// Find specific Peer
// FindPeer searches for a peer with given ID.
......
package routing
import (
"time"
peer "github.com/jbenet/go-ipfs/peer"
u "github.com/jbenet/go-ipfs/util"
"time"
)
// IpfsRouting is the routing module interface
......@@ -13,22 +13,20 @@ type IpfsRouting interface {
// Basic Put/Get
// PutValue adds value corresponding to given Key.
PutValue(key u.Key, value []byte) (error)
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)
// 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)
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)
// Find specific Peer
// FindPeer searches for a peer with given ID.
......
......@@ -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
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment