Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
531117ed
Unverified
Commit
531117ed
authored
Aug 30, 2020
by
metacertain
Committed by
GitHub
Aug 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Standalone flag option for bee (#597)
* Add standalone flag
parent
6ab1b364
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
12 deletions
+32
-12
cmd.go
cmd/bee/cmd/cmd.go
+2
-0
start.go
cmd/bee/cmd/start.go
+1
-0
kademlia.go
pkg/kademlia/kademlia.go
+9
-3
node.go
pkg/node/node.go
+15
-9
libp2p.go
pkg/p2p/libp2p/libp2p.go
+5
-0
No files found.
cmd/bee/cmd/cmd.go
View file @
531117ed
...
...
@@ -32,6 +32,7 @@ const (
optionNameNetworkID
=
"network-id"
optionWelcomeMessage
=
"welcome-message"
optionCORSAllowedOrigins
=
"cors-allowed-origins"
optionNameStandalone
=
"standalone"
optionNameTracingEnabled
=
"tracing-enable"
optionNameTracingEndpoint
=
"tracing-endpoint"
optionNameTracingServiceName
=
"tracing-service-name"
...
...
@@ -172,6 +173,7 @@ func (c *command) setAllFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
String
(
optionNameDebugAPIAddr
,
":6060"
,
"debug HTTP API listen address"
)
cmd
.
Flags
()
.
Uint64
(
optionNameNetworkID
,
1
,
"ID of the Swarm network"
)
cmd
.
Flags
()
.
StringSlice
(
optionCORSAllowedOrigins
,
[]
string
{},
"origins with CORS headers enabled"
)
cmd
.
Flags
()
.
Bool
(
optionNameStandalone
,
false
,
"whether we want the node to start with no listen addresses for p2p"
)
cmd
.
Flags
()
.
Bool
(
optionNameTracingEnabled
,
false
,
"enable tracing"
)
cmd
.
Flags
()
.
String
(
optionNameTracingEndpoint
,
"127.0.0.1:6831"
,
"endpoint to send tracing data"
)
cmd
.
Flags
()
.
String
(
optionNameTracingServiceName
,
"bee"
,
"service name identifier for tracing"
)
...
...
cmd/bee/cmd/start.go
View file @
531117ed
...
...
@@ -139,6 +139,7 @@ Welcome to the Swarm.... Bzzz Bzzzz Bzzzz
WelcomeMessage
:
c
.
config
.
GetString
(
optionWelcomeMessage
),
Bootnodes
:
c
.
config
.
GetStringSlice
(
optionNameBootnodes
),
CORSAllowedOrigins
:
c
.
config
.
GetStringSlice
(
optionCORSAllowedOrigins
),
Standalone
:
c
.
config
.
GetBool
(
optionNameStandalone
),
TracingEnabled
:
c
.
config
.
GetBool
(
optionNameTracingEnabled
),
TracingEndpoint
:
c
.
config
.
GetString
(
optionNameTracingEndpoint
),
TracingServiceName
:
c
.
config
.
GetString
(
optionNameTracingServiceName
),
...
...
pkg/kademlia/kademlia.go
View file @
531117ed
...
...
@@ -41,6 +41,7 @@ type binSaturationFunc func(bin uint8, peers, connected *pslice.PSlice) bool
type
Options
struct
{
SaturationFunc
binSaturationFunc
Bootnodes
[]
ma
.
Multiaddr
Standalone
bool
}
// Kad is the Swarm forwarding kademlia implementation.
...
...
@@ -61,8 +62,9 @@ type Kad struct {
peerSig
[]
chan
struct
{}
peerSigMtx
sync
.
Mutex
logger
logging
.
Logger
// logger
quit
chan
struct
{}
// quit channel
done
chan
struct
{}
// signal that `manage` has quit
standalone
bool
quit
chan
struct
{}
// quit channel
done
chan
struct
{}
// signal that `manage` has quit
wg
sync
.
WaitGroup
}
...
...
@@ -89,6 +91,7 @@ func New(base swarm.Address, addressbook addressbook.Interface, discovery discov
manageC
:
make
(
chan
struct
{},
1
),
waitNext
:
make
(
map
[
string
]
retryInfo
),
logger
:
logger
,
standalone
:
o
.
Standalone
,
quit
:
make
(
chan
struct
{}),
done
:
make
(
chan
struct
{}),
wg
:
sync
.
WaitGroup
{},
...
...
@@ -130,8 +133,11 @@ func (k *Kad) manage() {
return
default
:
}
if
k
.
standalone
{
continue
}
err
:=
k
.
knownPeers
.
EachBinRev
(
func
(
peer
swarm
.
Address
,
po
uint8
)
(
bool
,
bool
,
error
)
{
if
k
.
connectedPeers
.
Exists
(
peer
)
{
return
false
,
false
,
nil
}
...
...
pkg/node/node.go
View file @
531117ed
...
...
@@ -80,6 +80,7 @@ type Options struct {
Bootnodes
[]
string
CORSAllowedOrigins
[]
string
Logger
logging
.
Logger
Standalone
bool
TracingEnabled
bool
TracingEndpoint
string
TracingServiceName
string
...
...
@@ -136,6 +137,7 @@ func NewBee(addr string, swarmAddress swarm.Address, keystore keystore.Service,
NATAddr
:
o
.
NATAddr
,
EnableWS
:
o
.
EnableWS
,
EnableQUIC
:
o
.
EnableQUIC
,
Standalone
:
o
.
Standalone
,
WelcomeMessage
:
o
.
WelcomeMessage
,
})
if
err
!=
nil
{
...
...
@@ -170,18 +172,22 @@ func NewBee(addr string, swarmAddress swarm.Address, keystore keystore.Service,
}
var
bootnodes
[]
ma
.
Multiaddr
for
_
,
a
:=
range
o
.
Bootnodes
{
addr
,
err
:=
ma
.
NewMultiaddr
(
a
)
if
err
!=
nil
{
logger
.
Debugf
(
"multiaddress fail %s: %v"
,
a
,
err
)
logger
.
Warningf
(
"invalid bootnode address %s"
,
a
)
continue
}
if
o
.
Standalone
{
logger
.
Info
(
"Starting node in standalone mode, no p2p connections will be made or accepted"
)
}
else
{
for
_
,
a
:=
range
o
.
Bootnodes
{
addr
,
err
:=
ma
.
NewMultiaddr
(
a
)
if
err
!=
nil
{
logger
.
Debugf
(
"multiaddress fail %s: %v"
,
a
,
err
)
logger
.
Warningf
(
"invalid bootnode address %s"
,
a
)
continue
}
bootnodes
=
append
(
bootnodes
,
addr
)
bootnodes
=
append
(
bootnodes
,
addr
)
}
}
kad
:=
kademlia
.
New
(
swarmAddress
,
addressbook
,
hive
,
p2ps
,
logger
,
kademlia
.
Options
{
Bootnodes
:
bootnodes
})
kad
:=
kademlia
.
New
(
swarmAddress
,
addressbook
,
hive
,
p2ps
,
logger
,
kademlia
.
Options
{
Bootnodes
:
bootnodes
,
Standalone
:
o
.
Standalone
})
b
.
topologyCloser
=
kad
hive
.
SetAddPeersHandler
(
kad
.
AddPeers
)
p2ps
.
AddNotifier
(
kad
)
...
...
pkg/p2p/libp2p/libp2p.go
View file @
531117ed
...
...
@@ -64,6 +64,7 @@ type Options struct {
NATAddr
string
EnableWS
bool
EnableQUIC
bool
Standalone
bool
LightNode
bool
WelcomeMessage
string
}
...
...
@@ -148,6 +149,10 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay
transports
=
append
(
transports
,
libp2p
.
Transport
(
libp2pquic
.
NewTransport
))
}
if
o
.
Standalone
{
opts
=
append
(
opts
,
libp2p
.
NoListenAddrs
)
}
opts
=
append
(
opts
,
transports
...
)
h
,
err
:=
libp2p
.
New
(
ctx
,
opts
...
)
...
...
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