Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
74d26449
Commit
74d26449
authored
Jul 29, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
whole project go fmt
parent
550971fb
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
53 deletions
+49
-53
bitswap/bitswap.go
bitswap/bitswap.go
+11
-9
routing/dht/dht.go
routing/dht/dht.go
+2
-3
routing/dht/routing.go
routing/dht/routing.go
+14
-17
routing/routing.go
routing/routing.go
+17
-19
swarm/swarm.go
swarm/swarm.go
+5
-5
No files found.
bitswap/bitswap.go
View file @
74d26449
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
}
routing/dht/dht.go
View file @
74d26449
...
...
@@ -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
{
...
...
routing/dht/routing.go
View file @
74d26449
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.
...
...
routing/routing.go
View file @
74d26449
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.
...
...
swarm/swarm.go
View file @
74d26449
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment