Skip to content

Commit

Permalink
Merge pull request #125 from 0chain/initialState
Browse files Browse the repository at this point in the history
Fixed initial state panic for non genesis miners.
  • Loading branch information
Kenwes13 committed Mar 24, 2021
2 parents 0f0c84c + abe69bb commit af1e32f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions code/go/0chain.net/miner/miner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ func main() {
}

initStates := state.NewInitStates()
err = initStates.Read(*initialStatesFile)
if err != nil {
Logger.Panic("Failed to read initialStates", zap.Any("Error", err))
}
initStateErr := initStates.Read(*initialStatesFile)

// if there's no magic_block_file commandline flag, use configured then
if *magicBlockFile == "" {
Expand Down Expand Up @@ -149,6 +146,10 @@ func main() {
node.Self.Underlying().N2NHost = n2nHostName
node.Self.Underlying().Port = portNum
node.Self.Underlying().Path = path
} else {
if initStateErr != nil {
Logger.Panic("Failed to read initialStates", zap.Any("Error", initStateErr))
}
}

if node.Self.Underlying().GetKey() == "" {
Expand Down
9 changes: 5 additions & 4 deletions code/go/0chain.net/sharder/sharder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,7 @@ func main() {
}

initStates := state.NewInitStates()
err = initStates.Read(*initialStatesFile)
if err != nil {
Logger.Panic("Failed to read initialStates", zap.Any("Error", err))
}
initStateErr := initStates.Read(*initialStatesFile)

// if there's no magic_block_file commandline flag, use configured then
if *magicBlockFile == "" {
Expand Down Expand Up @@ -200,6 +197,10 @@ func main() {
selfNode.Port = portNum
selfNode.Type = node.NodeTypeSharder
selfNode.Path = path
} else {
if initStateErr != nil {
Logger.Panic("Failed to read initialStates", zap.Any("Error", initStateErr))
}
}
if selfNode.Type != node.NodeTypeSharder {
Logger.Panic("node not configured as sharder")
Expand Down

0 comments on commit af1e32f

Please sign in to comment.