From cbad8d7b5ded7ff614f228a37918d0f2212f1bb8 Mon Sep 17 00:00:00 2001 From: vsmk98 Date: Mon, 13 May 2019 15:29:47 +0800 Subject: [PATCH] permissions: code clean up based on review comments --- cmd/geth/main.go | 1 - cmd/utils/flags.go | 7 ------- core/quorum/api.go | 12 ++++-------- core/tx_pool.go | 2 -- docs/Permissioning/Permissioning apis.md | 2 +- eth/backend.go | 6 ------ 6 files changed, 5 insertions(+), 25 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 9d02c1470..27b73b599 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -137,7 +137,6 @@ var ( utils.EVMInterpreterFlag, configFileFlag, utils.EnableNodePermissionFlag, - utils.PermissionContractAddressFlag, utils.RaftModeFlag, utils.RaftBlockTimeFlag, utils.RaftJoinExistingFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 1b068ad41..e9a1ed99b 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -607,13 +607,6 @@ var ( Usage: "If enabled, the node will allow only a defined list of nodes to connect", } - // Quorum permission contract - PermissionContractAddressFlag = cli.StringFlag{ - Name: "permission.contract", - Usage: "If passed, the node will use this contract to bootstrap permission instead of contract from genesis.json", - Value: "0x", - } - // Istanbul settings IstanbulRequestTimeoutFlag = cli.Uint64Flag{ Name: "istanbul.requesttimeout", diff --git a/core/quorum/api.go b/core/quorum/api.go index d2975083e..0a038ca65 100644 --- a/core/quorum/api.go +++ b/core/quorum/api.go @@ -293,10 +293,8 @@ func (s *QuorumControlsAPI) validateOrg(orgId, pOrgId string) (ExecStatus, error if types.OrgInfoMap.GetOrg(locOrgId) != nil { return ErrOrgExists, errors.New("org exists") } - } else { - if types.OrgInfoMap.GetOrg(orgId) != nil { - return ErrOrgExists, errors.New("org exists") - } + } else if types.OrgInfoMap.GetOrg(orgId) != nil { + return ErrOrgExists, errors.New("org exists") } return ExecSuccess, nil } @@ -334,10 +332,8 @@ func (s *QuorumControlsAPI) valNodeStatusChange(orgId, url string, op int64) (Ex if len(url) == 0 { return ErrInvalidNode, errors.New("invalid node id") } - if execStatus, err := s.valNodeDetails(url); err != nil { - if execStatus != ErrNodePresent { - return execStatus, errors.New("node not found") - } + if execStatus, err := s.valNodeDetails(url); err != nil && execStatus != ErrNodePresent { + return execStatus, errors.New("node not found") } node := types.NodeInfoMap.GetNodeByUrl(url) diff --git a/core/tx_pool.go b/core/tx_pool.go index a79a0c03d..c0cbcd721 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -1333,8 +1333,6 @@ func checkAccount(fromAcct common.Address, toAcct *common.Address) error { case types.Transact: if toAcct == nil { return errors.New("account does not have contract create permissions") - } else { - return nil } } return nil diff --git a/docs/Permissioning/Permissioning apis.md b/docs/Permissioning/Permissioning apis.md index ac4217c1c..7d52e1669 100644 --- a/docs/Permissioning/Permissioning apis.md +++ b/docs/Permissioning/Permissioning apis.md @@ -195,7 +195,7 @@ When an organization is in suspended status, no transactions or contract deploy #### quorumPermission.addSubOrg This api can be executed by a organization admin account to create a sub organization under the master org. -* Input: parent org id, sub organization id, enode id (not mandatory and can be null), account id (not mandatory and can be 0x0) +* Input: parent org id, alphanumeric sub organization id, enode id (not mandatory and can be null), account id (not mandatory and can be 0x0) * Output: Status of the operation * Example: ``` diff --git a/eth/backend.go b/eth/backend.go index 16fba0041..9a8d2dc34 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -343,12 +343,6 @@ func (s *Ethereum) APIs() []rpc.API { Service: quorum.NewQuorumControlsAPI(s.txPool, s.accountManager), Public: true, }, - { - Namespace: "quorumOrgMgmt", - Version: "1.0", - Service: quorum.NewQuorumControlsAPI(s.txPool, s.accountManager), - Public: true, - }, }...) return apis }