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
1fb007e4
Unverified
Commit
1fb007e4
authored
Mar 05, 2021
by
Ralph Pichler
Committed by
GitHub
Mar 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent nodes from starting with a different overlay (#1377)
parent
e043c29e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
7 deletions
+52
-7
deploy.go
cmd/bee/cmd/deploy.go
+10
-5
init.go
cmd/bee/cmd/init.go
+15
-2
node.go
pkg/node/node.go
+5
-0
statestore.go
pkg/node/statestore.go
+22
-0
No files found.
cmd/bee/cmd/deploy.go
View file @
1fb007e4
...
...
@@ -49,17 +49,22 @@ func (c *command) initDeployCmd() error {
stateStore
,
err
:=
node
.
InitStateStore
(
logger
,
dataDir
)
if
err
!=
nil
{
return
return
err
}
defer
stateStore
.
Close
()
signerConfig
,
err
:=
c
.
configureSigner
(
cmd
,
logger
)
if
err
!=
nil
{
return
return
err
}
signer
:=
signerConfig
.
signer
err
=
node
.
CheckOverlayWithStore
(
signerConfig
.
address
,
stateStore
)
if
err
!=
nil
{
return
err
}
ctx
:=
cmd
.
Context
()
swapBackend
,
overlayEthAddress
,
chainID
,
transactionService
,
err
:=
node
.
InitChain
(
...
...
@@ -70,7 +75,7 @@ func (c *command) initDeployCmd() error {
signer
,
)
if
err
!=
nil
{
return
return
err
}
defer
swapBackend
.
Close
()
...
...
@@ -82,7 +87,7 @@ func (c *command) initDeployCmd() error {
factoryAddress
,
)
if
err
!=
nil
{
return
return
err
}
_
,
err
=
node
.
InitChequebookService
(
...
...
@@ -98,7 +103,7 @@ func (c *command) initDeployCmd() error {
swapInitialDeposit
,
)
return
return
err
},
PreRunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
return
c
.
config
.
BindPFlags
(
cmd
.
Flags
())
...
...
cmd/bee/cmd/init.go
View file @
1fb007e4
...
...
@@ -10,6 +10,7 @@ import (
"strings"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/node"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
...
...
@@ -41,8 +42,20 @@ func (c *command) initInitCmd() (err error) {
return
fmt
.
Errorf
(
"unknown verbosity level %q"
,
v
)
}
_
,
err
=
c
.
configureSigner
(
cmd
,
logger
)
return
err
signerConfig
,
err
:=
c
.
configureSigner
(
cmd
,
logger
)
if
err
!=
nil
{
return
err
}
dataDir
:=
c
.
config
.
GetString
(
optionNameDataDir
)
stateStore
,
err
:=
node
.
InitStateStore
(
logger
,
dataDir
)
if
err
!=
nil
{
return
err
}
defer
stateStore
.
Close
()
return
node
.
CheckOverlayWithStore
(
signerConfig
.
address
,
stateStore
)
},
PreRunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
return
c
.
config
.
BindPFlags
(
cmd
.
Flags
())
...
...
pkg/node/node.go
View file @
1fb007e4
...
...
@@ -167,6 +167,11 @@ func NewBee(addr string, swarmAddress swarm.Address, publicKey ecdsa.PublicKey,
}
b
.
stateStoreCloser
=
stateStore
err
=
CheckOverlayWithStore
(
swarmAddress
,
stateStore
)
if
err
!=
nil
{
return
nil
,
err
}
addressbook
:=
addressbook
.
New
(
stateStore
)
var
swapBackend
*
ethclient
.
Client
...
...
pkg/node/statestore.go
View file @
1fb007e4
...
...
@@ -5,12 +5,15 @@
package
node
import
(
"errors"
"fmt"
"path/filepath"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/statestore/leveldb"
"github.com/ethersphere/bee/pkg/statestore/mock"
"github.com/ethersphere/bee/pkg/storage"
"github.com/ethersphere/bee/pkg/swarm"
)
// InitStateStore will initialze the stateStore with the given path to the
...
...
@@ -24,3 +27,22 @@ func InitStateStore(log logging.Logger, dataDir string) (ret storage.StateStorer
}
return
leveldb
.
NewStateStore
(
filepath
.
Join
(
dataDir
,
"statestore"
),
log
)
}
const
overlayKey
=
"overlay"
// CheckOverlayWithStore checks the overlay is the same as stored in the statestore
func
CheckOverlayWithStore
(
overlay
swarm
.
Address
,
storer
storage
.
StateStorer
)
error
{
var
storedOverlay
swarm
.
Address
err
:=
storer
.
Get
(
overlayKey
,
&
storedOverlay
)
if
err
!=
nil
{
if
!
errors
.
Is
(
err
,
storage
.
ErrNotFound
)
{
return
err
}
return
storer
.
Put
(
overlayKey
,
overlay
)
}
if
!
storedOverlay
.
Equal
(
overlay
)
{
return
fmt
.
Errorf
(
"overlay address changed. was %s before but now is %s"
,
storedOverlay
,
overlay
)
}
return
nil
}
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