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
3ff1214a
Unverified
Commit
3ff1214a
authored
Jul 15, 2021
by
Anatol
Committed by
GitHub
Jul 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: remove standalone mode (#2331)
parent
b90e92cd
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
75 additions
and
112 deletions
+75
-112
cmd.go
cmd/bee/cmd/cmd.go
+0
-2
start.go
cmd/bee/cmd/start.go
+0
-1
bee.yaml
packaging/bee.yaml
+0
-2
docker-compose.yml
packaging/docker/docker-compose.yml
+0
-1
env
packaging/docker/env
+0
-2
bee.yaml
packaging/homebrew/bee.yaml
+0
-2
bee.yaml
packaging/scoop/bee.yaml
+0
-2
node.go
pkg/node/node.go
+75
-88
libp2p.go
pkg/p2p/libp2p/libp2p.go
+0
-5
kademlia.go
pkg/topology/kademlia/kademlia.go
+0
-7
No files found.
cmd/bee/cmd/cmd.go
View file @
3ff1214a
...
...
@@ -40,7 +40,6 @@ const (
optionNameNetworkID
=
"network-id"
optionWelcomeMessage
=
"welcome-message"
optionCORSAllowedOrigins
=
"cors-allowed-origins"
optionNameStandalone
=
"standalone"
optionNameTracingEnabled
=
"tracing-enable"
optionNameTracingEndpoint
=
"tracing-endpoint"
optionNameTracingHost
=
"tracing-host"
...
...
@@ -217,7 +216,6 @@ func (c *command) setAllFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
String
(
optionNameDebugAPIAddr
,
":1635"
,
"debug HTTP API listen address"
)
cmd
.
Flags
()
.
Uint64
(
optionNameNetworkID
,
10
,
"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
(
optionNameTracingHost
,
""
,
"host to send tracing data"
)
...
...
cmd/bee/cmd/start.go
View file @
3ff1214a
...
...
@@ -173,7 +173,6 @@ inability to use, or your interaction with other nodes or the software.`)
WelcomeMessage
:
c
.
config
.
GetString
(
optionWelcomeMessage
),
Bootnodes
:
networkConfig
.
bootNodes
,
CORSAllowedOrigins
:
c
.
config
.
GetStringSlice
(
optionCORSAllowedOrigins
),
Standalone
:
c
.
config
.
GetBool
(
optionNameStandalone
),
TracingEnabled
:
c
.
config
.
GetBool
(
optionNameTracingEnabled
),
TracingEndpoint
:
tracingEndpoint
,
TracingServiceName
:
c
.
config
.
GetString
(
optionNameTracingServiceName
),
...
...
packaging/bee.yaml
View file @
3ff1214a
...
...
@@ -62,8 +62,6 @@ password-file: /var/lib/bee/password
# postage-stamp-address: ""
## ENS compatible API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url
# resolver-options: []
## whether we want the node to start with no listen addresses for p2p
# standalone: false
## enable swap (default true)
# swap-enable: true
## swap ethereum blockchain endpoint (default "ws://localhost:8546")
...
...
packaging/docker/docker-compose.yml
View file @
3ff1214a
...
...
@@ -45,7 +45,6 @@ services:
-
BEE_PAYMENT_TOLERANCE
-
BEE_POSTAGE_STAMP_ADDRESS
-
BEE_RESOLVER_OPTIONS
-
BEE_STANDALONE
-
BEE_SWAP_ENABLE
-
BEE_SWAP_ENDPOINT
-
BEE_SWAP_FACTORY_ADDRESS
...
...
packaging/docker/env
View file @
3ff1214a
...
...
@@ -69,8 +69,6 @@ BEE_CLEF_SIGNER_ENABLE=true
# BEE_POSTAGE_STAMP_ADDRESS=
## ENS compatible API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url
# BEE_RESOLVER_OPTIONS=[]
## whether we want the node to start with no listen addresses for p2p
# BEE_STANDALONE=false
## enable swap (default true)
# BEE_SWAP_ENABLE=true
## swap ethereum blockchain endpoint (default ws://localhost:8546)
...
...
packaging/homebrew/bee.yaml
View file @
3ff1214a
...
...
@@ -62,8 +62,6 @@ password-file: /usr/local/var/lib/swarm-bee/password
# postage-stamp-address: ""
## ENS compatible API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url
# resolver-options: []
## whether we want the node to start with no listen addresses for p2p
# standalone: false
## enable swap (default true)
# swap-enable: true
## swap ethereum blockchain endpoint (default "ws://localhost:8546")
...
...
packaging/scoop/bee.yaml
View file @
3ff1214a
...
...
@@ -52,8 +52,6 @@ password-file: ./password
# postage-stamp-address: ""
## ENS compatible API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url
# resolver-options: []
## whether we want the node to start with no listen addresses for p2p
# standalone: false
## enable swap (default true)
# swap-enable: true
## swap ethereum blockchain endpoint (default "ws://localhost:8546")
...
...
pkg/node/node.go
View file @
3ff1214a
...
...
@@ -128,7 +128,6 @@ type Options struct {
Bootnodes
[]
string
CORSAllowedOrigins
[]
string
Logger
logging
.
Logger
Standalone
bool
TracingEnabled
bool
TracingEndpoint
string
TracingServiceName
string
...
...
@@ -212,25 +211,23 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
cashoutService
chequebook
.
CashoutService
pollingInterval
=
time
.
Duration
(
o
.
BlockTime
)
*
time
.
Second
)
if
!
o
.
Standalone
{
swapBackend
,
overlayEthAddress
,
chainID
,
transactionMonitor
,
transactionService
,
err
=
InitChain
(
p2pCtx
,
logger
,
stateStore
,
o
.
SwapEndpoint
,
signer
,
pollingInterval
,
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"init chain: %w"
,
err
)
}
b
.
ethClientCloser
=
swapBackend
.
Close
b
.
transactionCloser
=
tracerCloser
b
.
transactionMonitorCloser
=
transactionMonitor
swapBackend
,
overlayEthAddress
,
chainID
,
transactionMonitor
,
transactionService
,
err
=
InitChain
(
p2pCtx
,
logger
,
stateStore
,
o
.
SwapEndpoint
,
signer
,
pollingInterval
,
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"init chain: %w"
,
err
)
}
b
.
ethClientCloser
=
swapBackend
.
Close
b
.
transactionCloser
=
tracerCloser
b
.
transactionMonitorCloser
=
transactionMonitor
if
o
.
ChainID
!=
-
1
&&
o
.
ChainID
!=
chainID
{
return
nil
,
fmt
.
Errorf
(
"connected to wrong ethereum network: got chainID %d, want %d"
,
chainID
,
o
.
ChainID
)
}
if
o
.
ChainID
!=
-
1
&&
o
.
ChainID
!=
chainID
{
return
nil
,
fmt
.
Errorf
(
"connected to wrong ethereum network: got chainID %d, want %d"
,
chainID
,
o
.
ChainID
)
}
var
debugAPIService
*
debugapi
.
Service
...
...
@@ -266,19 +263,17 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
b
.
debugAPIServer
=
debugAPIServer
}
if
!
o
.
Standalone
{
// Sync the with the given Ethereum backend:
isSynced
,
_
,
err
:=
transaction
.
IsSynced
(
p2pCtx
,
swapBackend
,
maxDelay
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"is synced: %w"
,
err
)
}
if
!
isSynced
{
logger
.
Infof
(
"waiting to sync with the Ethereum backend"
)
// Sync the with the given Ethereum backend:
isSynced
,
_
,
err
:=
transaction
.
IsSynced
(
p2pCtx
,
swapBackend
,
maxDelay
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"is synced: %w"
,
err
)
}
if
!
isSynced
{
logger
.
Infof
(
"waiting to sync with the Ethereum backend"
)
err
:=
transaction
.
WaitSynced
(
p2pCtx
,
logger
,
swapBackend
,
maxDelay
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"waiting backend sync: %w"
,
err
)
}
err
:=
transaction
.
WaitSynced
(
p2pCtx
,
logger
,
swapBackend
,
maxDelay
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"waiting backend sync: %w"
,
err
)
}
}
...
...
@@ -362,7 +357,6 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
NATAddr
:
o
.
NATAddr
,
EnableWS
:
o
.
EnableWS
,
EnableQUIC
:
o
.
EnableQUIC
,
Standalone
:
o
.
Standalone
,
WelcomeMessage
:
o
.
WelcomeMessage
,
FullNode
:
o
.
FullNodeMode
,
Transaction
:
txHash
,
...
...
@@ -422,56 +416,52 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
)
var
postageSyncStart
uint64
=
0
if
!
o
.
Standalone
{
chainCfg
,
found
:=
config
.
GetChainConfig
(
chainID
)
postageContractAddress
,
startBlock
:=
chainCfg
.
PostageStamp
,
chainCfg
.
StartBlock
if
o
.
PostageContractAddress
!=
""
{
if
!
common
.
IsHexAddress
(
o
.
PostageContractAddress
)
{
return
nil
,
errors
.
New
(
"malformed postage stamp address"
)
}
postageContractAddress
=
common
.
HexToAddress
(
o
.
PostageContractAddress
)
}
else
if
!
found
{
return
nil
,
errors
.
New
(
"no known postage stamp addresses for this network"
)
}
if
found
{
postageSyncStart
=
startBlock
chainCfg
,
found
:=
config
.
GetChainConfig
(
chainID
)
postageContractAddress
,
startBlock
:=
chainCfg
.
PostageStamp
,
chainCfg
.
StartBlock
if
o
.
PostageContractAddress
!=
""
{
if
!
common
.
IsHexAddress
(
o
.
PostageContractAddress
)
{
return
nil
,
errors
.
New
(
"malformed postage stamp address"
)
}
postageContractAddress
=
common
.
HexToAddress
(
o
.
PostageContractAddress
)
}
else
if
!
found
{
return
nil
,
errors
.
New
(
"no known postage stamp addresses for this network"
)
}
if
found
{
postageSyncStart
=
startBlock
}
eventListener
=
listener
.
New
(
logger
,
swapBackend
,
postageContractAddress
,
o
.
BlockTime
,
&
pidKiller
{
node
:
b
})
b
.
listenerCloser
=
eventListener
batchSvc
,
err
=
batchservice
.
New
(
stateStore
,
batchStore
,
logger
,
eventListener
,
overlayEthAddress
.
Bytes
(),
post
,
sha3
.
New256
)
if
err
!=
nil
{
return
nil
,
err
}
eventListener
=
listener
.
New
(
logger
,
swapBackend
,
postageContractAddress
,
o
.
BlockTime
,
&
pidKiller
{
node
:
b
})
b
.
listenerCloser
=
eventListener
erc20Address
,
err
:=
postagecontract
.
LookupERC20Address
(
p2pCtx
,
transactionService
,
postageContractAddress
)
if
err
!=
nil
{
return
nil
,
err
}
batchSvc
,
err
=
batchservice
.
New
(
stateStore
,
batchStore
,
logger
,
eventListener
,
overlayEthAddress
.
Bytes
(),
post
,
sha3
.
New256
)
if
err
!=
nil
{
return
nil
,
err
}
postageContractService
=
postagecontract
.
New
(
overlayEthAddress
,
postageContractAddress
,
erc20Address
,
transactionService
,
post
,
)
erc20Address
,
err
:=
postagecontract
.
LookupERC20Address
(
p2pCtx
,
transactionService
,
postageContractAddress
)
if
err
!=
nil
{
return
nil
,
err
}
if
!
o
.
Standalone
{
if
natManager
:=
p2ps
.
NATManager
();
natManager
!=
nil
{
// wait for nat manager to init
logger
.
Debug
(
"initializing NAT manager"
)
select
{
case
<-
natManager
.
Ready
()
:
// this is magic sleep to give NAT time to sync the mappings
// this is a hack, kind of alchemy and should be improved
time
.
Sleep
(
3
*
time
.
Second
)
logger
.
Debug
(
"NAT manager initialized"
)
case
<-
time
.
After
(
10
*
time
.
Second
)
:
logger
.
Warning
(
"NAT manager init timeout"
)
}
postageContractService
=
postagecontract
.
New
(
overlayEthAddress
,
postageContractAddress
,
erc20Address
,
transactionService
,
post
,
)
if
natManager
:=
p2ps
.
NATManager
();
natManager
!=
nil
{
// wait for nat manager to init
logger
.
Debug
(
"initializing NAT manager"
)
select
{
case
<-
natManager
.
Ready
()
:
// this is magic sleep to give NAT time to sync the mappings
// this is a hack, kind of alchemy and should be improved
time
.
Sleep
(
3
*
time
.
Second
)
logger
.
Debug
(
"NAT manager initialized"
)
case
<-
time
.
After
(
10
*
time
.
Second
)
:
logger
.
Warning
(
"NAT manager init timeout"
)
}
}
...
...
@@ -488,19 +478,16 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
}
var
bootnodes
[]
ma
.
Multiaddr
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
)
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
)
}
var
swapService
*
swap
.
Service
...
...
@@ -510,7 +497,7 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
return
nil
,
fmt
.
Errorf
(
"unable to create metrics storage for kademlia: %w"
,
err
)
}
kad
:=
kademlia
.
New
(
swarmAddress
,
addressbook
,
hive
,
p2ps
,
metricsDB
,
logger
,
kademlia
.
Options
{
Bootnodes
:
bootnodes
,
StandaloneMode
:
o
.
Standalone
,
BootnodeMode
:
o
.
BootnodeMode
})
kad
:=
kademlia
.
New
(
swarmAddress
,
addressbook
,
hive
,
p2ps
,
metricsDB
,
logger
,
kademlia
.
Options
{
Bootnodes
:
bootnodes
,
BootnodeMode
:
o
.
BootnodeMode
})
b
.
topologyCloser
=
kad
b
.
topologyHalter
=
kad
hive
.
SetAddPeersHandler
(
kad
.
AddPeers
)
...
...
pkg/p2p/libp2p/libp2p.go
View file @
3ff1214a
...
...
@@ -87,7 +87,6 @@ type Options struct {
NATAddr
string
EnableWS
bool
EnableQUIC
bool
Standalone
bool
FullNode
bool
LightNodeLimit
int
WelcomeMessage
string
...
...
@@ -178,10 +177,6 @@ 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
...
)
...
...
pkg/topology/kademlia/kademlia.go
View file @
3ff1214a
...
...
@@ -66,7 +66,6 @@ var noopSanctionedPeerFn = func(_ swarm.Address) bool { return false }
type
Options
struct
{
SaturationFunc
binSaturationFunc
Bootnodes
[]
ma
.
Multiaddr
StandaloneMode
bool
BootnodeMode
bool
BitSuffixLength
int
}
...
...
@@ -90,7 +89,6 @@ type Kad struct {
peerSig
[]
chan
struct
{}
peerSigMtx
sync
.
Mutex
logger
logging
.
Logger
// logger
standalone
bool
// indicates whether the node is working in standalone mode
bootnode
bool
// indicates whether the node is working in bootnode mode
collector
*
im
.
Collector
quit
chan
struct
{}
// quit channel
...
...
@@ -136,7 +134,6 @@ func New(
manageC
:
make
(
chan
struct
{},
1
),
waitNext
:
waitnext
.
New
(),
logger
:
logger
,
standalone
:
o
.
StandaloneMode
,
bootnode
:
o
.
BootnodeMode
,
collector
:
im
.
NewCollector
(
metricsDB
),
quit
:
make
(
chan
struct
{}),
...
...
@@ -529,10 +526,6 @@ func (k *Kad) manage() {
default
:
}
if
k
.
standalone
{
continue
}
oldDepth
:=
k
.
NeighborhoodDepth
()
k
.
connectNeighbours
(
&
wg
,
peerConnChan
,
peerConnChan2
)
k
.
connectBalanced
(
&
wg
,
peerConnChan2
)
...
...
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