mirror of https://github.com/poanetwork/quorum.git
changes to avoid duplicate records in permissioned-nodes.json
This commit is contained in:
parent
4bb8a364a9
commit
412ba4d73d
|
@ -10,6 +10,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
|
@ -238,18 +239,20 @@ func (p *PermissionCtrl) updatePermissionedNodes(enodeId, ipAddrPort, discPort,
|
||||||
newEnodeId := p.formatEnodeId(enodeId, ipAddrPort, discPort, raftPort)
|
newEnodeId := p.formatEnodeId(enodeId, ipAddrPort, discPort, raftPort)
|
||||||
|
|
||||||
// logic to update the permissioned-nodes.json file based on action
|
// logic to update the permissioned-nodes.json file based on action
|
||||||
if operation == NodeAdd {
|
index := 0
|
||||||
nodelist = append(nodelist, newEnodeId)
|
recExists := false
|
||||||
} else {
|
for i, enodeId := range nodelist {
|
||||||
index := 0
|
if strings.EqualFold(enodeId, newEnodeId){
|
||||||
recExists := false
|
index = i
|
||||||
for i, enodeId := range nodelist {
|
recExists = true
|
||||||
if (enodeId == newEnodeId){
|
break
|
||||||
index = i
|
|
||||||
recExists = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if operation == NodeAdd {
|
||||||
|
if !recExists {
|
||||||
|
nodelist = append(nodelist, newEnodeId)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if recExists {
|
if recExists {
|
||||||
nodelist = append(nodelist[:index], nodelist[index+1:]...)
|
nodelist = append(nodelist[:index], nodelist[index+1:]...)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue