mirror of https://github.com/poanetwork/quorum.git
permission: refactor dir structure for contract
This commit is contained in:
parent
3aad59fc58
commit
468478be78
|
@ -20,9 +20,9 @@ import (
|
|||
"bufio"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/ethereum/go-ethereum/controls/permission"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/permission"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -210,7 +210,7 @@ func RegisterPermissionService(ctx *cli.Context, stack *node.Node) {
|
|||
var permissionConfig types.PermissionConfig
|
||||
var err error
|
||||
if permissionConfig, err = permission.ParsePermissionConifg(dataDir); err != nil {
|
||||
utils.Fatalf("loading of permission-config.json failed", "error")
|
||||
utils.Fatalf("loading of permission-config.json failed", "error", err)
|
||||
}
|
||||
|
||||
// start the permissions management service
|
||||
|
|
|
@ -284,6 +284,7 @@ func geth(ctx *cli.Context) error {
|
|||
// it unlocks any requested accounts, and starts the RPC/IPC interfaces and the
|
||||
// miner.
|
||||
func startNode(ctx *cli.Context, stack *node.Node) {
|
||||
log.Info("AJ-start node1")
|
||||
log.DoEmitCheckpoints = ctx.GlobalBool(utils.EmitCheckpointsFlag.Name)
|
||||
debug.Memsize.Add("node", stack)
|
||||
|
||||
|
|
|
@ -64,6 +64,8 @@ func Fatalf(format string, args ...interface{}) {
|
|||
}
|
||||
|
||||
func StartNode(stack *node.Node) {
|
||||
log.Info("AJ-start node2")
|
||||
|
||||
if err := stack.Start(); err != nil {
|
||||
Fatalf("Error starting protocol stack: %v", err)
|
||||
}
|
||||
|
|
10
node/node.go
10
node/node.go
|
@ -150,6 +150,8 @@ func (n *Node) Register(constructor ServiceConstructor) error {
|
|||
|
||||
// Start create a live P2P node and starts running it.
|
||||
func (n *Node) Start() error {
|
||||
log.Info("AJ-start node3")
|
||||
|
||||
n.lock.Lock()
|
||||
defer n.lock.Unlock()
|
||||
|
||||
|
@ -183,7 +185,8 @@ func (n *Node) Start() error {
|
|||
|
||||
// Otherwise copy and specialize the P2P configuration
|
||||
services := make(map[reflect.Type]Service)
|
||||
for _, constructor := range n.serviceFuncs {
|
||||
|
||||
for ct, constructor := range n.serviceFuncs {
|
||||
// Create a new context for the particular service
|
||||
ctx := &ServiceContext{
|
||||
config: n.config,
|
||||
|
@ -194,12 +197,16 @@ func (n *Node) Start() error {
|
|||
for kind, s := range services { // copy needed for threaded access
|
||||
ctx.services[kind] = s
|
||||
}
|
||||
log.Info("AJ-construct service1", "ct", ct, "Cons", constructor)
|
||||
|
||||
// Construct and save the service
|
||||
service, err := constructor(ctx)
|
||||
log.Info("AJ-construct service2", "service", service)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
kind := reflect.TypeOf(service)
|
||||
log.Info("AJ-construct service3", "ct", ct, "kind", kind)
|
||||
if _, exists := services[kind]; exists {
|
||||
return &DuplicateServiceError{Kind: kind}
|
||||
}
|
||||
|
@ -215,6 +222,7 @@ func (n *Node) Start() error {
|
|||
// Start each of the services
|
||||
started := []reflect.Type{}
|
||||
for kind, service := range services {
|
||||
log.Info("AJ-start service ", "kind", kind, "srv", service)
|
||||
// Start the next service, stopping all previous upon failure
|
||||
if err := service.Start(running); err != nil {
|
||||
for _, kind := range started {
|
||||
|
|
|
@ -109,10 +109,6 @@ func populateConfig(config PermissionLocalConfig) types.PermissionConfig {
|
|||
func ParsePermissionConifg(dir string) (types.PermissionConfig, error) {
|
||||
fileName := "permission-config.json"
|
||||
fullPath := filepath.Join(dir, fileName)
|
||||
if _, err := os.Stat(fullPath); err != nil {
|
||||
log.Warn("permission-config.json file is missing", err)
|
||||
return types.PermissionConfig{}, err
|
||||
}
|
||||
|
||||
blob, err := ioutil.ReadFile(fullPath)
|
||||
|
||||
|
@ -152,7 +148,7 @@ func waitForSync(e *eth.Ethereum) {
|
|||
func NewQuorumPermissionCtrl(stack *node.Node, permissionedMode, isRaft bool, pconfig *types.PermissionConfig) (*PermissionCtrl, error) {
|
||||
// Create a new ethclient to for interfacing with the contract
|
||||
clnt, e, err := controls.CreateEthClient(stack)
|
||||
waitForSync(e)
|
||||
//waitForSync(e)
|
||||
if err != nil {
|
||||
log.Error("Unable to create ethereum client for permissions check", "err", err)
|
||||
return nil, err
|
||||
|
@ -203,6 +199,7 @@ func NewQuorumPermissionCtrl(stack *node.Node, permissionedMode, isRaft bool, pc
|
|||
// Starts the node permissioning and event monitoring for permissions
|
||||
// smart contracts
|
||||
func (p *PermissionCtrl) Start(srvr *p2p.Server) error {
|
||||
log.Info("permission service started...")
|
||||
// Permissions initialization
|
||||
if err := p.init(); err != nil {
|
||||
log.Error("Permissions init failed", "err", err)
|
Loading…
Reference in New Issue