format code

This commit is contained in:
amalraj.manigmail.com 2018-11-14 18:24:28 +08:00
parent 405204cd23
commit 9628cb5e2b
4 changed files with 26 additions and 24 deletions

View File

@ -362,7 +362,7 @@ func startNode(ctx *cli.Context, stack *node.Node) {
func startQuorumPermissionService(ctx *cli.Context, stack *node.Node) {
// start the permissions management service
pc, err := permission.NewQuorumPermissionCtrl(stack, ctx.GlobalBool(utils.EnableNodePermissionFlag.Name),ctx.GlobalBool(utils.RaftModeFlag.Name))
pc, err := permission.NewQuorumPermissionCtrl(stack, ctx.GlobalBool(utils.EnableNodePermissionFlag.Name), ctx.GlobalBool(utils.RaftModeFlag.Name))
if err != nil {
utils.Fatalf("Failed to start Quorum Permission contract service: %v", err)
}

View File

@ -3,8 +3,8 @@ package permission
import (
"crypto/ecdsa"
"encoding/json"
"fmt"
"errors"
"fmt"
"io/ioutil"
"math/big"
"os"
@ -38,14 +38,14 @@ const (
)
type PermissionCtrl struct {
node *node.Node
ethClnt *ethclient.Client
eth *eth.Ethereum
isRaft bool
node *node.Node
ethClnt *ethclient.Client
eth *eth.Ethereum
isRaft bool
permissionedMode bool
key *ecdsa.PrivateKey
dataDir string
pm *pbind.Permissions
key *ecdsa.PrivateKey
dataDir string
pm *pbind.Permissions
}
// Creates the controls structure for permissions
@ -345,7 +345,7 @@ func (p *PermissionCtrl) populateAcctPermissions() error {
for recExists {
recExists = pastEvents.Next()
if recExists {
log.Info("SMK-populateAcctPermissions @344 ", "Account", pastEvents.Event.Address, "access",pastEvents.Event.Access)
log.Info("SMK-populateAcctPermissions @344 ", "Account", pastEvents.Event.Address, "access", pastEvents.Event.Access)
types.AddAccountAccess(pastEvents.Event.Address, pastEvents.Event.Access)
}
}
@ -442,7 +442,7 @@ func (p *PermissionCtrl) populateInitPermission() error {
log.Info("SMK-populateInitPermission @447")
}
if !p.permissionedMode{
if !p.permissionedMode {
return errors.New("Node started in non-permissioned mode")
log.Info("SMK-populateInitPermission @452")
}

View File

@ -73,7 +73,7 @@ type txArgs struct {
}
type nodeStatus struct {
Name string
Name string
Status string
}
@ -90,7 +90,7 @@ func NewPermissionAPI(tp *core.TxPool, am *accounts.Manager) *PermissionAPI {
// helper function decodes the node status to string
func decodeNodeStatus(nodeStatus uint8) string {
var status string
switch nodeStatus{
switch nodeStatus {
case 0:
status = "Unknown"
case 1:
@ -131,7 +131,7 @@ func (p *PermissionAPI) Init(ethClnt *ethclient.Client, key *ecdsa.PrivateKey) e
return nil
}
// Returns the list of Nodes and status of each
// Returns the list of Nodes and status of each
func (s *PermissionAPI) PermissionNodeList() []nodeStatus {
auth := bind.NewKeyedTransactor(s.key)
ps := &pbind.PermissionsSession{
@ -153,9 +153,9 @@ func (s *PermissionAPI) PermissionNodeList() []nodeStatus {
// loop for each index and get the node details from the contract
if err == nil {
i := int64(0)
for nodeCnt.Cmp(big.NewInt(i)) > 0{
for nodeCnt.Cmp(big.NewInt(i)) > 0 {
nodeDtls, _ := ps.GetNodeDetails(big.NewInt(i))
nodeStatArr[i].Name = "enode://"+ nodeDtls.EnodeId + "@" +nodeDtls.IpAddrPort
nodeStatArr[i].Name = "enode://" + nodeDtls.EnodeId + "@" + nodeDtls.IpAddrPort
nodeStatArr[i].Name += "?discport=" + nodeDtls.DiscPort
if len(nodeDtls.RaftPort) > 0 {
nodeStatArr[i].Name += "&raftport" + nodeDtls.RaftPort
@ -254,7 +254,7 @@ func (s *PermissionAPI) executePermAction(action PermAction, args txArgs) ExecSt
tx, err = ps.RemoveVoter(args.voter)
case ProposeNode:
if !checkVoterExists(ps){
if !checkVoterExists(ps) {
return voterErr
}
node, err = discover.ParseNode(args.nodeId)
@ -272,7 +272,7 @@ func (s *PermissionAPI) executePermAction(action PermAction, args txArgs) ExecSt
tx, err = ps.ProposeNode(enodeID, ipAddrPort, discPort, raftPort)
case ApproveNode:
if !checkIsVoter(ps, args.txa.From){
if !checkIsVoter(ps, args.txa.From) {
return voterErr
}
node, err = discover.ParseNode(args.nodeId)
@ -284,7 +284,7 @@ func (s *PermissionAPI) executePermAction(action PermAction, args txArgs) ExecSt
tx, err = ps.ApproveNode(enodeID)
case ProposeNodeDeactivation:
if !checkVoterExists(ps){
if !checkVoterExists(ps) {
return voterErr
}
node, err = discover.ParseNode(args.nodeId)
@ -296,7 +296,7 @@ func (s *PermissionAPI) executePermAction(action PermAction, args txArgs) ExecSt
tx, err = ps.ProposeDeactivation(enodeID)
case ApproveNodeDeactivation:
if !checkIsVoter(ps, args.txa.From){
if !checkIsVoter(ps, args.txa.From) {
return voterErr
}
node, err = discover.ParseNode(args.nodeId)
@ -308,7 +308,7 @@ func (s *PermissionAPI) executePermAction(action PermAction, args txArgs) ExecSt
tx, err = ps.DeactivateNode(enodeID)
case ProposeNodeActivation:
if !checkVoterExists(ps){
if !checkVoterExists(ps) {
return voterErr
}
node, err = discover.ParseNode(args.nodeId)
@ -320,7 +320,7 @@ func (s *PermissionAPI) executePermAction(action PermAction, args txArgs) ExecSt
tx, err = ps.ProposeNodeActivation(enodeID)
case ApproveNodeActivation:
if !checkIsVoter(ps, args.txa.From){
if !checkIsVoter(ps, args.txa.From) {
return voterErr
}
node, err = discover.ParseNode(args.nodeId)
@ -332,7 +332,7 @@ func (s *PermissionAPI) executePermAction(action PermAction, args txArgs) ExecSt
tx, err = ps.ActivateNode(enodeID)
case ProposeNodeBlacklisting:
if !checkVoterExists(ps){
if !checkVoterExists(ps) {
return voterErr
}
node, err = discover.ParseNode(args.nodeId)
@ -349,7 +349,7 @@ func (s *PermissionAPI) executePermAction(action PermAction, args txArgs) ExecSt
tx, err = ps.ProposeNodeBlacklisting(enodeID, ipAddrPort, discPort, raftPort)
case ApproveNodeBlacklisting:
if !checkIsVoter(ps, args.txa.From){
if !checkIsVoter(ps, args.txa.From) {
return voterErr
}
node, err = discover.ParseNode(args.nodeId)
@ -428,6 +428,7 @@ func checkIsVoter(ps *pbind.PermissionsSession, acctId common.Address) bool {
}
return false
}
// newPermSession creates a new permission contract session
func (s *PermissionAPI) newPermSession(w accounts.Wallet, txa ethapi.SendTxArgs) *pbind.PermissionsSession {
frmAcct, transactOpts, gasLimit, gasPrice, nonce := s.getTxParams(txa, w)

View File

@ -23,6 +23,7 @@ type OrgStruct struct {
OrgId string
Keys []string
}
var DefaultAccess = FullAccess
const acctMapLimit = 100