good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
4e9230ea
Unverified
Commit
4e9230ea
authored
Mar 1, 2019
by
Anton Evangelatov
Committed by
GitHub
Mar 1, 2019
Browse files
Options
Downloads
Patches
Plain Diff
swarm: enable p2p/discovery and disable dynamic dialling (#19189)
parent
94eca08a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/swarm/main.go
+2
-2
2 additions, 2 deletions
cmd/swarm/main.go
swarm/api/inspector.go
+9
-0
9 additions, 0 deletions
swarm/api/inspector.go
swarm/network/kademlia.go
+26
-1
26 additions, 1 deletion
swarm/network/kademlia.go
with
37 additions
and
3 deletions
cmd/swarm/main.go
+
2
−
2
View file @
4e9230ea
...
@@ -287,8 +287,8 @@ func bzzd(ctx *cli.Context) error {
...
@@ -287,8 +287,8 @@ func bzzd(ctx *cli.Context) error {
//setup the ethereum node
//setup the ethereum node
utils
.
SetNodeConfig
(
ctx
,
&
cfg
)
utils
.
SetNodeConfig
(
ctx
,
&
cfg
)
//
always
disable d
iscovery from p2p package - swarm discovery is done with the `hive` protocol
//disable d
ynamic dialing from p2p/discovery
cfg
.
P2P
.
NoDi
scovery
=
true
cfg
.
P2P
.
NoDi
al
=
true
stack
,
err
:=
node
.
New
(
&
cfg
)
stack
,
err
:=
node
.
New
(
&
cfg
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
swarm/api/inspector.go
+
9
−
0
View file @
4e9230ea
...
@@ -18,6 +18,7 @@ package api
...
@@ -18,6 +18,7 @@ package api
import
(
import
(
"context"
"context"
"fmt"
"github.com/ethereum/go-ethereum/swarm/network"
"github.com/ethereum/go-ethereum/swarm/network"
"github.com/ethereum/go-ethereum/swarm/storage"
"github.com/ethereum/go-ethereum/swarm/storage"
...
@@ -38,6 +39,14 @@ func (inspector *Inspector) Hive() string {
...
@@ -38,6 +39,14 @@ func (inspector *Inspector) Hive() string {
return
inspector
.
hive
.
String
()
return
inspector
.
hive
.
String
()
}
}
func
(
inspector
*
Inspector
)
ListKnown
()
[]
string
{
res
:=
[]
string
{}
for
_
,
v
:=
range
inspector
.
hive
.
Kademlia
.
ListKnown
()
{
res
=
append
(
res
,
fmt
.
Sprintf
(
"%v"
,
v
))
}
return
res
}
type
HasInfo
struct
{
type
HasInfo
struct
{
Addr
string
`json:"address"`
Addr
string
`json:"address"`
Has
bool
`json:"has"`
Has
bool
`json:"has"`
...
...
This diff is collapsed.
Click to expand it.
swarm/network/kademlia.go
+
26
−
1
View file @
4e9230ea
...
@@ -140,6 +140,7 @@ func (k *Kademlia) Register(peers ...*BzzAddr) error {
...
@@ -140,6 +140,7 @@ func (k *Kademlia) Register(peers ...*BzzAddr) error {
defer
k
.
lock
.
Unlock
()
defer
k
.
lock
.
Unlock
()
var
known
,
size
int
var
known
,
size
int
for
_
,
p
:=
range
peers
{
for
_
,
p
:=
range
peers
{
log
.
Trace
(
"kademlia trying to register"
,
"addr"
,
p
)
// error if self received, peer should know better
// error if self received, peer should know better
// and should be punished for this
// and should be punished for this
if
bytes
.
Equal
(
p
.
Address
(),
k
.
base
)
{
if
bytes
.
Equal
(
p
.
Address
(),
k
.
base
)
{
...
@@ -149,10 +150,22 @@ func (k *Kademlia) Register(peers ...*BzzAddr) error {
...
@@ -149,10 +150,22 @@ func (k *Kademlia) Register(peers ...*BzzAddr) error {
k
.
addrs
,
_
,
found
,
_
=
pot
.
Swap
(
k
.
addrs
,
p
,
Pof
,
func
(
v
pot
.
Val
)
pot
.
Val
{
k
.
addrs
,
_
,
found
,
_
=
pot
.
Swap
(
k
.
addrs
,
p
,
Pof
,
func
(
v
pot
.
Val
)
pot
.
Val
{
// if not found
// if not found
if
v
==
nil
{
if
v
==
nil
{
log
.
Trace
(
"registering new peer"
,
"addr"
,
p
)
// insert new offline peer into conns
// insert new offline peer into conns
return
newEntry
(
p
)
return
newEntry
(
p
)
}
}
// found among known peers, do nothing
e
:=
v
.
(
*
entry
)
// if underlay address is different, still add
if
!
bytes
.
Equal
(
e
.
BzzAddr
.
UAddr
,
p
.
UAddr
)
{
log
.
Trace
(
"underlay addr is different, so add again"
,
"new"
,
p
,
"old"
,
e
.
BzzAddr
)
// insert new offline peer into conns
return
newEntry
(
p
)
}
log
.
Trace
(
"found among known peers, underlay addr is same, do nothing"
,
"new"
,
p
,
"old"
,
e
.
BzzAddr
)
return
v
return
v
})
})
if
found
{
if
found
{
...
@@ -417,6 +430,18 @@ func (k *Kademlia) Off(p *Peer) {
...
@@ -417,6 +430,18 @@ func (k *Kademlia) Off(p *Peer) {
}
}
}
}
func
(
k
*
Kademlia
)
ListKnown
()
[]
*
BzzAddr
{
res
:=
[]
*
BzzAddr
{}
k
.
addrs
.
Each
(
func
(
val
pot
.
Val
)
bool
{
e
:=
val
.
(
*
entry
)
res
=
append
(
res
,
e
.
BzzAddr
)
return
true
})
return
res
}
// EachConn is an iterator with args (base, po, f) applies f to each live peer
// EachConn is an iterator with args (base, po, f) applies f to each live peer
// that has proximity order po or less as measured from the base
// that has proximity order po or less as measured from the base
// if base is nil, kademlia base address is used
// if base is nil, kademlia base address is used
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment