Fixing problem on duplicated join in goloop
@@ -202,11 +202,19 @@ func (n *Node) JoinChain(
return nil, errors.Wrap(err, "fail to get NID for genesis")
}
+ if _, ok := n.channels[nid]; ok {
+ return nil, errors.Wrapf(ErrAlreadyExists, "Network(id=%#x) already exists", nid)
+ }
+
channel := p.Channel
if channel == "" {
channel = strconv.FormatInt(int64(nid), 16)
}
+ if _, ok := n.chains[channel]; ok {
+ return nil, errors.Wrapf(ErrAlreadyExists, "Network(channel=%s) already exists", channel)
+ }
+
chainDir := n.ChainDir(nid)
log.Println("ChainDir", chainDir)
if err := os.MkdirAll(chainDir, 0700); err != nil {
@@ -224,7 +232,6 @@ func (n *Node) JoinChain(
SeedAddr: p.SeedAddr,
Role: p.Role,
GenesisStorage: genesisStorage,
- // GenesisDataPath: path.Join(chainDir, "genesis"),
ConcurrencyLevel: p.ConcurrencyLevel,
NormalTxPoolSize: p.NormalTxPoolSize,
PatchTxPoolSize: p.PatchTxPoolSize,
