handled null pointer error for permissioned node and account list when network is brought in non-permissioned mode

This commit is contained in:
vsmk98 2018-11-20 22:36:24 +08:00
parent cdf0e0dd5e
commit 939142786e
1 changed files with 10 additions and 0 deletions

View File

@ -156,6 +156,11 @@ func (p *PermissionAPI) Init(ethClnt *ethclient.Client, key *ecdsa.PrivateKey) e
// Returns the list of Nodes and status of each
func (s *PermissionAPI) PermissionNodeList() []nodeStatus {
if !s.enabled {
nodeStatArr := make([]nodeStatus, 1)
nodeStatArr[0].EnodeId = "Permisssions control not enabled for network"
return nodeStatArr
}
ps := s.newPermSessionWithNodeKeySigner()
// get the total number of nodes on the contract
nodeCnt, err := ps.GetNumberOfNodes()
@ -184,6 +189,11 @@ func (s *PermissionAPI) PermissionNodeList() []nodeStatus {
}
func (s *PermissionAPI) PermissionAccountList() []accountInfo {
if !s.enabled {
acctInfoArr := make([]accountInfo, 1)
acctInfoArr[0].Address = "Account access control not enable for the network"
return acctInfoArr
}
ps := s.newPermSessionWithNodeKeySigner()
// get the total number of accounts with permissions
acctCnt, err := ps.GetNumberOfAccounts()