[#1573] node: Simplify bootstrapWithState()
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 4m29s
Pre-commit hooks / Pre-commit (pull_request) Successful in 5m8s
Tests and linters / Tests with -race (pull_request) Successful in 8m24s
DCO action / DCO (pull_request) Successful in 11m41s
Build / Build Components (pull_request) Successful in 13m35s
Tests and linters / Tests (pull_request) Successful in 13m35s
Tests and linters / Staticcheck (pull_request) Successful in 13m51s
Tests and linters / gopls check (pull_request) Successful in 14m35s
Tests and linters / Lint (pull_request) Successful in 14m54s
Vulncheck / Vulncheck (pull_request) Successful in 2m31s
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 4m29s
Pre-commit hooks / Pre-commit (pull_request) Successful in 5m8s
Tests and linters / Tests with -race (pull_request) Successful in 8m24s
DCO action / DCO (pull_request) Successful in 11m41s
Build / Build Components (pull_request) Successful in 13m35s
Tests and linters / Tests (pull_request) Successful in 13m35s
Tests and linters / Staticcheck (pull_request) Successful in 13m51s
Tests and linters / gopls check (pull_request) Successful in 14m35s
Tests and linters / Lint (pull_request) Successful in 14m54s
Vulncheck / Vulncheck (pull_request) Successful in 2m31s
After #1382 we have no need to use lambdas. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
df05057ed4
commit
9e6341849b
1 changed files with 4 additions and 8 deletions
|
@ -1220,9 +1220,9 @@ func (c *cfg) updateContractNodeInfo(ctx context.Context, epoch uint64) {
|
|||
// bootstrapWithState calls "addPeer" method of the Sidechain Netmap contract
|
||||
// with the binary-encoded information from the current node's configuration.
|
||||
// The state is set using the provided setter which MUST NOT be nil.
|
||||
func (c *cfg) bootstrapWithState(ctx context.Context, stateSetter func(*netmap.NodeInfo)) error {
|
||||
func (c *cfg) bootstrapWithState(ctx context.Context, state netmap.NodeState) error {
|
||||
ni := c.cfgNodeInfo.localInfo
|
||||
stateSetter(&ni)
|
||||
ni.SetStatus(state)
|
||||
|
||||
prm := nmClient.AddPeerPrm{}
|
||||
prm.SetNodeInfo(ni)
|
||||
|
@ -1232,9 +1232,7 @@ func (c *cfg) bootstrapWithState(ctx context.Context, stateSetter func(*netmap.N
|
|||
|
||||
// bootstrapOnline calls cfg.bootstrapWithState with "online" state.
|
||||
func bootstrapOnline(ctx context.Context, c *cfg) error {
|
||||
return c.bootstrapWithState(ctx, func(ni *netmap.NodeInfo) {
|
||||
ni.SetStatus(netmap.Online)
|
||||
})
|
||||
return c.bootstrapWithState(ctx, netmap.Online)
|
||||
}
|
||||
|
||||
// bootstrap calls bootstrapWithState with:
|
||||
|
@ -1245,9 +1243,7 @@ func (c *cfg) bootstrap(ctx context.Context) error {
|
|||
st := c.cfgNetmap.state.controlNetmapStatus()
|
||||
if st == control.NetmapStatus_MAINTENANCE {
|
||||
c.log.Info(ctx, logs.FrostFSNodeBootstrappingWithTheMaintenanceState)
|
||||
return c.bootstrapWithState(ctx, func(ni *netmap.NodeInfo) {
|
||||
ni.SetStatus(netmap.Maintenance)
|
||||
})
|
||||
return c.bootstrapWithState(ctx, netmap.Maintenance)
|
||||
}
|
||||
|
||||
c.log.Info(ctx, logs.FrostFSNodeBootstrappingWithOnlineState,
|
||||
|
|
Loading…
Reference in a new issue