[node] fix print message if db already occupied

pull/3364/head
Jacky Wang 4 years ago committed by Leo Chen
parent a551c05ed8
commit 5b954b84ca
  1. 2
      internal/shardchain/shardchains.go
  2. 19
      node/node.go

@ -77,7 +77,7 @@ func (sc *CollectionImpl) ShardChain(shardID uint32) (*core.BlockChain, error) {
// NewChainDB may return incompletely initialized DB;
// avoid closing it.
db = nil
return nil, errors.New("cannot open chain database")
return nil, errors.Wrap(err, "cannot open chain database")
}
if rawdb.ReadCanonicalHash(db, 0) == (common.Hash{}) {
utils.Logger().Info().

@ -885,16 +885,15 @@ func New(
blockchain := node.Blockchain() // this also sets node.isFirstTime if the DB is fresh
beaconChain := node.Beaconchain()
if b1, b2 := beaconChain == nil, blockchain == nil; b1 || b2 {
shardID := node.NodeConfig.ShardID
// HACK get the real error reason
_, err := node.shardChains.ShardChain(shardID)
fmt.Fprintf(
os.Stderr,
"reason:%s beaconchain-is-nil:%t shardchain-is-nil:%t",
err.Error(), b1, b2,
)
var err error
if blockchain == nil {
shardID := node.NodeConfig.ShardID
// HACK get the real error reason
_, err = node.shardChains.ShardChain(shardID)
} else {
_, err = node.shardChains.ShardChain(shard.BeaconChainShardID)
}
fmt.Fprintf(os.Stderr, "Cannot initialize node: %v\n", err)
os.Exit(-1)
}

Loading…
Cancel
Save