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

whole project go fmt

parent 550971fb
package bitswap package bitswap
import ( import (
"time"
mh "github.com/jbenet/go-multihash"
blocks "github.com/jbenet/go-ipfs/blocks" blocks "github.com/jbenet/go-ipfs/blocks"
peer "github.com/jbenet/go-ipfs/peer"
u "github.com/jbenet/go-ipfs/util" u "github.com/jbenet/go-ipfs/util"
mh "github.com/jbenet/go-multihash"
"time"
) )
// aliases // aliases
...@@ -21,4 +22,5 @@ type BitSwap struct { ...@@ -21,4 +22,5 @@ type BitSwap struct {
Ledgers map[u.Key]*Ledger // key is peer.ID Ledgers map[u.Key]*Ledger // key is peer.ID
HaveList map[u.Key]*blocks.Block // key is multihash HaveList map[u.Key]*blocks.Block // key is multihash
WantList []*mh.Multihash WantList []*mh.Multihash
// todo
} }
...@@ -7,7 +7,6 @@ import ( ...@@ -7,7 +7,6 @@ import (
// TODO. SEE https://github.com/jbenet/node-ipfs/blob/master/submodules/ipfs-dht/index.js // 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. // IpfsDHT is an implementation of Kademlia with Coral and S/Kademlia modifications.
// It is used to implement the base IpfsRouting module. // It is used to implement the base IpfsRouting module.
type IpfsDHT struct { type IpfsDHT struct {
......
package dht package dht
import ( import (
"time"
peer "github.com/jbenet/go-ipfs/peer" peer "github.com/jbenet/go-ipfs/peer"
u "github.com/jbenet/go-ipfs/util"
swarm "github.com/jbenet/go-ipfs/swarm" 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. // This file implements the Routing interface for the IpfsDHT struct.
// Basic Put/Get // Basic Put/Get
// PutValue adds value corresponding to given Key. // 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 var p *peer.Peer
p = s.routes.NearestNode(key) p = s.routes.NearestNode(key)
...@@ -59,12 +58,11 @@ func (s *IpfsDHT) GetValue(key u.Key, timeout time.Duration) ([]byte, error) { ...@@ -59,12 +58,11 @@ func (s *IpfsDHT) GetValue(key u.Key, timeout time.Duration) ([]byte, error) {
return nil, nil return nil, nil
} }
// Value provider layer of indirection. // Value provider layer of indirection.
// This is what DSHTs (Coral and MainlineDHT) do to store large values in a DHT. // 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 // 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 return u.ErrNotImplemented
} }
...@@ -73,7 +71,6 @@ func (s *IpfsDHT) FindProviders(key u.Key, timeout time.Duration) (*peer.Peer, e ...@@ -73,7 +71,6 @@ func (s *IpfsDHT) FindProviders(key u.Key, timeout time.Duration) (*peer.Peer, e
return nil, u.ErrNotImplemented return nil, u.ErrNotImplemented
} }
// Find specific Peer // Find specific Peer
// FindPeer searches for a peer with given ID. // FindPeer searches for a peer with given ID.
......
package routing package routing
import ( import (
"time"
peer "github.com/jbenet/go-ipfs/peer" peer "github.com/jbenet/go-ipfs/peer"
u "github.com/jbenet/go-ipfs/util" u "github.com/jbenet/go-ipfs/util"
"time"
) )
// IpfsRouting is the routing module interface // IpfsRouting is the routing module interface
...@@ -13,22 +13,20 @@ type IpfsRouting interface { ...@@ -13,22 +13,20 @@ type IpfsRouting interface {
// Basic Put/Get // Basic Put/Get
// PutValue adds value corresponding to given Key. // 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 searches for the value corresponding to given Key.
GetValue(key u.Key, timeout time.Duration) ([]byte, error) GetValue(key u.Key, timeout time.Duration) ([]byte, error)
// Value provider layer of indirection. // Value provider layer of indirection.
// This is what DSHTs (Coral and MainlineDHT) do to store large values in a DHT. // 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 // 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 searches for peers who can provide the value for given key.
FindProviders(key u.Key, timeout time.Duration) (*peer.Peer, error) 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 searches for a peer with given ID.
......
...@@ -3,10 +3,10 @@ package swarm ...@@ -3,10 +3,10 @@ package swarm
import ( import (
"fmt" "fmt"
peer "github.com/jbenet/go-ipfs/peer" peer "github.com/jbenet/go-ipfs/peer"
ma "github.com/jbenet/go-multiaddr"
u "github.com/jbenet/go-ipfs/util" u "github.com/jbenet/go-ipfs/util"
"sync" ma "github.com/jbenet/go-multiaddr"
"net" "net"
"sync"
) )
// Message represents a packet of information sent to or received from a // Message represents a packet of information sent to or received from a
...@@ -62,7 +62,7 @@ func NewSwarm(local *peer.Peer) *Swarm { ...@@ -62,7 +62,7 @@ func NewSwarm(local *peer.Peer) *Swarm {
// Open listeners for each network the swarm should listen on // Open listeners for each network the swarm should listen on
func (s *Swarm) Listen() { func (s *Swarm) Listen() {
for _,addr := range s.local.Addresses { for _, addr := range s.local.Addresses {
err := s.connListen(addr) err := s.connListen(addr)
if err != nil { if err != nil {
u.PErr("Failed to listen on: %s [%s]", addr, err) u.PErr("Failed to listen on: %s [%s]", addr, err)
...@@ -85,7 +85,7 @@ func (s *Swarm) connListen(maddr *ma.Multiaddr) error { ...@@ -85,7 +85,7 @@ func (s *Swarm) connListen(maddr *ma.Multiaddr) error {
// Accept and handle new connections on this listener until it errors // Accept and handle new connections on this listener until it errors
go func() { go func() {
for { for {
nconn,err := list.Accept() nconn, err := list.Accept()
if err != nil { if err != nil {
u.PErr("Failed to accept connection: %s - %s", netstr, addr) u.PErr("Failed to accept connection: %s - %s", netstr, addr)
return 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