permission: merge with code improvements to contract and api

This commit is contained in:
amalraj.manigmail.com 2019-04-08 19:49:51 +08:00
commit cf97fde8d9
25 changed files with 547 additions and 4447 deletions

View File

@ -28,7 +28,7 @@ var (
)
// OrgManagerABI is the input ABI used to generate the binding from.
const OrgManagerABI = "[{\"constant\":false,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"},{\"name\":\"_status\",\"type\":\"uint256\"}],\"name\":\"updateOrg\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"getOrgIndex\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"},{\"name\":\"_status\",\"type\":\"uint256\"}],\"name\":\"approveOrgStatusUpdate\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"addAdminOrg\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgIndex\",\"type\":\"uint256\"}],\"name\":\"getOrgInfo\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getNumberOfOrgs\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"},{\"name\":\"_orgStatus\",\"type\":\"uint256\"}],\"name\":\"checkOrgStatus\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getImpl\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"approveOrg\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"addOrg\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"getOrgStatus\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"checkOrgExists\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_permUpgradable\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"OrgApproved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_orgId\",\"type\":\"string\"},{\"indexed\":false,\"name\":\"_type\",\"type\":\"uint256\"}],\"name\":\"OrgPendingApproval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"OrgSuspended\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"OrgSuspensionRevoked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_msg\",\"type\":\"string\"}],\"name\":\"Dummy\",\"type\":\"event\"}]"
const OrgManagerABI = "[{\"constant\":false,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"},{\"name\":\"_status\",\"type\":\"uint256\"}],\"name\":\"updateOrg\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"getOrgIndex\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"},{\"name\":\"_status\",\"type\":\"uint256\"}],\"name\":\"approveOrgStatusUpdate\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"addAdminOrg\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgIndex\",\"type\":\"uint256\"}],\"name\":\"getOrgInfo\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getNumberOfOrgs\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"},{\"name\":\"_orgStatus\",\"type\":\"uint256\"}],\"name\":\"checkOrgStatus\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getImpl\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"approveOrg\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"addOrg\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"getOrgStatus\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"checkOrgExists\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_permUpgradable\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"OrgApproved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_orgId\",\"type\":\"string\"},{\"indexed\":false,\"name\":\"_type\",\"type\":\"uint256\"}],\"name\":\"OrgPendingApproval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"OrgSuspended\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"OrgSuspensionRevoked\",\"type\":\"event\"}]"
// OrgManager is an auto generated Go binding around an Ethereum contract.
type OrgManager struct {
@ -463,128 +463,6 @@ func (_OrgManager *OrgManagerTransactorSession) UpdateOrg(_orgId string, _status
return _OrgManager.Contract.UpdateOrg(&_OrgManager.TransactOpts, _orgId, _status)
}
// OrgManagerDummyIterator is returned from FilterDummy and is used to iterate over the raw logs and unpacked data for Dummy events raised by the OrgManager contract.
type OrgManagerDummyIterator struct {
Event *OrgManagerDummy // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *OrgManagerDummyIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(OrgManagerDummy)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(OrgManagerDummy)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *OrgManagerDummyIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *OrgManagerDummyIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// OrgManagerDummy represents a Dummy event raised by the OrgManager contract.
type OrgManagerDummy struct {
Msg string
Raw types.Log // Blockchain specific contextual infos
}
// FilterDummy is a free log retrieval operation binding the contract event 0xe4909ae09a5f09db1c974cfab835cf594054bde73d77a5bd128f2d5842036a66.
//
// Solidity: e Dummy(_msg string)
func (_OrgManager *OrgManagerFilterer) FilterDummy(opts *bind.FilterOpts) (*OrgManagerDummyIterator, error) {
logs, sub, err := _OrgManager.contract.FilterLogs(opts, "Dummy")
if err != nil {
return nil, err
}
return &OrgManagerDummyIterator{contract: _OrgManager.contract, event: "Dummy", logs: logs, sub: sub}, nil
}
// WatchDummy is a free log subscription operation binding the contract event 0xe4909ae09a5f09db1c974cfab835cf594054bde73d77a5bd128f2d5842036a66.
//
// Solidity: e Dummy(_msg string)
func (_OrgManager *OrgManagerFilterer) WatchDummy(opts *bind.WatchOpts, sink chan<- *OrgManagerDummy) (event.Subscription, error) {
logs, sub, err := _OrgManager.contract.WatchLogs(opts, "Dummy")
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(OrgManagerDummy)
if err := _OrgManager.contract.UnpackLog(event, "Dummy", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// OrgManagerOrgApprovedIterator is returned from FilterOrgApproved and is used to iterate over the raw logs and unpacked data for OrgApproved events raised by the OrgManager contract.
type OrgManagerOrgApprovedIterator struct {
Event *OrgManagerOrgApproved // Event containing the contract specifics and raw log

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -28,7 +28,7 @@ var (
)
// VoterManagerABI is the input ABI used to generate the binding from.
const VoterManagerABI = "[{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"},{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"checkIfVoterExists\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"getPendingOpDetails\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"address\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"getVoteCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"},{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"addVoter\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"},{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"deleteVoter\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"getNumberOfValidVoters\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"getNumberOfVoters\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_authOrg\",\"type\":\"string\"},{\"name\":\"_vAccount\",\"type\":\"address\"},{\"name\":\"_pendingOp\",\"type\":\"uint256\"}],\"name\":\"processVote\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"checkVotingAccountExists\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_authOrg\",\"type\":\"string\"},{\"name\":\"_orgId\",\"type\":\"string\"},{\"name\":\"_enodeId\",\"type\":\"string\"},{\"name\":\"_account\",\"type\":\"address\"},{\"name\":\"_pendingOp\",\"type\":\"uint256\"}],\"name\":\"addVotingItem\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_permUpgradable\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_orgId\",\"type\":\"string\"},{\"indexed\":false,\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"VoterAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_orgId\",\"type\":\"string\"},{\"indexed\":false,\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"VoterDeleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"VotingItemAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"VoteProcessed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_msg\",\"type\":\"string\"}],\"name\":\"Dummy\",\"type\":\"event\"}]"
const VoterManagerABI = "[{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"},{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"checkIfVoterExists\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"getPendingOpDetails\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"address\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"getVoteCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"},{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"addVoter\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"},{\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"deleteVoter\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"getNumberOfValidVoters\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"getNumberOfVoters\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_authOrg\",\"type\":\"string\"},{\"name\":\"_vAccount\",\"type\":\"address\"},{\"name\":\"_pendingOp\",\"type\":\"uint256\"}],\"name\":\"processVote\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"checkVotingAccountExists\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_authOrg\",\"type\":\"string\"},{\"name\":\"_orgId\",\"type\":\"string\"},{\"name\":\"_enodeId\",\"type\":\"string\"},{\"name\":\"_account\",\"type\":\"address\"},{\"name\":\"_pendingOp\",\"type\":\"uint256\"}],\"name\":\"addVotingItem\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_permUpgradable\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_orgId\",\"type\":\"string\"},{\"indexed\":false,\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"VoterAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_orgId\",\"type\":\"string\"},{\"indexed\":false,\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"VoterDeleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"VotingItemAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_orgId\",\"type\":\"string\"}],\"name\":\"VoteProcessed\",\"type\":\"event\"}]"
// VoterManager is an auto generated Go binding around an Ethereum contract.
type VoterManager struct {
@ -424,128 +424,6 @@ func (_VoterManager *VoterManagerTransactorSession) ProcessVote(_authOrg string,
return _VoterManager.Contract.ProcessVote(&_VoterManager.TransactOpts, _authOrg, _vAccount, _pendingOp)
}
// VoterManagerDummyIterator is returned from FilterDummy and is used to iterate over the raw logs and unpacked data for Dummy events raised by the VoterManager contract.
type VoterManagerDummyIterator struct {
Event *VoterManagerDummy // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *VoterManagerDummyIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(VoterManagerDummy)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(VoterManagerDummy)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *VoterManagerDummyIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *VoterManagerDummyIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// VoterManagerDummy represents a Dummy event raised by the VoterManager contract.
type VoterManagerDummy struct {
Msg string
Raw types.Log // Blockchain specific contextual infos
}
// FilterDummy is a free log retrieval operation binding the contract event 0xe4909ae09a5f09db1c974cfab835cf594054bde73d77a5bd128f2d5842036a66.
//
// Solidity: e Dummy(_msg string)
func (_VoterManager *VoterManagerFilterer) FilterDummy(opts *bind.FilterOpts) (*VoterManagerDummyIterator, error) {
logs, sub, err := _VoterManager.contract.FilterLogs(opts, "Dummy")
if err != nil {
return nil, err
}
return &VoterManagerDummyIterator{contract: _VoterManager.contract, event: "Dummy", logs: logs, sub: sub}, nil
}
// WatchDummy is a free log subscription operation binding the contract event 0xe4909ae09a5f09db1c974cfab835cf594054bde73d77a5bd128f2d5842036a66.
//
// Solidity: e Dummy(_msg string)
func (_VoterManager *VoterManagerFilterer) WatchDummy(opts *bind.WatchOpts, sink chan<- *VoterManagerDummy) (event.Subscription, error) {
logs, sub, err := _VoterManager.contract.WatchLogs(opts, "Dummy")
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(VoterManagerDummy)
if err := _VoterManager.contract.UnpackLog(event, "Dummy", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// VoterManagerVoteProcessedIterator is returned from FilterVoteProcessed and is used to iterate over the raw logs and unpacked data for VoteProcessed events raised by the VoterManager contract.
type VoterManagerVoteProcessedIterator struct {
Event *VoterManagerVoteProcessed // Event containing the contract specifics and raw log

View File

@ -89,8 +89,9 @@ contract NodeManager {
onlyImpl
enodeNotInList(_enodeId)
{
addNode(_enodeId, _orgId);
approveNode(_enodeId, _orgId);
numberOfNodes++;
nodeIdToIndex[keccak256(abi.encodePacked(_enodeId))] = numberOfNodes;
nodeList.push(NodeDetails(_enodeId, _orgId, 2));
}
function addNode(string memory _enodeId, string memory _orgId) public
onlyImpl
@ -134,7 +135,7 @@ contract NodeManager {
require(checkOrg(_enodeId, _orgId), "Node does not belong to the org");
// changing node status to integer (0-NotInList, 1- PendingApproval, 2-Approved, 3-Deactivated, 4-Blacklisted)
// operations that can be done 3-Deactivate Node, 4-ActivateNode, 5-Blacklist nodeList
require((_status == 2 || _status == 3 || _status == 4 || _status == 5), "invalid operation");
require((_status == 3 || _status == 4 || _status == 5), "invalid operation");
if (_status == 3){
require(getNodeStatus(_enodeId) == 2, "Op cannot be performed");

View File

@ -30,8 +30,6 @@ contract OrgManager {
event OrgSuspended(string _orgId);
event OrgSuspensionRevoked(string _orgId);
event Dummy(string _msg);
modifier onlyImpl
{
require(msg.sender == permUpgradable.getPermImpl());

View File

@ -1,488 +0,0 @@
pragma solidity ^0.5.0;
contract Permissions {
address[] initialAcctList;
// enum and struct declaration
enum NodeStatus {NotInList, PendingApproval, Approved, PendingDeactivation, Deactivated, PendingActivation, PendingBlacklisting, Blacklisted }
struct NodeDetails {
string enodeId; //e.g. 127.0.0.1:20005
string ipAddrPort;
string discPort;
string raftPort;
NodeStatus status;
}
// use an array to store node details
NodeDetails[] private nodeList;
// use a mapping of enodeid to array index to track node
mapping (bytes32 => uint) private nodeIdToIndex;
// keep track of node number
uint private numberOfNodes;
enum AccountAccess { ReadOnly, Transact, ContractDeploy, FullAccess}
struct AccountAccessDetails {
address acctId;
AccountAccess acctAccess;
}
AccountAccessDetails[] private acctAccessList;
mapping (address => uint) private acctToIndex;
uint private numberOfAccts;
uint private numFullAccessAccts;
// use an array to store account details
enum VoterStatus { Active, Inactive }
struct VoterAcctDetails {
address voterAcct;
VoterStatus voterStatus;
}
VoterAcctDetails[] private voterAcctList;
mapping (address => uint) private voterAcctIndex;
uint private numberOfVoters;
uint private numberOfValidVoters;
// store pre pending status, use for cancelPendingOperation
mapping(uint => NodeStatus) private prependingStatus;
// store node approval, deactivation and blacklisting vote status (prevent double vote)
mapping (uint => mapping (address => bool)) private voteStatus;
// valid vote count
mapping (uint => uint) private voteCount;
// checks if first time network boot up has happened or not
bool private networkBoot = false;
// node permission events for new node propose
event NodeProposed(string _enodeId);
event NodeApproved(string _enodeId, string _ipAddrPort, string _discPort, string _raftPort);
// node permission events for node decativation
event NodePendingDeactivation (string _enodeId);
event NodeDeactivated(string _enodeId, string _ipAddrPort, string _discPort, string _raftPort);
// node permission events for node activation
event NodePendingActivation(string _enodeId);
event NodeActivated(string _enodeId, string _ipAddrPort, string _discPort, string _raftPort);
// node permission events for node blacklist
event NodePendingBlacklist(string _enodeId);
event NodeBlacklisted(string _enodeId, string _ipAddrPort, string _discPort, string _raftPort);
// pending operation cancelled
event PendingOperationCancelled(string _enodeId);
// account permission events
event AccountAccessModified(address _address, AccountAccess _access);
// Checks if the given enode exists
modifier enodeInList(string memory _enodeId)
{
require(nodeIdToIndex[keccak256(abi.encodePacked(_enodeId))] != 0, "Enode is not in the list");
_;
}
// Checks if the given enode does not exists
modifier enodeNotInList(string memory _enodeId)
{
require(nodeIdToIndex[keccak256(abi.encodePacked(_enodeId))] == 0 || getNodeStatus(_enodeId) == NodeStatus.NotInList, "Enode is in the list");
_;
}
// Checks if the account can vote
modifier canVote()
{
bool flag = false;
uint voterIndex = getVoterIndex(msg.sender);
if ((voterAcctIndex[msg.sender] != 0) && (voterAcctList[voterIndex].voterStatus == VoterStatus.Active)) {
flag = true;
}
require(flag, "Account can not vote");
_;
}
/* public and external functions */
// view functions
// get number of accounts in the init list given as per genesis.json
function getInitAccountsCount() external view returns (uint){
return initialAcctList.length;
}
// returns the numbers of accounts which will have full access
function getFullAccessAccountCount() external view returns (uint){
return numFullAccessAccts;
}
// Get number of voters
function getNumberOfVoters() external view returns (uint)
{
return numberOfVoters;
}
// Get number of valid voters
function getNumberOfValidVoters() external view returns (uint)
{
return numberOfValidVoters;
}
// Get voter details given the voter index
function getVoter(uint i) external view returns (address _addr, VoterStatus _voterStatus)
{
return (voterAcctList[i].voterAcct, voterAcctList[i].voterStatus);
}
// Get network boot status
function getNetworkBootStatus() external view returns (bool)
{
return networkBoot;
}
// Get node details given enode Id
function getNodeDetails(string calldata enodeId) external view returns (string memory _enodeId, string memory _ipAddrPort, string memory _discPort, string memory _raftPort, NodeStatus _nodeStatus)
{
uint nodeIndex = getNodeIndex(enodeId);
if (nodeIdToIndex[keccak256(abi.encodePacked(enodeId))] != 0){
return (nodeList[nodeIndex].enodeId, nodeList[nodeIndex].ipAddrPort, nodeList[nodeIndex].discPort, nodeList[nodeIndex].raftPort, nodeList[nodeIndex].status);
}
else {
return (enodeId, "", "", "", NodeStatus.NotInList);
}
}
// Get node details given index
function getNodeDetailsFromIndex(uint nodeIndex) external view returns (string memory _enodeId, string memory _ipAddrPort, string memory _discPort, string memory _raftPort, NodeStatus _nodeStatus)
{
return (nodeList[nodeIndex].enodeId, nodeList[nodeIndex].ipAddrPort, nodeList[nodeIndex].discPort, nodeList[nodeIndex].raftPort, nodeList[nodeIndex].status);
}
// Get number of nodes
function getNumberOfNodes() external view returns (uint)
{
return numberOfNodes;
}
// Get account details given index
function getAccountDetails(uint acctIndex) external view returns (address _acct, AccountAccess _acctAccess)
{
return (acctAccessList[acctIndex].acctId, acctAccessList[acctIndex].acctAccess);
}
// Get number of accounts
function getNumberOfAccounts() external view returns (uint)
{
return acctAccessList.length;
}
// Get node status by enode id
function getNodeStatus(string memory _enodeId) public view enodeInList(_enodeId) returns (NodeStatus)
{
return nodeList[getNodeIndex(_enodeId)].status;
}
// checks if the given account is a voter account
function isVoter(address _acctid) external view returns (bool)
{
return ((voterAcctIndex[_acctid] != 0) &&
(voterAcctList[getVoterIndex(_acctid)].voterStatus == VoterStatus.Active));
}
// update the networ boot status as true
function updateNetworkBootStatus() external returns (bool)
{
require (networkBoot == false, "Invalid call: Network boot up completed");
networkBoot = true;
return networkBoot;
}
// initializes the voting status for each voting account to false
function initNodeVoteStatus(uint nodeIndex) internal {
voteCount[nodeIndex] = 0;
for (uint i = 0; i < voterAcctList.length; i++){
if (voterAcctList[i].voterStatus == VoterStatus.Active){
voteStatus[nodeIndex][voterAcctList[i].voterAcct] = false;
}
}
}
// updates the vote status and increses the vote count
function updateVoteStatus(uint nodeIndex) internal {
voteCount[nodeIndex]++;
voteStatus[nodeIndex][msg.sender] = true;
}
// checks if enough votes are received for the approval
function checkEnoughVotes(uint nodeIndex) internal view returns (bool) {
bool approvalStatus = false;
if (voteCount[nodeIndex] > numberOfValidVoters/2){
approvalStatus = true;
}
return approvalStatus;
}
// propose a new node to the network
function proposeNode(string calldata _enodeId, string calldata _ipAddrPort, string calldata _discPort, string calldata _raftPort) external enodeNotInList(_enodeId)
{
if (!(networkBoot)){
numberOfNodes++;
nodeIdToIndex[keccak256(abi.encodePacked(_enodeId))] = numberOfNodes;
nodeList.push(NodeDetails(_enodeId, _ipAddrPort,_discPort, _raftPort, NodeStatus.Approved));
}
else {
if (checkVotingAccountExist()){
if (nodeIdToIndex[keccak256(abi.encodePacked(_enodeId))] != 0){
nodeList[getNodeIndex(_enodeId)].status = NodeStatus.PendingApproval;
prependingStatus[getNodeIndex(_enodeId)] = NodeStatus.NotInList;
} else {
// increment node number, add node to the list
numberOfNodes++;
nodeIdToIndex[keccak256(abi.encodePacked(_enodeId))] = numberOfNodes;
nodeList.push(NodeDetails(_enodeId, _ipAddrPort,_discPort, _raftPort, NodeStatus.PendingApproval));
prependingStatus[numberOfNodes] = NodeStatus.NotInList;
}
// add voting status, numberOfNodes is the index of current proposed node
initNodeVoteStatus(numberOfNodes);
// emit event
emit NodeProposed(_enodeId);
}
}
}
// Adds a node to the nodeList mapping and emits node approved event if successful
function approveNode(string calldata _enodeId) external canVote
{
require(getNodeStatus(_enodeId) == NodeStatus.PendingApproval, "Node need to be in PendingApproval status");
uint nodeIndex = getNodeIndex(_enodeId);
require(voteStatus[nodeIndex][msg.sender] == false, "Node can not double vote");
// vote node
updateVoteStatus(nodeIndex);
// emit event
// check if node vote reach majority
if (checkEnoughVotes(nodeIndex)) {
nodeList[nodeIndex].status = NodeStatus.Approved;
emit NodeApproved(nodeList[nodeIndex].enodeId, nodeList[nodeIndex].ipAddrPort, nodeList[nodeIndex].discPort, nodeList[nodeIndex].raftPort);
}
}
// Propose a node for deactivation from network
function proposeDeactivation(string calldata _enodeId) external enodeInList(_enodeId)
{
if (checkVotingAccountExist()){
require(getNodeStatus(_enodeId) == NodeStatus.Approved, "Node need to be in Approved status");
uint nodeIndex = getNodeIndex(_enodeId);
prependingStatus[nodeIndex] = NodeStatus.Approved;
nodeList[nodeIndex].status = NodeStatus.PendingDeactivation;
// add voting status, numberOfNodes is the index of current proposed node
initNodeVoteStatus(nodeIndex);
// emit event
emit NodePendingDeactivation(_enodeId);
}
}
//deactivates a given Enode and emits the node decativation event
function deactivateNode(string calldata _enodeId) external canVote
{
require(getNodeStatus(_enodeId) == NodeStatus.PendingDeactivation, "Node need to be in PendingDeactivation status");
uint nodeIndex = getNodeIndex(_enodeId);
require(voteStatus[nodeIndex][msg.sender] == false, "Node can not double vote");
// vote node
updateVoteStatus(nodeIndex);
// check if node vote reachead majority and emit event
if (checkEnoughVotes(nodeIndex)) {
nodeList[nodeIndex].status = NodeStatus.Deactivated;
emit NodeDeactivated(nodeList[nodeIndex].enodeId, nodeList[nodeIndex].ipAddrPort, nodeList[nodeIndex].discPort, nodeList[nodeIndex].raftPort);
}
}
// Propose activation of a deactivated node
function proposeNodeActivation(string calldata _enodeId) external
{
if (checkVotingAccountExist()){
require(getNodeStatus(_enodeId) == NodeStatus.Deactivated, "Node need to be in Deactivated status");
uint nodeIndex = getNodeIndex(_enodeId);
prependingStatus[nodeIndex] = NodeStatus.Deactivated;
nodeList[nodeIndex].status = NodeStatus.PendingActivation;
// add voting status, numberOfNodes is the index of current proposed node
initNodeVoteStatus(nodeIndex);
// emit event
emit NodePendingActivation(_enodeId);
}
}
// Activates a given Enode and emits the node activated event
function activateNode(string calldata _enodeId) external canVote
{
require(getNodeStatus(_enodeId) == NodeStatus.PendingActivation, "Node need to be in PendingActivation status");
uint nodeIndex = getNodeIndex(_enodeId);
require(voteStatus[nodeIndex][msg.sender] == false, "Node can not double vote");
// vote node
updateVoteStatus(nodeIndex);
// check if node vote reachead majority and emit event
if (checkEnoughVotes(nodeIndex)) {
nodeList[nodeIndex].status = NodeStatus.Approved;
emit NodeActivated(nodeList[nodeIndex].enodeId, nodeList[nodeIndex].ipAddrPort, nodeList[nodeIndex].discPort, nodeList[nodeIndex].raftPort);
}
}
// Propose node for blacklisting
function proposeNodeBlacklisting(string calldata _enodeId, string calldata _ipAddrPort, string calldata _discPort, string calldata _raftPort) external
{
if (checkVotingAccountExist()){
uint nodeIndex = getNodeIndex(_enodeId);
// check if node is in the nodeList
if (nodeIdToIndex[keccak256(abi.encodePacked(_enodeId))] != 0){
// no matter what status the node is in, vote will reset and node status change to PendingBlacklisting
if (!(nodeList[nodeIndex].status == NodeStatus.PendingApproval || nodeList[nodeIndex].status == NodeStatus.PendingActivation || nodeList[nodeIndex].status == NodeStatus.PendingDeactivation || nodeList[nodeIndex].status == NodeStatus.PendingBlacklisting)){
prependingStatus[nodeIndex] = nodeList[nodeIndex].status;
}
nodeList[nodeIndex].status = NodeStatus.PendingBlacklisting;
nodeIndex = getNodeIndex(_enodeId);
} else {
// increment node number, add node to the list
numberOfNodes++;
nodeIdToIndex[keccak256(abi.encodePacked(_enodeId))] = numberOfNodes;
nodeList.push(NodeDetails(_enodeId, _ipAddrPort,_discPort, _raftPort, NodeStatus.PendingBlacklisting));
prependingStatus[nodeIndex] = NodeStatus.NotInList;
nodeIndex = numberOfNodes;
}
initNodeVoteStatus(nodeIndex);
// emit event
emit NodePendingBlacklist(_enodeId);
}
}
//Approve node blacklisting
function blacklistNode(string calldata _enodeId) external canVote
{
require(getNodeStatus(_enodeId) == NodeStatus.PendingBlacklisting, "Node need to be in PendingBlacklisting status");
uint nodeIndex = getNodeIndex(_enodeId);
require(voteStatus[nodeIndex][msg.sender] == false, "Node can not double vote");
// vote node
voteStatus[nodeIndex][msg.sender] = true;
voteCount[nodeIndex]++;
// emit event
// check if node vote reach majority
if (checkEnoughVotes(nodeIndex)) {
nodeList[nodeIndex].status = NodeStatus.Blacklisted;
emit NodeBlacklisted(nodeList[nodeIndex].enodeId, nodeList[nodeIndex].ipAddrPort, nodeList[nodeIndex].discPort, nodeList[nodeIndex].raftPort);
}
}
// Cancel current pending node operation
function cancelPendingOperation(string calldata _enodeId) external canVote
{
require(getNodeStatus(_enodeId) == NodeStatus.PendingApproval ||
getNodeStatus(_enodeId) == NodeStatus.PendingActivation ||
getNodeStatus(_enodeId) == NodeStatus.PendingDeactivation ||
getNodeStatus(_enodeId) == NodeStatus.PendingBlacklisting,
"Node status must be in pending");
uint nodeIndex = getNodeIndex(_enodeId);
nodeList[nodeIndex].status = prependingStatus[nodeIndex];
emit PendingOperationCancelled(_enodeId);
}
function addInitAccount(address _addr) external {
require(networkBoot == false, "network accounts already boot up");
initialAcctList.push(_addr);
}
// sets the account access to full access for the initial list of accounts
// given as a part of genesis.json
function initAccounts() external
{
require(networkBoot == false, "network accounts already boot up");
for (uint i=0; i<initialAcctList.length; i++){
if (acctToIndex[initialAcctList[i]] == 0){
numberOfAccts ++;
numFullAccessAccts ++;
acctToIndex[initialAcctList[i]] = numberOfAccts;
acctAccessList.push(AccountAccessDetails(initialAcctList[i], AccountAccess.FullAccess));
emit AccountAccessModified(initialAcctList[i], AccountAccess.FullAccess);
}
}
}
// updates accounts access
function updateAccountAccess(address _address, AccountAccess _accountAccess) external
{
// Check if account already exists
uint acctIndex = getAcctIndex(_address);
if (acctToIndex[_address] != 0){
if (acctAccessList[acctIndex].acctAccess == AccountAccess.FullAccess &&
_accountAccess != AccountAccess.FullAccess &&
numFullAccessAccts > 1){
numFullAccessAccts --;
acctAccessList[acctIndex].acctAccess = _accountAccess;
}
else {
acctAccessList[acctIndex].acctAccess = _accountAccess;
}
}
else{
numberOfAccts ++;
acctToIndex[_address] = numberOfAccts;
if (_accountAccess == AccountAccess.FullAccess) {
numFullAccessAccts ++;
}
acctAccessList.push(AccountAccessDetails(_address, _accountAccess));
}
emit AccountAccessModified(_address, _accountAccess);
}
// Add voting account to the current network
function addVoter(address _address) external
{
uint vId = getVoterIndex(_address);
if (voterAcctIndex[_address] != 0) {
if (voterAcctList[vId].voterStatus == VoterStatus.Inactive){
voterAcctList[vId].voterStatus = VoterStatus.Active;
numberOfValidVoters ++;
}
}
else {
numberOfVoters ++;
voterAcctIndex[_address] = numberOfVoters;
voterAcctList.push(VoterAcctDetails(_address, VoterStatus.Active));
numberOfValidVoters ++;
}
}
// Remove voting account from the network
function removeVoter(address _address) external
{
uint vId = getVoterIndex(_address);
if (voterAcctIndex[_address] != 0) {
voterAcctList[vId].voterStatus = VoterStatus.Inactive;
numberOfValidVoters --;
}
}
// returns total voter count and number of valid voter count
function getVoterCount() public view returns (uint, uint)
{
return (numberOfVoters,numberOfValidVoters);
}
/* private functions */
// Returns the node index based on enode id
function getNodeIndex(string memory _enodeId) internal view returns (uint)
{
return nodeIdToIndex[keccak256(abi.encodePacked(_enodeId))] - 1;
}
// Returns the account index based on account id
function getAcctIndex(address _acct) internal view returns (uint)
{
return acctToIndex[_acct] - 1;
}
// Returns the voter index based on account id
function getVoterIndex(address _acct) internal view returns (uint)
{
return voterAcctIndex[_acct] - 1;
}
// checks if voting account exists
function checkVotingAccountExist() internal view returns (bool)
{
return (!(numberOfValidVoters == 0));
}
}

View File

@ -15,8 +15,6 @@ contract PermissionsImplementation {
OrgManager private org;
PermissionsUpgradable private permUpgradable;
event Dummy(string _msg);
string private adminOrg;
string private adminRole;
string private orgAdminRole;
@ -31,7 +29,7 @@ contract PermissionsImplementation {
require(msg.sender == permUpgradable.getPermInterface(), "can be called by proxy only");
_;
}
// Modifiers
// Checks if the given network boot up is pending exists
modifier networkBootStatus(bool _status)
{
@ -68,6 +66,8 @@ contract PermissionsImplementation {
permUpgradable = PermissionsUpgradable(_permUpgradable);
}
// initial set up related functions
// set policy related attributes
function setPolicy(string calldata _nwAdminOrg, string calldata _nwAdminRole, string calldata _oAdminRole) external
onlyProxy
networkBootStatus(false)
@ -119,22 +119,17 @@ contract PermissionsImplementation {
return networkBoot;
}
// Get network boot status
function getNetworkBootStatus() external view
returns (bool)
{
return networkBoot;
}
// function for adding a new master org
function addOrg(string calldata _orgId, string calldata _enodeId, address _caller) external
function addOrg(string calldata _orgId, string calldata _enodeId, address _account, address _caller) external
onlyProxy
networkBootStatus(true)
networkAdmin(_caller)
{
voter.addVotingItem(adminOrg, _orgId, _enodeId, address(0), 1);
voter.addVotingItem(adminOrg, _orgId, _enodeId, _account, 1);
org.addOrg(_orgId);
nodes.addNode(_enodeId, _orgId);
require(validateAccount(_account, _orgId) == true, "Operation cannot be performed");
accounts.assignAccountRole(_account, _orgId, orgAdminRole);
}
// function for adding a new master org
@ -150,6 +145,20 @@ contract PermissionsImplementation {
nodes.addNode(_enodeId, pid);
}
function approveOrg(string calldata _orgId, string calldata _enodeId, address _account, address _caller) external
// function for adding a new master org
function addSubOrg(string calldata _pOrg, string calldata _orgId, string calldata _enodeId, address _caller) external
onlyProxy
networkBootStatus(true)
orgExists(_pOrg)
networkAdmin(_caller)
{
string memory pid = string(abi.encodePacked(_pOrg, ".", _orgId));
voter.addVotingItem(adminOrg, pid, _enodeId, address(0), 1);
org.addSubOrg(_pOrg, _orgId);
nodes.addNode(_enodeId, pid);
}
function approveOrgImpl(string memory _orgId, string memory _enodeId, address _caller) internal
onlyProxy
networkAdmin(_caller)
@ -159,6 +168,7 @@ contract PermissionsImplementation {
org.approveOrg(_orgId);
roles.addRole(orgAdminRole, _orgId, fullAccess, true);
nodes.approveNode(_enodeId, _orgId);
accounts.approveOrgAdminAccount(_account);
}
}
@ -174,7 +184,6 @@ contract PermissionsImplementation {
function updateOrgStatus(string calldata _orgId, uint _status, address _caller) external
onlyProxy
orgExists(_orgId)
networkAdmin(_caller)
{
uint pendingOp;
@ -184,7 +193,6 @@ contract PermissionsImplementation {
function approveOrgStatus(string calldata _orgId, uint _status, address _caller) external
onlyProxy
orgExists(_orgId)
networkAdmin(_caller)
{
require((_status == 3 || _status == 5), "Operation not allowed");
@ -196,17 +204,10 @@ contract PermissionsImplementation {
pendingOp = 3;
}
require(checkOrgStatus(_orgId, _status) == true, "Operation not allowed");
if ((processVote(adminOrg, msg.sender, pendingOp))) {
if ((processVote(adminOrg, _caller, pendingOp))) {
org.approveOrgStatusUpdate(_orgId, _status);
}
}
// returns org and master org details based on org index
/* function getOrgInfo(uint _orgIndex) external view
returns (string memory, uint, uint, string memory, uint)
{
return org.getOrgInfo(_orgIndex);
}*/
// Role related functions
function addNewRole(string calldata _roleId, string calldata _orgId, uint _access, bool _voter, address _caller) external
@ -223,46 +224,18 @@ contract PermissionsImplementation {
orgApproved(_orgId)
orgAdmin(_caller, _orgId)
{
require(((keccak256(abi.encodePacked(_roleId)) != keccak256(abi.encodePacked(adminRole))) &&
(keccak256(abi.encodePacked(_roleId)) != keccak256(abi.encodePacked(orgAdminRole)))), "Admin roles cannot be removed");
roles.removeRole(_roleId, _orgId);
}
/*function getRoleDetails(string calldata _roleId, string calldata _orgId) external view
returns (string memory, string memory, uint, bool, bool)
{
return roles.getRoleDetails(_roleId, _orgId);
}*/
// Org voter related functions
/*function getNumberOfVoters(string calldata _orgId) external view
returns (uint){
return voter.getNumberOfValidVoters(_orgId);
}*/
/*function checkIfVoterExists(string calldata _orgId, address _acct) external view
returns (bool)
{
return voter.checkIfVoterExists(_orgId, _acct);
}*/
/*function getVoteCount(string calldata _orgId) external view returns (uint, uint)
{
return voter.getVoteCount(_orgId);
}*/
/*function getPendingOp(string calldata _orgId) external view
returns (string memory, string memory, address, uint)
{
return voter.getPendingOpDetails(_orgId);
}*/
// Account related functions
function assignOrgAdminAccount(string calldata _orgId, address _account, address _caller) external
onlyProxy
orgExists(_orgId)
networkAdmin(_caller)
{
require(validateAccount(_account, _orgId) == true, "Operation cannot be performed");
// check if orgAdmin already exists if yes then op cannot be performed
require(checkOrgAdminExists(_orgId) != true, "org admin exists");
// assign the account org admin role and propose voting
@ -281,15 +254,12 @@ contract PermissionsImplementation {
}
}
function assignAccountRole(address _acct, string memory _orgId, string memory _roleId, address _caller) public
onlyProxy
orgAdmin(_caller, _orgId)
orgApproved(_orgId)
{
// // check if the account is part of another org. If yes then op cannot be done
require(validateAccount(_acct, _orgId) == true, "Operation cannot be performed");
// // check if role is existing for the org. if yes the op can be done
require(roleExists(_roleId, _orgId) == true, "role does not exists");
bool newRoleVoter = isVoterRole(_roleId, _orgId);
// // check the role of the account. if the current role is voter and new role is also voter
@ -318,24 +288,56 @@ contract PermissionsImplementation {
accounts.assignAccountRole(_acct, _orgId, _roleId);
}
// Node related functions
function addNode(string calldata _orgId, string calldata _enodeId, address _caller) external
onlyProxy
orgApproved(_orgId)
orgAdmin(_caller, _orgId)
{
// check that the node is not part of another org
require(nodes.getNodeStatus(_enodeId) == 0, "Node present already");
nodes.addOrgNode(_enodeId, _orgId);
}
/* function getNodeStatus(string memory _enodeId) public view
returns (uint)
function updateNodeStatus(string calldata _orgId, string calldata _enodeId, uint _status, address _caller) external
onlyProxy
orgExists(_orgId)
orgAdmin(_caller, _orgId)
{
return (nodes.getNodeStatus(_enodeId));
}*/
nodes.updateNodeStatus(_enodeId, _orgId, _status);
}
// Get network boot status
function getNetworkBootStatus() external view
returns (bool)
{
return networkBoot;
}
// Voter related functions
function updateVoterList(string memory _orgId, address _account, bool _add) internal
{
if (_add) {
voter.addVoter(_orgId, _account);
}
else {
voter.deleteVoter(_orgId, _account);
}
}
function processVote(string memory _orgId, address _caller, uint _pendingOp) internal
returns (bool)
{
return voter.processVote(_orgId, _caller, _pendingOp);
}
function getPendingOp(string calldata _orgId) external view
returns (string memory, string memory, address, uint)
{
return voter.getPendingOpDetails(_orgId);
}
// helper functions
function isNetworkAdmin(address _account) public view
returns (bool)
{
@ -391,34 +393,4 @@ contract PermissionsImplementation {
return roles.isVoterRole(_roleId, _orgId);
}
function processVote(string memory _orgId, address _caller, uint _pendingOp) internal
returns (bool)
{
return voter.processVote(_orgId, _caller, _pendingOp);
}
function updateVoterList(string memory _orgId, address _account, bool _add) internal
{
if (_add) {
voter.addVoter(_orgId, _account);
}
else {
voter.deleteVoter(_orgId, _account);
}
}
/* function getAccountDetails(address _acct) external view
returns (address, string memory, string memory, uint, bool)
{
return accounts.getAccountDetails(_acct);
}*/
function updateNodeStatus(string calldata _orgId, string calldata _enodeId, uint _status, address _caller) external
onlyProxy
orgExists(_orgId)
orgAdmin(_caller, _orgId)
{
nodes.updateNodeStatus(_enodeId, _orgId, _status);
}
}

View File

@ -9,8 +9,6 @@ contract PermissionsInterface {
PermissionsUpgradable private permUpgradable;
address private permImplUpgradeable;
event Dummy(string _msg);
constructor(address _permImplUpgradeable) public {
permImplUpgradeable = _permImplUpgradeable;
}
@ -65,22 +63,18 @@ contract PermissionsInterface {
}
// function for adding a new master org
function addOrg(string calldata _orgId, string calldata _enodeId) external
function addOrg(string calldata _orgId, string calldata _enodeId, address _account) external
{
permImplementation.addOrg(_orgId, _enodeId, msg.sender);
permImplementation.addOrg(_orgId, _enodeId, _account, msg.sender);
}
function approveOrg(string calldata _orgId, string calldata _enodeId, address _account) external
// function for adding a new master org
function addSubOrg(string calldata _pOrg, string calldata _orgId, string calldata _enodeId) external
{
permImplementation.addSubOrg(_pOrg, _orgId, _enodeId, msg.sender);
}
function approveOrg(string calldata _orgId, string calldata _enodeId) external
{
permImplementation.approveOrg(_orgId, _enodeId, msg.sender);
}
function approveSubOrg(string calldata _pOrg, string calldata _orgId, string calldata _enodeId) external
{
permImplementation.approveSubOrg(_pOrg, _orgId, _enodeId, msg.sender);
@ -95,11 +89,6 @@ contract PermissionsInterface {
{
permImplementation.approveOrgStatus(_orgId, _status, msg.sender);
}
// returns org and master org details based on org index
/* function getOrgInfo(uint _orgIndex) external view returns (string memory, uint, uint, string memory, uint)
{
return permImplementation.getOrgInfo(_orgIndex);
}*/
// Role related functions
function addNewRole(string calldata _roleId, string calldata _orgId, uint _access, bool _voter) external
@ -112,36 +101,6 @@ contract PermissionsInterface {
permImplementation.removeRole(_roleId, _orgId, msg.sender);
}
/* function getRoleDetails(string calldata _roleId, string calldata _orgId) external view returns (string memory, string memory, uint, bool, bool)
{
return permImplementation.getRoleDetails(_roleId, _orgId);
}*/
// Org voter related functions
/*
function getNumberOfVoters(string calldata _orgId) external view returns (uint)
{
return permImplementation.getNumberOfVoters(_orgId);
}
*/
/* function checkIfVoterExists(string calldata _orgId, address _acct) external view returns (bool)
{
return permImplementation.checkIfVoterExists(_orgId, _acct);
}*/
/* function getVoteCount(string calldata _orgId) external view returns (uint, uint)
{
return permImplementation.getVoteCount(_orgId);
}*/
/* function getPendingOp(string calldata _orgId) external view returns (string memory, string memory, address, uint)
{
return permImplementation.getPendingOp(_orgId);
}*/
function assignOrgAdminAccount(string calldata _orgId, address _account) external
{
permImplementation.assignOrgAdminAccount(_orgId, _account, msg.sender);
@ -170,12 +129,7 @@ contract PermissionsInterface {
permImplementation.updateNodeStatus(_orgId, _enodeId, _status, msg.sender);
}
/* function getNodeStatus(string memory _enodeId) public view returns (uint)
{
return permImplementation.getNodeStatus(_enodeId);
}*/
/*function isNetworkAdmin(address _account) public view returns (bool)
function isNetworkAdmin(address _account) public view returns (bool)
{
return permImplementation.isNetworkAdmin(_account);
}
@ -190,9 +144,4 @@ contract PermissionsInterface {
return permImplementation.validateAccount(_account, _orgId);
}
function getAccountDetails(address _acct) external view returns (address, string memory, string memory, uint, bool)
{
return permImplementation.getAccountDetails(_acct);
}
*/
}

View File

@ -39,8 +39,6 @@ contract VoterManager {
event VotingItemAdded(string _orgId);
event VoteProcessed(string _orgId);
event Dummy(string _msg);
modifier onlyImpl
{
require(msg.sender == permUpgradable.getPermImpl());
@ -157,7 +155,6 @@ contract VoterManager {
orgVoterList[id].pendingOp.enodeId = _enodeId;
orgVoterList[id].pendingOp.account = _account;
orgVoterList[id].pendingOp.opType = _pendingOp;
emit Dummy("at 1");
// init vote status
for (uint i = 0; i < orgVoterList[id].voterList.length; i++) {
if (orgVoterList[id].voterList[i].active) {

View File

@ -1 +1 @@
[{"constant":true,"inputs":[{"name":"_acct","type":"address"},{"name":"_orgId","type":"string"}],"name":"checkOrgAdmin","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_acct","type":"address"}],"name":"getAccountDetails","outputs":[{"name":"","type":"address"},{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"uint256"},{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"},{"name":"_orgId","type":"string"},{"name":"_roleId","type":"string"}],"name":"assignAccountRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getNumberOfAccounts","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_acct","type":"address"},{"name":"_orgId","type":"string"}],"name":"valAcctAccessChange","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_acct","type":"address"}],"name":"getAccountRole","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"orgAdminExists","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"},{"name":"_orgId","type":"string"}],"name":"addNWAdminAccount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_nwAdminRole","type":"string"},{"name":"_oAdminRole","type":"string"}],"name":"setDefaults","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"}],"name":"approveOrgAdminAccount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"}],"name":"revokeAccountRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_permUpgradable","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_address","type":"address"},{"indexed":false,"name":"_roleId","type":"string"}],"name":"AccountAccessModified","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_address","type":"address"},{"indexed":false,"name":"_roleId","type":"string"}],"name":"AccountAccessRevoked","type":"event"}]
[{"constant":true,"inputs":[{"name":"_acct","type":"address"},{"name":"_orgId","type":"string"}],"name":"checkOrgAdmin","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_acct","type":"address"}],"name":"getAccountDetails","outputs":[{"name":"","type":"address"},{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"uint256"},{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"},{"name":"_orgId","type":"string"},{"name":"_roleId","type":"string"}],"name":"assignAccountRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getNumberOfAccounts","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_acct","type":"address"},{"name":"_orgId","type":"string"}],"name":"valAcctAccessChange","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_acct","type":"address"}],"name":"getAccountRole","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"orgAdminExists","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"aIndex","type":"uint256"}],"name":"getAccountDetailsFromIndex","outputs":[{"name":"","type":"address"},{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"uint256"},{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"},{"name":"_orgId","type":"string"}],"name":"addNWAdminAccount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_nwAdminRole","type":"string"},{"name":"_oAdminRole","type":"string"}],"name":"setDefaults","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"}],"name":"approveOrgAdminAccount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"}],"name":"revokeAccountRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_permUpgradable","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_address","type":"address"},{"indexed":false,"name":"_orgId","type":"string"},{"indexed":false,"name":"_roleId","type":"string"},{"indexed":false,"name":"_orgAdmin","type":"bool"},{"indexed":false,"name":"_status","type":"uint256"}],"name":"AccountAccessModified","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_address","type":"address"},{"indexed":false,"name":"_orgId","type":"string"},{"indexed":false,"name":"_roleId","type":"string"},{"indexed":false,"name":"_orgAdmin","type":"bool"}],"name":"AccountAccessRevoked","type":"event"}]

View File

@ -1 +1 @@
[{"constant":false,"inputs":[{"name":"_enodeId","type":"string"}],"name":"approveNode","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_enodeId","type":"string"}],"name":"getNodeStatus","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"enodeId","type":"string"}],"name":"getNodeDetails","outputs":[{"name":"_enodeId","type":"string"},{"name":"_nodeStatus","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_enodeId","type":"string"},{"name":"_orgId","type":"string"}],"name":"addOrgNode","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"nodeIndex","type":"uint256"}],"name":"getNodeDetailsFromIndex","outputs":[{"name":"_enodeId","type":"string"},{"name":"_nodeStatus","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_enodeId","type":"string"},{"name":"_orgId","type":"string"}],"name":"addNode","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getNumberOfNodes","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_permUpgradable","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_enodeId","type":"string"}],"name":"NodeProposed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_enodeId","type":"string"}],"name":"NodeApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_enodeId","type":"string"}],"name":"NodePendingDeactivation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_enodeId","type":"string"}],"name":"NodeDeactivated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_enodeId","type":"string"}],"name":"NodePendingActivation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_enodeId","type":"string"}],"name":"NodeActivated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_enodeId","type":"string"}],"name":"NodePendingBlacklist","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"","type":"string"}],"name":"NodeBlacklisted","type":"event"}]
[{"constant":false,"inputs":[{"name":"_enodeId","type":"string"},{"name":"_orgId","type":"string"},{"name":"_status","type":"uint256"}],"name":"updateNodeStatus","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_enodeId","type":"string"}],"name":"getNodeStatus","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"enodeId","type":"string"}],"name":"getNodeDetails","outputs":[{"name":"_orgId","type":"string"},{"name":"_enodeId","type":"string"},{"name":"_nodeStatus","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_enodeId","type":"string"},{"name":"_orgId","type":"string"}],"name":"addOrgNode","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_enodeId","type":"string"},{"name":"_orgId","type":"string"}],"name":"approveNode","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"nodeIndex","type":"uint256"}],"name":"getNodeDetailsFromIndex","outputs":[{"name":"_orgId","type":"string"},{"name":"_enodeId","type":"string"},{"name":"_nodeStatus","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_enodeId","type":"string"},{"name":"_orgId","type":"string"}],"name":"addNode","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getNumberOfNodes","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_enodeId","type":"string"},{"name":"_orgId","type":"string"}],"name":"addAdminNode","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_permUpgradable","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_enodeId","type":"string"},{"indexed":false,"name":"_orgId","type":"string"}],"name":"NodeProposed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_enodeId","type":"string"},{"indexed":false,"name":"_orgId","type":"string"}],"name":"NodeApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_enodeId","type":"string"},{"indexed":false,"name":"_orgId","type":"string"}],"name":"NodeDeactivated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_enodeId","type":"string"},{"indexed":false,"name":"_orgId","type":"string"}],"name":"NodeActivated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_enodeId","type":"string"},{"indexed":false,"name":"_orgId","type":"string"}],"name":"NodeBlacklisted","type":"event"}]

View File

@ -1 +1 @@
[{"constant":false,"inputs":[{"name":"_orgId","type":"string"},{"name":"_status","type":"uint256"}],"name":"updateOrg","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"getOrgIndex","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_orgId","type":"string"},{"name":"_status","type":"uint256"}],"name":"approveOrgStatusUpdate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_orgId","type":"string"}],"name":"addAdminOrg","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_orgIndex","type":"uint256"}],"name":"getOrgInfo","outputs":[{"name":"","type":"string"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"},{"name":"_orgStatus","type":"uint256"}],"name":"checkOrgStatus","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getImpl","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_orgId","type":"string"}],"name":"approveOrg","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_orgId","type":"string"}],"name":"addOrg","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"getOrgStatus","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"checkOrgExists","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_permUpgradable","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_orgId","type":"string"}],"name":"OrgApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_orgId","type":"string"},{"indexed":false,"name":"_type","type":"uint256"}],"name":"OrgPendingApproval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_orgId","type":"string"}],"name":"OrgSuspended","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_orgId","type":"string"}],"name":"OrgSuspensionRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_msg","type":"string"}],"name":"Dummy","type":"event"}]
[{"constant":false,"inputs":[{"name":"_orgId","type":"string"},{"name":"_status","type":"uint256"}],"name":"updateOrg","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"getOrgIndex","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_orgId","type":"string"},{"name":"_status","type":"uint256"}],"name":"approveOrgStatusUpdate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_orgId","type":"string"}],"name":"addAdminOrg","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_orgIndex","type":"uint256"}],"name":"getOrgInfo","outputs":[{"name":"","type":"string"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getNumberOfOrgs","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"},{"name":"_orgStatus","type":"uint256"}],"name":"checkOrgStatus","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getImpl","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_orgId","type":"string"}],"name":"approveOrg","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_orgId","type":"string"}],"name":"addOrg","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"getOrgStatus","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"checkOrgExists","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_permUpgradable","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_orgId","type":"string"}],"name":"OrgApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_orgId","type":"string"},{"indexed":false,"name":"_type","type":"uint256"}],"name":"OrgPendingApproval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_orgId","type":"string"}],"name":"OrgSuspended","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_orgId","type":"string"}],"name":"OrgSuspensionRevoked","type":"event"}]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
[{"constant":true,"inputs":[{"name":"_roleId","type":"string"},{"name":"_orgId","type":"string"}],"name":"getRoleDetails","outputs":[{"name":"roleId","type":"string"},{"name":"orgId","type":"string"},{"name":"accessType","type":"uint256"},{"name":"voter","type":"bool"},{"name":"active","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_roleId","type":"string"},{"name":"_orgId","type":"string"}],"name":"isVoterRole","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_roleId","type":"string"},{"name":"_orgId","type":"string"}],"name":"isFullAccessRole","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_roleId","type":"string"},{"name":"_orgId","type":"string"},{"name":"_baseAccess","type":"uint256"},{"name":"_voter","type":"bool"}],"name":"addRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_roleId","type":"string"},{"name":"_orgId","type":"string"}],"name":"roleExists","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getNumberOfRoles","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_roleId","type":"string"},{"name":"_orgId","type":"string"}],"name":"removeRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_permUpgradable","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_roleId","type":"string"},{"indexed":false,"name":"_orgId","type":"string"}],"name":"RoleCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_roleId","type":"string"},{"indexed":false,"name":"_orgId","type":"string"}],"name":"RoleRevoked","type":"event"}]
[{"constant":true,"inputs":[{"name":"_roleId","type":"string"},{"name":"_orgId","type":"string"}],"name":"getRoleDetails","outputs":[{"name":"roleId","type":"string"},{"name":"orgId","type":"string"},{"name":"accessType","type":"uint256"},{"name":"voter","type":"bool"},{"name":"active","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_roleId","type":"string"},{"name":"_orgId","type":"string"}],"name":"isVoterRole","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_roleId","type":"string"},{"name":"_orgId","type":"string"}],"name":"isFullAccessRole","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_roleId","type":"string"},{"name":"_orgId","type":"string"},{"name":"_baseAccess","type":"uint256"},{"name":"_voter","type":"bool"}],"name":"addRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_roleId","type":"string"},{"name":"_orgId","type":"string"}],"name":"roleExists","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getNumberOfRoles","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"rIndex","type":"uint256"}],"name":"getRoleDetailsFromIndex","outputs":[{"name":"roleId","type":"string"},{"name":"orgId","type":"string"},{"name":"accessType","type":"uint256"},{"name":"voter","type":"bool"},{"name":"active","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_roleId","type":"string"},{"name":"_orgId","type":"string"}],"name":"removeRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_permUpgradable","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_roleId","type":"string"},{"indexed":false,"name":"_orgId","type":"string"},{"indexed":false,"name":"_baseAccess","type":"uint256"},{"indexed":false,"name":"_isVoter","type":"bool"}],"name":"RoleCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_roleId","type":"string"},{"indexed":false,"name":"_orgId","type":"string"}],"name":"RoleRevoked","type":"event"}]

View File

@ -1 +1 @@
[{"constant":true,"inputs":[{"name":"_orgId","type":"string"},{"name":"_address","type":"address"}],"name":"checkIfVoterExists","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"getPendingOpDetails","outputs":[{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"address"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"getVoteCount","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_orgId","type":"string"},{"name":"_address","type":"address"}],"name":"addVoter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_orgId","type":"string"},{"name":"_address","type":"address"}],"name":"deleteVoter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"getNumberOfValidVoters","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"getNumberOfVoters","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_authOrg","type":"string"},{"name":"_vAccount","type":"address"},{"name":"_pendingOp","type":"uint256"}],"name":"processVote","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"checkVotingAccountExists","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_authOrg","type":"string"},{"name":"_orgId","type":"string"},{"name":"_enodeId","type":"string"},{"name":"_account","type":"address"},{"name":"_pendingOp","type":"uint256"}],"name":"addVotingItem","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_permUpgradable","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_orgId","type":"string"},{"indexed":false,"name":"_address","type":"address"}],"name":"VoterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_orgId","type":"string"},{"indexed":false,"name":"_address","type":"address"}],"name":"VoterDeleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_orgId","type":"string"}],"name":"VotingItemAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_orgId","type":"string"}],"name":"VoteProcessed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_msg","type":"string"}],"name":"Dummy","type":"event"}]
[{"constant":true,"inputs":[{"name":"_orgId","type":"string"},{"name":"_address","type":"address"}],"name":"checkIfVoterExists","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"getPendingOpDetails","outputs":[{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"address"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"getVoteCount","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_orgId","type":"string"},{"name":"_address","type":"address"}],"name":"addVoter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_orgId","type":"string"},{"name":"_address","type":"address"}],"name":"deleteVoter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"getNumberOfValidVoters","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"getNumberOfVoters","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_authOrg","type":"string"},{"name":"_vAccount","type":"address"},{"name":"_pendingOp","type":"uint256"}],"name":"processVote","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_orgId","type":"string"}],"name":"checkVotingAccountExists","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_authOrg","type":"string"},{"name":"_orgId","type":"string"},{"name":"_enodeId","type":"string"},{"name":"_account","type":"address"},{"name":"_pendingOp","type":"uint256"}],"name":"addVotingItem","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_permUpgradable","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_orgId","type":"string"},{"indexed":false,"name":"_address","type":"address"}],"name":"VoterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_orgId","type":"string"},{"indexed":false,"name":"_address","type":"address"}],"name":"VoterDeleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_orgId","type":"string"}],"name":"VotingItemAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_orgId","type":"string"}],"name":"VoteProcessed","type":"event"}]

View File

@ -84,7 +84,7 @@ func populateConfig(config PermissionLocalConfig) types.PermissionConfig {
permConfig.VoterAddress = common.HexToAddress(config.VoterAddress)
permConfig.NwAdminOrg = config.NwAdminOrg
permConfig.NwAdminRole = config.NwAdminOrg
permConfig.NwAdminRole = config.NwAdminRole
permConfig.OrgAdminRole = config.OrgAdminRole
// populate the account list as passed in config
@ -190,13 +190,13 @@ func (p *PermissionCtrl) Start() error {
go p.manageOrgPermissions()
// monitor org level node management events
p.manageNodePermissions()
go p.manageNodePermissions()
// monitor org level role management events
p.manageRolePermissions()
go p.manageRolePermissions()
// monitor org level account management events
p.manageAccountPermissions()
go p.manageAccountPermissions()
return nil
}
@ -249,176 +249,82 @@ func (p *PermissionCtrl) manageOrgPermissions() {
}
for {
log.Info("AJ-new org pending approval waiting for events...")
select {
case evtPendingApproval = <-chPendingApproval:
log.Info("AJ-newOrgPendingApproval", "node", evtPendingApproval.OrgId)
types.OrgInfoMap.UpsertOrg(evtPendingApproval.OrgId, types.OrgStatus(evtPendingApproval.Type.Uint64()))
log.Info("AJ-newOrgPendingApproval cached updated for ", "orgid", evtPendingApproval.OrgId)
case evtOrgApproved = <-chOrgApproved:
log.Info("AJ-newOrgPendingApproval", "node", evtOrgApproved.OrgId)
types.OrgInfoMap.UpsertOrg(evtOrgApproved.OrgId, types.OrgApproved)
log.Info("AJ-newOrgPendingApproval cached updated for ", "orgid", evtOrgApproved.OrgId)
case evtOrgSuspended = <-chOrgSuspended:
log.Info("AJ-newOrgPendingApproval", "node", evtOrgSuspended.OrgId)
types.OrgInfoMap.UpsertOrg(evtOrgSuspended.OrgId, types.OrgSuspended)
log.Info("AJ-newOrgPendingApproval cached updated for ", "orgid", evtOrgSuspended.OrgId)
case evtOrgReactivated = <-chOrgReactivated:
log.Info("AJ-newOrgPendingApproval", "node", evtOrgReactivated.OrgId)
types.OrgInfoMap.UpsertOrg(evtOrgReactivated.OrgId, types.OrgApproved)
log.Info("AJ-newOrgPendingApproval cached updated for ", "orgid", evtOrgReactivated.OrgId)
}
}
}
// Manages node addition, decavtivation and activation from network
// Monitors node management events and updates cache accordingly
func (p *PermissionCtrl) manageNodePermissions() {
chNodeApproved := make(chan *pbind.NodeManagerNodeApproved, 1)
chNodeProposed := make(chan *pbind.NodeManagerNodeProposed, 1)
chNodeDeactivated := make(chan *pbind.NodeManagerNodeDeactivated, 1)
chNodeActivated := make(chan *pbind.NodeManagerNodeActivated, 1)
chNodeBlacklisted := make(chan *pbind.NodeManagerNodeBlacklisted)
if p.permissionedMode {
log.Info("AJ-manage node start")
//monitor for new nodes addition via smart contract
go p.monitorNewNodeAdd()
go p.monitorNewNodePendingApproval()
//monitor for nodes deletion via smart contract
go p.monitorNodeDeactivation()
//monitor for nodes activation from deactivation status
go p.monitorNodeActivation()
//monitor for nodes blacklisting via smart contract
go p.monitorNodeBlacklisting()
}
}
// Listens on the channel for new node approval via smart contract and
// adds the same into permissioned-nodes.json
func (p *PermissionCtrl) monitorNewNodeAdd() {
log.Info("AJ-new node approved event monitor started...")
ch := make(chan *pbind.NodeManagerNodeApproved, 1)
var evtNodeApproved *pbind.NodeManagerNodeApproved
var evtNodeProposed *pbind.NodeManagerNodeProposed
var evtNodeDeactivated *pbind.NodeManagerNodeDeactivated
var evtNodeActivated *pbind.NodeManagerNodeActivated
var evtNodeBlacklisted *pbind.NodeManagerNodeBlacklisted
opts := &bind.WatchOpts{}
var blockNumber uint64 = 1
opts.Start = &blockNumber
var evt *pbind.NodeManagerNodeApproved
_, err := p.permNode.NodeManagerFilterer.WatchNodeApproved(opts, ch)
if err != nil {
log.Info("Failed WatchNodeApproved: %v", err)
}
for {
log.Info("AJ-new node approved waiting for events...")
select {
case evt = <-ch:
log.Info("AJ-newNodeApproved", "node", evt.EnodeId)
p.updatePermissionedNodes(evt.EnodeId, NodeAdd)
types.NodeInfoMap.UpsertNode(evt.OrgId, evt.EnodeId, types.NodeApproved)
log.Info("AJ-newNodeApproved cached updated for ", "enode", evt.EnodeId)
}
}
if _, err := p.permNode.NodeManagerFilterer.WatchNodeApproved(opts, chNodeApproved); err != nil {
log.Info("Failed WatchNodeApproved", "error", err)
}
func (p *PermissionCtrl) monitorNewNodePendingApproval() {
log.Info("AJ-new node proposed event monitor started...")
ch := make(chan *pbind.NodeManagerNodeProposed, 1)
opts := &bind.WatchOpts{}
var blockNumber uint64 = 1
opts.Start = &blockNumber
var evt *pbind.NodeManagerNodeProposed
_, err := p.permNode.NodeManagerFilterer.WatchNodeProposed(opts, ch)
if err != nil {
log.Info("Failed WatchNodeProposed: %v", err)
}
for {
log.Info("AJ-new node proposed waiting for events...")
select {
case evt = <-ch:
log.Info("AJ-newNodeProposed", "node", evt.EnodeId)
p.updatePermissionedNodes(evt.EnodeId, NodeAdd)
types.NodeInfoMap.UpsertNode(evt.OrgId, evt.EnodeId, types.NodePendingApproval)
log.Info("AJ-newNodeProposed cached updated for ", "enode", evt.EnodeId)
}
}
if _, err := p.permNode.NodeManagerFilterer.WatchNodeProposed(opts, chNodeProposed); err != nil {
log.Info("Failed WatchNodeProposed", "error", err)
}
// Listens on the channel for new node deactivation via smart contract
// and removes the same from permissioned-nodes.json
func (p *PermissionCtrl) monitorNodeDeactivation() {
ch := make(chan *pbind.NodeManagerNodeDeactivated)
opts := &bind.WatchOpts{}
var blockNumber uint64 = 1
opts.Start = &blockNumber
var evt *pbind.NodeManagerNodeDeactivated
_, err := p.permNode.NodeManagerFilterer.WatchNodeDeactivated(opts, ch)
if err != nil {
log.Info("Failed NodeDeactivated: %v", err)
if _, err := p.permNode.NodeManagerFilterer.WatchNodeDeactivated(opts, chNodeDeactivated); err != nil {
log.Info("Failed NodeDeactivated", "error", err)
}
if _, err := p.permNode.NodeManagerFilterer.WatchNodeActivated(opts, chNodeActivated); err != nil {
log.Info("Failed WatchNodeActivated", "error", err)
}
if _, err := p.permNode.NodeManagerFilterer.WatchNodeBlacklisted(opts, chNodeBlacklisted); err != nil {
log.Info("Failed NodeBlacklisting", "error", err)
}
for {
select {
case evt = <-ch:
p.updatePermissionedNodes(evt.EnodeId, NodeDelete)
types.NodeInfoMap.UpsertNode(evt.OrgId, evt.EnodeId, types.NodeDeactivated)
log.Info("AJ-NodeDeactivated cached updated for ", "enode", evt.EnodeId)
}
case evtNodeApproved = <-chNodeApproved:
p.updatePermissionedNodes(evtNodeApproved.EnodeId, NodeAdd)
types.NodeInfoMap.UpsertNode(evtNodeApproved.OrgId, evtNodeApproved.EnodeId, types.NodeApproved)
}
}
case evtNodeProposed = <-chNodeProposed:
p.updatePermissionedNodes(evtNodeProposed.EnodeId, NodeAdd)
types.NodeInfoMap.UpsertNode(evtNodeProposed.OrgId, evtNodeProposed.EnodeId, types.NodePendingApproval)
// Listnes on the channel for any node activation via smart contract
// and adds the same permissioned-nodes.json
func (p *PermissionCtrl) monitorNodeActivation() {
ch := make(chan *pbind.NodeManagerNodeActivated, 1)
case evtNodeDeactivated = <-chNodeDeactivated:
p.updatePermissionedNodes(evtNodeDeactivated.EnodeId, NodeDelete)
types.NodeInfoMap.UpsertNode(evtNodeDeactivated.OrgId, evtNodeDeactivated.EnodeId, types.NodeDeactivated)
opts := &bind.WatchOpts{}
var blockNumber uint64 = 1
opts.Start = &blockNumber
var evt *pbind.NodeManagerNodeActivated
case evtNodeActivated = <-chNodeActivated:
p.updatePermissionedNodes(evtNodeActivated.EnodeId, NodeAdd)
types.NodeInfoMap.UpsertNode(evtNodeActivated.OrgId, evtNodeActivated.EnodeId, types.NodeActivated)
_, err := p.permNode.NodeManagerFilterer.WatchNodeActivated(opts, ch)
if err != nil {
log.Info("Failed WatchNodeActivated: %v", err)
case evtNodeBlacklisted = <-chNodeBlacklisted:
p.updatePermissionedNodes(evtNodeBlacklisted.EnodeId, NodeDelete)
p.updateDisallowedNodes(evtNodeBlacklisted.EnodeId)
types.NodeInfoMap.UpsertNode(evtNodeBlacklisted.OrgId, evtNodeBlacklisted.EnodeId, types.NodeBlackListed)
}
for {
select {
case evt = <-ch:
p.updatePermissionedNodes(evt.EnodeId, NodeAdd)
types.NodeInfoMap.UpsertNode(evt.OrgId, evt.EnodeId, types.NodeActivated)
log.Info("AJ-newNodeActivated cached updated for ", "enode", evt.EnodeId)
}
}
}
// Listens on the channel for node blacklisting via smart contract and
// adds the same into disallowed-nodes.json
func (p *PermissionCtrl) monitorNodeBlacklisting() {
ch := make(chan *pbind.NodeManagerNodeBlacklisted)
opts := &bind.WatchOpts{}
var blockNumber uint64 = 1
opts.Start = &blockNumber
var evt *pbind.NodeManagerNodeBlacklisted
_, err := p.permNode.NodeManagerFilterer.WatchNodeBlacklisted(opts, ch)
if err != nil {
log.Info("Failed NodeBlacklisting: %v", err)
}
for {
select {
case evt = <-ch:
log.Info("AJ-nodeBlackListed", "event", evt)
p.updatePermissionedNodes(evt.EnodeId, NodeDelete)
p.updateDisallowedNodes(evt.EnodeId)
types.NodeInfoMap.UpsertNode(evt.OrgId, evt.EnodeId, types.NodeBlackListed)
log.Info("AJ-newNodeABlacklisted cached updated for ", "enode", evt.EnodeId)
}
}
}
@ -519,14 +425,35 @@ func (p *PermissionCtrl) updateDisallowedNodes(url string) {
p.disconnectNode(url)
}
// Manages account level permissions update
// Monitors account access related events and updates the cache accordingly
func (p *PermissionCtrl) manageAccountPermissions() {
if !p.permissionedMode {
return
chAccessModified := make(chan *pbind.AcctManagerAccountAccessModified)
chAccessRevoked := make(chan *pbind.AcctManagerAccountAccessRevoked)
var evtAccessModified *pbind.AcctManagerAccountAccessModified
var evtAccessRevoked *pbind.AcctManagerAccountAccessRevoked
opts := &bind.WatchOpts{}
var blockNumber uint64 = 1
opts.Start = &blockNumber
if _, err := p.permAcct.AcctManagerFilterer.WatchAccountAccessModified(opts, chAccessModified); err != nil {
log.Info("Failed NewNodeProposed", "error", err)
}
if _, err := p.permAcct.AcctManagerFilterer.WatchAccountAccessRevoked(opts, chAccessRevoked); err != nil {
log.Info("Failed NewNodeProposed", "error", err)
}
for {
select {
case evtAccessModified = <-chAccessModified:
types.AcctInfoMap.UpsertAccount(evtAccessModified.OrgId, evtAccessModified.RoleId, evtAccessModified.Address, evtAccessModified.OrgAdmin, types.AcctStatus(int(evtAccessModified.Status.Uint64())))
case evtAccessRevoked = <-chAccessRevoked:
types.AcctInfoMap.UpsertAccount(evtAccessRevoked.OrgId, evtAccessRevoked.RoleId, evtAccessRevoked.Address, evtAccessRevoked.OrgAdmin, types.AcctActive)
}
}
go p.monitorAccountPermissionsAccessModified()
go p.monitorAccountPermissionsAccessRevoked()
return
}
// populates the nodes list from permissioned-nodes.json into the permissions smart contract
@ -558,55 +485,6 @@ func (p *PermissionCtrl) populatePermissionedNodes() error {
return nil
}
// Monitors permissions changes at acount level and uodate the account permissions cache
func (p *PermissionCtrl) monitorAccountPermissionsAccessModified() {
ch := make(chan *pbind.AcctManagerAccountAccessModified)
opts := &bind.WatchOpts{}
var blockNumber uint64 = 1
opts.Start = &blockNumber
var evt *pbind.AcctManagerAccountAccessModified
_, err := p.permAcct.AcctManagerFilterer.WatchAccountAccessModified(opts, ch)
if err != nil {
log.Info("AJ-Failed NewNodeProposed: %v", err)
}
for {
select {
case evt = <-ch:
log.Info("AJ-AccountAccessModified", "address", evt.Address, "role", evt.RoleId)
types.AcctInfoMap.UpsertAccount(evt.OrgId, evt.RoleId, evt.Address, evt.OrgAdmin, types.AcctStatus(int(evt.Status.Uint64())))
log.Info("AJ-AccountAccessModified cached updated for ", "acct", evt.Address)
}
}
}
func (p *PermissionCtrl) monitorAccountPermissionsAccessRevoked() {
ch := make(chan *pbind.AcctManagerAccountAccessRevoked)
opts := &bind.WatchOpts{}
var blockNumber uint64 = 1
opts.Start = &blockNumber
var evt *pbind.AcctManagerAccountAccessRevoked
_, err := p.permAcct.AcctManagerFilterer.WatchAccountAccessRevoked(opts, ch)
if err != nil {
log.Info("AJ-Failed NewNodeProposed: %v", err)
}
for {
select {
case evt = <-ch:
log.Info("AJ-AccountAccessModified", "address", evt.Address, "role", evt.RoleId)
types.AcctInfoMap.UpsertAccount(evt.OrgId, evt.RoleId, evt.Address, evt.OrgAdmin, types.AcctActive)
log.Info("AJ-AccountAccessModified cached updated for ", "acct", evt.Address)
}
}
}
// Disconnect the node from the network
func (p *PermissionCtrl) disconnectNode(enodeId string) {
if p.isRaft {
@ -632,15 +510,6 @@ func (p *PermissionCtrl) disconnectNode(enodeId string) {
}
}
// helper function to format EnodeId
func (p *PermissionCtrl) formatEnodeId(enodeId, ipAddrPort, discPort, raftPort string) string {
newEnodeId := "enode://" + enodeId + "@" + ipAddrPort + "?discport=" + discPort
if p.isRaft {
newEnodeId += "&raftport=" + raftPort
}
return newEnodeId
}
// Thus function checks if the its the initial network boot up status and if no
// populates permissioning model with details from permission-config.json
func (p *PermissionCtrl) populateInitPermissions() error {
@ -672,11 +541,8 @@ func (p *PermissionCtrl) populateInitPermissions() error {
} else {
//populate orgs, nodes, roles and accounts from contract
p.populateOrgsFromContract(auth)
p.populateNodesFromContract(auth)
p.populateRolesFromContract(auth)
p.populateAccountsFromContract(auth)
}
@ -715,6 +581,7 @@ func (p *PermissionCtrl) bootupNetwork(permInterfSession *pbind.PermInterfaceSes
return nil
}
// populates the account access details from contract into cache
func (p *PermissionCtrl) populateAccountsFromContract(auth *bind.TransactOpts) {
//populate accounts
permAcctSession := &pbind.AcctManagerSession{
@ -734,6 +601,7 @@ func (p *PermissionCtrl) populateAccountsFromContract(auth *bind.TransactOpts) {
}
}
// populates the role details from contract into cache
func (p *PermissionCtrl) populateRolesFromContract(auth *bind.TransactOpts) {
//populate roles
permRoleSession := &pbind.RoleManagerSession{
@ -753,6 +621,7 @@ func (p *PermissionCtrl) populateRolesFromContract(auth *bind.TransactOpts) {
}
}
// populates the node details from contract into cache
func (p *PermissionCtrl) populateNodesFromContract(auth *bind.TransactOpts) {
//populate nodes
permNodeSession := &pbind.NodeManagerSession{
@ -773,6 +642,7 @@ func (p *PermissionCtrl) populateNodesFromContract(auth *bind.TransactOpts) {
}
}
// populates the org details from contract into cache
func (p *PermissionCtrl) populateOrgsFromContract(auth *bind.TransactOpts) {
//populate orgs
permOrgSession := &pbind.OrgManagerSession{
@ -839,64 +709,37 @@ func (p *PermissionCtrl) updateNetworkStatus(permissionsSession *pbind.PermInter
return nil
}
// monitors role management related events and updated cache
func (p *PermissionCtrl) manageRolePermissions() {
if p.permissionedMode {
log.Info("AJ-manage role start")
//monitor for new nodes addition via smart contract
go p.monitorNewRoleAdd()
go p.monitorNewRoleRemove()
}
}
chRoleCreated := make(chan *pbind.RoleManagerRoleCreated, 1)
chRoleRevoked := make(chan *pbind.RoleManagerRoleRevoked, 1)
func (p *PermissionCtrl) monitorNewRoleAdd() {
log.Info("AJ-new role added event monitor started...")
ch := make(chan *pbind.RoleManagerRoleCreated, 1)
var evtRoleCreated *pbind.RoleManagerRoleCreated
var evtRoleRevoked *pbind.RoleManagerRoleRevoked
opts := &bind.WatchOpts{}
var blockNumber uint64 = 1
opts.Start = &blockNumber
var evt *pbind.RoleManagerRoleCreated
_, err := p.permRole.RoleManagerFilterer.WatchRoleCreated(opts, ch)
if err != nil {
if _, err := p.permRole.RoleManagerFilterer.WatchRoleCreated(opts, chRoleCreated); err != nil {
log.Info("Failed WatchRoleCreated: %v", err)
}
for {
log.Info("AJ-new role created waiting for events...")
select {
case evt = <-ch:
log.Info("AJ-newRoleCreated", "org", evt.OrgId, "role", evt.RoleId)
types.RoleInfoMap.UpsertRole(evt.OrgId, evt.RoleId, evt.IsVoter, types.AccessType(int(evt.BaseAccess.Uint64())), true)
log.Info("AJ-newRoleCreated cached updated for ", "orgid", evt.OrgId, "role", evt.RoleId)
}
}
}
func (p *PermissionCtrl) monitorNewRoleRemove() {
log.Info("AJ-new role remove event monitor started...")
ch := make(chan *pbind.RoleManagerRoleRevoked, 1)
opts := &bind.WatchOpts{}
var blockNumber uint64 = 1
opts.Start = &blockNumber
var evt *pbind.RoleManagerRoleRevoked
_, err := p.permRole.RoleManagerFilterer.WatchRoleRevoked(opts, ch)
if err != nil {
if _, err := p.permRole.RoleManagerFilterer.WatchRoleRevoked(opts, chRoleRevoked); err != nil {
log.Info("Failed WatchRoleRemoved: %v", err)
}
for {
log.Info("AJ-new role removed waiting for events...")
select {
case evt = <-ch:
log.Info("AJ-newRoleRemoved", "org", evt.OrgId, "role", evt.RoleId)
if r := types.RoleInfoMap.GetRole(evt.OrgId, evt.RoleId); r != nil {
types.RoleInfoMap.UpsertRole(evt.OrgId, evt.RoleId, r.IsVoter, r.Access, false)
log.Info("AJ-newRoleRemoved cached updated for ", "orgid", evt.OrgId, "role", evt.RoleId)
} else {
log.Error("AJ-revoke role - cache is missing role", "org", evt.OrgId, "role", evt.RoleId)
}
for {
select {
case evtRoleCreated = <-chRoleCreated:
types.RoleInfoMap.UpsertRole(evtRoleCreated.OrgId, evtRoleCreated.RoleId, evtRoleCreated.IsVoter, types.AccessType(int(evtRoleCreated.BaseAccess.Uint64())), true)
case evtRoleRevoked = <-chRoleRevoked:
if r := types.RoleInfoMap.GetRole(evtRoleRevoked.OrgId, evtRoleRevoked.RoleId); r != nil {
types.RoleInfoMap.UpsertRole(evtRoleRevoked.OrgId, evtRoleRevoked.RoleId, r.IsVoter, r.Access, false)
} else {
log.Error("Revoke role - cache is missing role", "org", evtRoleRevoked.OrgId, "role", evtRoleRevoked.RoleId)
}
}
}
}

View File

@ -13,7 +13,7 @@ import (
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/p2p/enode"
"math/big"
)
@ -43,16 +43,6 @@ const (
// OrgKeyAction represents an action in cluster contract
type OrgKeyAction int
const (
AddMasterOrg OrgKeyAction = iota
AddSubOrg
AddOrgVoter
RemoveOrgVoter
AddOrgKey
RemoveOrgKey
ApprovePendingOp
)
// return values for checkNodeDetails function
type NodeCheckRetVal int
@ -78,7 +68,6 @@ type QuorumControlsAPI struct {
ethClnt *ethclient.Client
acntMgr *accounts.Manager
txOpt *bind.TransactOpts
permContr *pbind.Permissions
clustContr *obind.Cluster
key *ecdsa.PrivateKey
permEnabled bool
@ -129,111 +118,50 @@ type ExecStatus struct {
}
var (
ErrNoVoterAccount = ExecStatus{false, "No voter account registered. Add voter first"}
ErrInvalidNode = ExecStatus{false, "Invalid node id"}
ErrAccountNotAVoter = ExecStatus{false, "Account is not a voter. Action cannot be approved"}
ErrNotNetworkAdmin = ExecStatus{false, "Operation can be performed by network admin only. Account not a network admin."}
ErrNotOrgAdmin = ExecStatus{false, "Operation can be performed by org admin only. Account not a org admin."}
ErrNodePresent = ExecStatus{false, "EnodeId already part of network."}
ErrInvalidNode = ExecStatus{false, "Invalid enode id"}
ErrInvalidAccount = ExecStatus{false, "Invalid account id"}
ErrInvalidAccountAccess = ExecStatus{false, "Invalid account access type"}
ErrFailedExecution = ExecStatus{false, "Failed to execute permission action"}
ErrNodeDetailsMismatch = ExecStatus{false, "Node details mismatch"}
ErrPermissionDisabled = ExecStatus{false, "Permissions control not enabled"}
ErrOrgDisabled = ExecStatus{false, "Org key management not enabled for the network"}
ErrAccountAccess = ExecStatus{false, "Account does not have sufficient access for operation"}
ErrVoterAccountAccess = ExecStatus{false, "Voter account does not have sufficient access"}
ErrMasterOrgExists = ExecStatus{false, "Master org already exists"}
ErrInvalidMasterOrg = ExecStatus{false, "Master org does not exist. Add master org first"}
ErrInvalidOrg = ExecStatus{false, "Org does not exist. Add org first"}
ErrOrgExists = ExecStatus{false, "Org already exists"}
ErrVoterExists = ExecStatus{false, "Voter account exists"}
ErrPendingApprovals = ExecStatus{false, "Pending approvals for the organization. Approve first"}
ErrKeyExists = ExecStatus{false, "Key exists for the organization"}
ErrKeyInUse = ExecStatus{false, "Key already in use in another master organization"}
ErrKeyNotFound = ExecStatus{false, "Key not found for the organization"}
ErrNothingToApprove = ExecStatus{false, "Nothing to approve"}
ErrNothingToCancel = ExecStatus{false, "Nothing to cancel"}
ErrNodeProposed = ExecStatus{false, "Node already proposed for the action"}
ErrAccountIsNotVoter = ExecStatus{false, "Not a voter account"}
ErrBlacklistedNode = ExecStatus{false, "Blacklisted node. Operation not allowed"}
ErrOpNotAllowed = ExecStatus{false, "Operation not allowed"}
ErrLastFullAccessAcct = ExecStatus{false, "Last account with full access. Operation not allowed"}
ErrNodeOrgMismatch = ExecStatus{false, "Enode id passed does not belong to the organization."}
ErrBlacklistedNode = ExecStatus{false, "Blacklisted node. Operation not allowed"}
ErrAccountOrgAdmin = ExecStatus{false, "Account already org admin for the org"}
ErrOrgAdminExists = ExecStatus{false, "Org admin exists for the org"}
ErrAccountInUse = ExecStatus{false, "Account already in use in another organization"}
ErrRoleExists = ExecStatus{false, "Role exists for the org"}
ErrRoleDoesNotExist = ExecStatus{false, "Role not found for org. Add role first"}
ErrRoleActive = ExecStatus{false, "Accounts linked to the role. Cannot be removed"}
ErrAdminRoles = ExecStatus{false, "Admin role cannot be removed"}
ExecSuccess = ExecStatus{true, "Action completed successfully"}
)
var (
nodeApproveStatus = map[uint8]string{
0: "NotInNetwork",
1: "PendingApproval",
2: "Approved",
3: "PendingDeactivation",
4: "Deactivated",
5: "PendingActivation",
6: "PendingBlacklisting",
7: "Blacklisted",
}
accountPermMap = map[uint8]string{
0: "ReadOnly",
1: "Transact",
2: "ContractDeploy",
3: "FullAccess",
}
pendingOpMap = map[uint8]string{
0: "None",
1: "Add",
2: "Remove",
}
)
// NewQuorumControlsAPI creates a new QuorumControlsAPI to access quorum services
func NewQuorumControlsAPI(tp *core.TxPool, am *accounts.Manager) *QuorumControlsAPI {
return &QuorumControlsAPI{tp, nil, am, nil, nil, nil, nil, false, false, nil, nil}
}
// helper function decodes the node status to string
func decodeNodeStatus(nodeStatus uint8) string {
if status, ok := nodeApproveStatus[nodeStatus]; ok {
return status
}
return "Unknown"
}
// helper function decodes the node status to string
func decodePendingOp(pendingOp uint8) string {
if desc, ok := pendingOpMap[pendingOp]; ok {
return desc
}
return "Unknown"
return &QuorumControlsAPI{tp, nil, am, nil, nil, nil, false, false, nil, nil}
}
//Init initializes QuorumControlsAPI with eth client, permission contract and org key management control
func (p *QuorumControlsAPI) Init(ethClnt *ethclient.Client, key *ecdsa.PrivateKey, apiName string, pconfig *types.PermissionConfig, pc *pbind.PermInterface) error {
// check if the interface contract is deployed or not. if not
// permissions apis will not work. return error
p.ethClnt = ethClnt
if apiName == "quorumPermission" {
var contractAddress common.Address
//TODO: to be updated with new contract API
//if pconfig.IsEmpty() {
contractAddress = params.QuorumPermissionsContract
//} else {
// contractAddress = common.HexToAddress(pconfig.InterfAddress)
//}
permContr, err := pbind.NewPermissions(contractAddress, p.ethClnt)
if err != nil {
return err
}
p.permConfig = pconfig
p.permContr = permContr
p.permEnabled = true
} else {
clustContr, err := obind.NewCluster(params.QuorumPrivateKeyManagementContract, p.ethClnt)
if err != nil {
if _, err := pbind.NewPermInterface(p.permConfig.InterfAddress, p.ethClnt); err != nil {
return err
}
p.clustContr = clustContr
p.orgEnabled = true
}
p.permEnabled = true
p.key = key
p.permInterf = pc
return nil
}
@ -253,29 +181,12 @@ func (s *QuorumControlsAPI) AcctList() []types.AccountInfo {
return types.AcctInfoMap.GetAcctList()
}
func (s *QuorumControlsAPI) newOrgKeySessionWithNodeKeySigner() *obind.ClusterSession {
auth := bind.NewKeyedTransactor(s.key)
cs := &obind.ClusterSession{
Contract: s.clustContr,
CallOpts: bind.CallOpts{
Pending: true,
},
TransactOpts: bind.TransactOpts{
From: auth.From,
Signer: auth.Signer,
GasLimit: 4700000,
GasPrice: big.NewInt(0),
},
}
return cs
func (s *QuorumControlsAPI) AddOrg(orgId string, url string, acct common.Address, txa ethapi.SendTxArgs) ExecStatus {
return s.executePermAction(AddOrg, txArgs{orgId: orgId, url: url, acctId: acct, txa: txa})
}
func (s *QuorumControlsAPI) AddOrg(orgId string, url string, txa ethapi.SendTxArgs) ExecStatus {
return s.executePermAction(AddOrg, txArgs{orgId: orgId, url: url, txa: txa})
}
func (s *QuorumControlsAPI) ApproveOrg(orgId string, url string, txa ethapi.SendTxArgs) ExecStatus {
return s.executePermAction(ApproveOrg, txArgs{orgId: orgId, url: url, txa: txa})
func (s *QuorumControlsAPI) ApproveOrg(orgId string, url string, acct common.Address, txa ethapi.SendTxArgs) ExecStatus {
return s.executePermAction(ApproveOrg, txArgs{orgId: orgId, url: url, acctId: acct, txa: txa})
}
func (s *QuorumControlsAPI) UpdateOrgStatus(orgId string, status uint8, txa ethapi.SendTxArgs) ExecStatus {
@ -303,51 +214,102 @@ func (s *QuorumControlsAPI) ApproveOrgAdminAccount(acct common.Address, txa etha
return s.executePermAction(ApproveOrgAdminAccount, txArgs{acctId: acct, txa: txa})
}
func (s *QuorumControlsAPI) AddNewRole(roleId string, orgId string, access uint8, isVoter bool, txa ethapi.SendTxArgs) ExecStatus {
func (s *QuorumControlsAPI) AddNewRole(orgId string, roleId string, access uint8, isVoter bool, txa ethapi.SendTxArgs) ExecStatus {
return s.executePermAction(AddNewRole, txArgs{orgId: orgId, roleId: roleId, accessType: access, isVoter: isVoter, txa: txa})
}
func (s *QuorumControlsAPI) RemoveRole(roleId string, orgId string, txa ethapi.SendTxArgs) ExecStatus {
func (s *QuorumControlsAPI) RemoveRole(orgId string, roleId string, txa ethapi.SendTxArgs) ExecStatus {
return s.executePermAction(RemoveRole, txArgs{orgId: orgId, roleId: roleId, txa: txa})
}
func (s *QuorumControlsAPI) AssignAccountRole(acct common.Address, roleId string, orgId string, txa ethapi.SendTxArgs) ExecStatus {
func (s *QuorumControlsAPI) AssignAccountRole(acct common.Address, orgId string, roleId string, txa ethapi.SendTxArgs) ExecStatus {
return s.executePermAction(AssignAccountRole, txArgs{orgId: orgId, roleId: roleId, acctId: acct, txa: txa})
}
// AddMasterOrg adds an new master organization to the contract
func (s *QuorumControlsAPI) AddMasterOrg(morgId string, txa ethapi.SendTxArgs) ExecStatus {
return s.executeOrgKeyAction(AddMasterOrg, txArgs{txa: txa, morgId: morgId})
// check if the account is network admin
func (s *QuorumControlsAPI) isNetworkAdmin(account common.Address) bool {
ac := types.AcctInfoMap.GetAccount(account)
return ac != nil && ac.RoleId == s.permConfig.NwAdminRole
}
// AddSubOrg ass a sub org to the master org
func (s *QuorumControlsAPI) AddSubOrg(orgId string, morgId string, txa ethapi.SendTxArgs) ExecStatus {
return s.executeOrgKeyAction(AddSubOrg, txArgs{txa: txa, orgId: orgId, morgId: morgId})
func (s *QuorumControlsAPI) isOrgAdmin(account common.Address, orgId string) bool {
ac := types.AcctInfoMap.GetAccount(account)
log.Info("SMK-isOrgAdmin @ 237", "account", account, "org", orgId)
if ac != nil {
log.Info("SMK-isOrgAdmin @ 239", "account", ac.AcctId, "org", ac.OrgId, "role", ac.RoleId, "configRole", s.permConfig.OrgAdminRole)
}
return ac != nil && (ac.RoleId == s.permConfig.OrgAdminRole && ac.OrgId == orgId)
}
// AddOrgVoter adds voter account to a master org
func (s *QuorumControlsAPI) AddOrgVoter(morgId string, acctId common.Address, txa ethapi.SendTxArgs) ExecStatus {
return s.executeOrgKeyAction(AddOrgVoter, txArgs{txa: txa, morgId: morgId, acctId: acctId})
func (s *QuorumControlsAPI) checkOrgExists(orgId string) bool {
org := types.OrgInfoMap.GetOrg(orgId)
return org != nil
}
// RemoveOrgVoter removes voter account to a master org
func (s *QuorumControlsAPI) RemoveOrgVoter(morgId string, acctId common.Address, txa ethapi.SendTxArgs) ExecStatus {
return s.executeOrgKeyAction(RemoveOrgVoter, txArgs{txa: txa, morgId: morgId, acctId: acctId})
func (s *QuorumControlsAPI) checkNodeExists(enodeId string) bool {
node := types.NodeInfoMap.GetNodeByUrl(enodeId)
return node != nil
}
// AddOrgKey adds an org key to the org id
func (s *QuorumControlsAPI) AddOrgKey(orgId string, tmKey string, txa ethapi.SendTxArgs) ExecStatus {
return s.executeOrgKeyAction(AddOrgKey, txArgs{txa: txa, orgId: orgId, tmKey: tmKey})
func (s *QuorumControlsAPI) validatePendingOp(authOrg, orgId, url string, account common.Address, pendingOp int64, pinterf *pbind.PermInterfaceSession) bool {
pOrg, pUrl, pAcct, op, err := pinterf.GetPendingOp(authOrg)
return err == nil && (op.Int64() == pendingOp && pOrg == orgId && pUrl == url && pAcct == account)
}
// RemoveOrgKey removes an org key combination from the org key map
func (s *QuorumControlsAPI) RemoveOrgKey(orgId string, tmKey string, txa ethapi.SendTxArgs) ExecStatus {
return s.executeOrgKeyAction(RemoveOrgKey, txArgs{txa: txa, orgId: orgId, tmKey: tmKey})
func (s *QuorumControlsAPI) checkPendingOp(orgId string, pinterf *pbind.PermInterfaceSession) bool {
_, _, _, op, err := pinterf.GetPendingOp(orgId)
return err == nil && op.Int64() != 0
}
// ApprovePendingOp approves any key add or delete activity
func (s *QuorumControlsAPI) ApprovePendingOp(orgId string, txa ethapi.SendTxArgs) ExecStatus {
return s.executeOrgKeyAction(ApprovePendingOp, txArgs{txa: txa, orgId: orgId})
func (s *QuorumControlsAPI) checkOrgStatus(orgId string, op uint8) bool {
org := types.OrgInfoMap.GetOrg(orgId)
return (op == 3 && org.Status == types.OrgApproved) || (op == 5 && org.Status == types.OrgSuspended)
}
func (s *QuorumControlsAPI) valNodeStatusChange(orgId, url string, op int64) (ExecStatus, error) {
// validates if the enode is linked the passed organization
node := types.NodeInfoMap.GetNodeByUrl(url)
if node.OrgId != orgId {
return ErrNodeOrgMismatch, errors.New("node does not belong to the organization passed")
}
if node.Status == types.NodeBlackListed {
return ErrBlacklistedNode, errors.New("blacklisted node. operation not allowed")
}
// validate the op and node status and check if the op can be performed
if op != 3 && op != 4 && op != 5 {
return ErrOpNotAllowed, errors.New("invalid node status change operation")
}
if (op == 3 && node.Status != types.NodeApproved) || (op == 4 && node.Status != types.NodeDeactivated) {
return ErrOpNotAllowed, errors.New("node status change cannot be performed")
}
return ExecSuccess, nil
}
func (s *QuorumControlsAPI) checkOrgAdminExists(orgId string, account common.Address) (ExecStatus, error) {
ac := types.AcctInfoMap.GetAccount(account)
if ac == nil {
orgAcctList := types.AcctInfoMap.GetAcctListOrg(orgId)
if len(orgAcctList) > 0 {
for _, a := range orgAcctList {
if a.IsOrgAdmin == true {
return ErrOrgAdminExists, errors.New("org admin exists for the org")
}
}
}
} else {
if ac.OrgId != orgId {
return ErrAccountInUse, errors.New("account part of another org")
}
if ac.IsOrgAdmin == true {
return ErrAccountOrgAdmin, errors.New("account already org admin for the org")
}
}
return ExecSuccess, nil
}
// executePermAction helps to execute an action in permission contract
@ -356,7 +318,6 @@ func (s *QuorumControlsAPI) executePermAction(action PermAction, args txArgs) Ex
if !s.permEnabled {
return ErrPermissionDisabled
}
log.Info("AJ-exec perm action", "action", action, "txargs", args)
var err error
var w accounts.Wallet
@ -371,36 +332,201 @@ func (s *QuorumControlsAPI) executePermAction(action PermAction, args txArgs) Ex
switch action {
case AddOrg:
tx, err = pinterf.AddOrg(args.orgId, args.url)
// check if caller is network admin
if !s.isNetworkAdmin(args.txa.From) {
return ErrNotNetworkAdmin
}
// check if any previous op is pending approval for network admin
if s.checkPendingOp(s.permConfig.NwAdminOrg, pinterf) {
return ErrPendingApprovals
}
// check if org already exists
if s.checkOrgExists(args.orgId) {
return ErrOrgExists
}
// validate node id and
_, err := enode.ParseV4(args.url)
if err != nil {
return ErrInvalidNode
}
// check if node already there
if s.checkNodeExists(args.url) {
return ErrNodePresent
}
// check if account is already part of another org
if execStatus, er := s.checkOrgAdminExists(args.orgId, args.acctId); er != nil {
return execStatus
}
tx, err = pinterf.AddOrg(args.orgId, args.url, args.acctId)
case ApproveOrg:
tx, err = pinterf.ApproveOrg(args.orgId, args.url)
// check caller is network admin
if !s.isNetworkAdmin(args.txa.From) {
return ErrNotNetworkAdmin
}
if !s.validatePendingOp(s.permConfig.NwAdminOrg, args.orgId, args.url, args.acctId, 1, pinterf) {
return ErrNothingToApprove
}
// check if anything pending approval
tx, err = pinterf.ApproveOrg(args.orgId, args.url, args.acctId)
case UpdateOrgStatus:
// check if called is network admin
if !s.isNetworkAdmin(args.txa.From) {
return ErrNotNetworkAdmin
}
// check if status update can be performed. Org should be approved for suspension
if !s.checkOrgStatus(args.orgId, args.status) {
return ErrOpNotAllowed
}
if args.status != 3 && args.status != 5 {
return ErrOpNotAllowed
}
// and in suspended state for suspension revoke
tx, err = pinterf.UpdateOrgStatus(args.orgId, big.NewInt(int64(args.status)))
case ApproveOrgStatus:
// check if called is network admin
if !s.isNetworkAdmin(args.txa.From) {
return ErrNotNetworkAdmin
}
// check if anything is pending approval
var pendingOp int64
if args.status == 3 {
pendingOp = 2
} else if args.status == 5 {
pendingOp = 3
} else {
return ErrOpNotAllowed
}
if !s.validatePendingOp(s.permConfig.NwAdminOrg, args.orgId, "", common.Address{}, pendingOp, pinterf) {
return ErrNothingToApprove
}
// validate that status change is pending approval
tx, err = pinterf.ApproveOrgStatus(args.orgId, big.NewInt(int64(args.status)))
case AddNode:
// check if org admin
if !s.isOrgAdmin(args.txa.From, args.orgId) {
return ErrNotOrgAdmin
}
// validate node id and
_, err := enode.ParseV4(args.url)
if err != nil {
return ErrInvalidNode
}
// check if node is already there
tx, err = pinterf.AddNode(args.orgId, args.url)
case UpdateNodeStatus:
// check if org admin
if !s.isOrgAdmin(args.txa.From, args.orgId) {
return ErrNotOrgAdmin
}
// validate node id and
_, err := enode.ParseV4(args.url)
if err != nil {
return ErrInvalidNode
}
// validation status change is with in allowed set
if execStatus, er := s.valNodeStatusChange(args.orgId, args.url, int64(args.status)); er != nil {
return execStatus
}
// check node status for operation
tx, err = pinterf.UpdateNodeStatus(args.orgId, args.url, big.NewInt(int64(args.status)))
case AssignOrgAdminAccount:
// check if caller is network admin
if !s.isNetworkAdmin(args.txa.From) {
return ErrNotNetworkAdmin
}
// check if account is already part of another org
if execStatus, er := s.checkOrgAdminExists(args.orgId, args.acctId); er != nil {
return execStatus
}
// check if account is already in use in another org
tx, err = pinterf.AssignOrgAdminAccount(args.orgId, args.acctId)
case ApproveOrgAdminAccount:
// check if caller is network admin
if !s.isNetworkAdmin(args.txa.From) {
return ErrNotNetworkAdmin
}
// validate pending op
if !s.validatePendingOp(s.permConfig.NwAdminOrg, types.AcctInfoMap.GetAccount(args.acctId).OrgId, "", args.acctId, 4, pinterf) {
return ErrNothingToApprove
}
// check if anything is pending approval
tx, err = pinterf.ApproveOrgAdminAccount(args.acctId)
case AddNewRole:
// check if org admin
if !s.isOrgAdmin(args.txa.From, args.orgId) {
return ErrNotOrgAdmin
}
// validate if role is already present
if types.RoleInfoMap.GetRole(args.orgId, args.roleId) != nil {
return ErrRoleExists
}
// check if role is already there in the org
tx, err = pinterf.AddNewRole(args.roleId, args.orgId, big.NewInt(int64(args.accessType)), args.isVoter)
case RemoveRole:
// check if org admin
if !s.isOrgAdmin(args.txa.From, args.orgId) {
return ErrNotOrgAdmin
}
// admin roles cannot be removed
if args.roleId == s.permConfig.OrgAdminRole || args.roleId == s.permConfig.NwAdminRole {
return ErrAdminRoles
}
// check if the role has active accounts. if yes operations should not be allowed
if len(types.AcctInfoMap.GetAcctListRole(args.orgId, args.roleId)) != 0 {
return ErrRoleActive
}
tx, err = pinterf.RemoveRole(args.roleId, args.orgId)
case AssignAccountRole:
// check if org admin
if !s.isOrgAdmin(args.txa.From, args.orgId) {
return ErrNotOrgAdmin
}
// check if the role is part of the org
if types.RoleInfoMap.GetRole(args.orgId, args.roleId) == nil {
return ErrRoleDoesNotExist
}
// check if the account is part of another org
if ac := types.AcctInfoMap.GetAccount(args.acctId); ac != nil {
if ac.OrgId != args.orgId {
return ErrAccountInUse
}
}
tx, err = pinterf.AssignAccountRole(args.acctId, args.orgId, args.roleId)
}
@ -412,182 +538,6 @@ func (s *QuorumControlsAPI) executePermAction(action PermAction, args txArgs) Ex
return ExecSuccess
}
// returns the master org, org and linked key details
func (s *QuorumControlsAPI) OrgKeyInfo() []orgInfo {
if !s.orgEnabled {
orgInfoArr := make([]orgInfo, 1)
orgInfoArr[0].MasterOrgId = "Org key management not enabled for the network"
return orgInfoArr
}
ps := s.newOrgKeySessionWithNodeKeySigner()
// get the total number of accounts with permissions
orgCnt, err := ps.GetNumberOfOrgs()
if err != nil {
return nil
}
orgCntI := orgCnt.Int64()
log.Debug("total orgs", "count", orgCntI)
orgArr := make([]orgInfo, orgCntI)
// loop for each index and get the node details from the contract
i := int64(0)
for i < orgCntI {
orgId, morgId, err := ps.GetOrgInfo(big.NewInt(i))
if err != nil {
log.Error("error getting org info", "err", err)
} else {
orgArr[i].SubOrgId = orgId
orgArr[i].MasterOrgId = morgId
// get the list of keys for the organization
keyCnt, err := ps.GetOrgKeyCount(orgId)
if err != nil {
return nil
}
keyCntI := keyCnt.Int64()
log.Debug("total keys", "count", keyCntI)
var keyArr []string
// loop for each index and get the node details from the contract
j := int64(0)
for j < keyCntI {
key, status, err := ps.GetOrgKey(orgId, big.NewInt(j))
if err == nil && status {
keyArr = append(keyArr, key)
}
j++
}
orgArr[i].SubOrgKeyList = keyArr
}
i++
}
return orgArr
}
// executeOrgKeyAction helps to execute an action in cluster contract
func (s *QuorumControlsAPI) executeOrgKeyAction(action OrgKeyAction, args txArgs) ExecStatus {
if !s.orgEnabled {
return ErrOrgDisabled
}
w, err := s.validateAccount(args.txa.From)
if err != nil {
return ExecStatus{false, err.Error()}
}
ps := s.newClusterSession(w, args.txa)
var tx *types.Transaction
switch action {
case AddMasterOrg:
// check if the master org exists. if yes throw error
ret, _ := ps.CheckMasterOrgExists(args.morgId)
if ret {
return ErrMasterOrgExists
}
tx, err = ps.AddMasterOrg(args.morgId)
case AddSubOrg:
ret, _ := ps.CheckMasterOrgExists(args.morgId)
if !ret {
return ErrInvalidMasterOrg
}
ret, err = ps.CheckOrgExists(args.orgId)
if ret {
return ErrOrgExists
}
tx, err = ps.AddSubOrg(args.orgId, args.morgId)
case AddOrgVoter:
if locErr, execStatus := valAccountAccessVoter(args.txa.From, args.acctId); locErr != nil {
return execStatus
}
ret, _ := ps.CheckMasterOrgExists(args.morgId)
if !ret {
return ErrInvalidMasterOrg
}
ret, _ = ps.CheckIfVoterExists(args.morgId, args.acctId)
if ret {
return ErrVoterExists
}
tx, err = ps.AddVoter(args.morgId, args.acctId)
case RemoveOrgVoter:
if locErr, execStatus := valAccountAccessVoter(args.txa.From, common.Address{}); locErr != nil {
return execStatus
}
ret, _ := ps.CheckMasterOrgExists(args.morgId)
if !ret {
return ErrInvalidMasterOrg
}
ret, _ = ps.CheckIfVoterExists(args.morgId, args.acctId)
if !ret {
return ErrInvalidAccount
}
tx, err = ps.DeleteVoter(args.morgId, args.acctId)
case AddOrgKey:
ret, _ := ps.CheckOrgExists(args.orgId)
if !ret {
return ErrInvalidOrg
}
ret, _ = ps.CheckVotingAccountExists(args.orgId)
if !ret {
return ErrNoVoterAccount
}
ret, _ = ps.CheckOrgPendingOp(args.orgId)
if ret {
return ErrPendingApprovals
}
ret, _ = ps.CheckIfKeyExists(args.orgId, args.tmKey)
if ret {
return ErrKeyExists
}
ret, _ = ps.CheckKeyClash(args.orgId, args.tmKey)
if ret {
return ErrKeyInUse
}
tx, err = ps.AddOrgKey(args.orgId, args.tmKey)
case RemoveOrgKey:
ret, _ := ps.CheckOrgExists(args.orgId)
if !ret {
return ErrInvalidOrg
}
ret, _ = ps.CheckVotingAccountExists(args.orgId)
if !ret {
return ErrNoVoterAccount
}
ret, _ = ps.CheckOrgPendingOp(args.orgId)
if ret {
return ErrPendingApprovals
}
ret, _ = ps.CheckIfKeyExists(args.orgId, args.tmKey)
if !ret {
return ErrKeyNotFound
}
tx, err = ps.DeleteOrgKey(args.orgId, args.tmKey)
case ApprovePendingOp:
ret, _ := ps.CheckOrgExists(args.orgId)
if !ret {
return ErrInvalidOrg
}
ret, _ = ps.IsVoter(args.orgId, args.txa.From)
if !ret {
return ErrAccountNotAVoter
}
ret, _ = ps.CheckOrgPendingOp(args.orgId)
if !ret {
return ErrNothingToApprove
}
tx, err = ps.ApprovePendingOp(args.orgId)
}
if err != nil {
log.Error("Failed to execute orgKey action", "action", action, "err", err)
return ExecStatus{false, err.Error()}
}
log.Debug("executed orgKey action", "action", action, "tx", tx)
return ExecSuccess
}
// validateAccount validates the account and returns the wallet associated with that for signing the transaction
func (s *QuorumControlsAPI) validateAccount(from common.Address) (accounts.Wallet, error) {
acct := accounts.Account{Address: from}
@ -616,25 +566,6 @@ func (s *QuorumControlsAPI) newPermInterfaceSession(w accounts.Wallet, txa ethap
return ps
}
// newClusterSession creates a new cluster contract session
func (s *QuorumControlsAPI) newClusterSession(w accounts.Wallet, txa ethapi.SendTxArgs) *obind.ClusterSession {
frmAcct, transactOpts, gasLimit, gasPrice, nonce := s.getTxParams(txa, w)
cs := &obind.ClusterSession{
Contract: s.clustContr,
CallOpts: bind.CallOpts{
Pending: true,
},
TransactOpts: bind.TransactOpts{
From: frmAcct.Address,
GasLimit: gasLimit,
GasPrice: gasPrice,
Signer: transactOpts.Signer,
Nonce: nonce,
},
}
return cs
}
// getTxParams extracts the transaction related parameters
func (s *QuorumControlsAPI) getTxParams(txa ethapi.SendTxArgs, w accounts.Wallet) (accounts.Account, *bind.TransactOpts, uint64, *big.Int, *big.Int) {
frmAcct := accounts.Account{Address: txa.From}

View File

@ -2,7 +2,6 @@ package types
import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/hashicorp/golang-lru"
"sync"
)
@ -108,8 +107,6 @@ type RoleKey struct {
}
type AccountKey struct {
OrgId string
RoleId string
AcctId common.Address
}
@ -189,18 +186,11 @@ func (o *OrgCache) GetOrg(orgId string) *OrgInfo {
o.mux.Lock()
key := OrgKey{OrgId: orgId}
if ent, ok := o.c.Get(key); ok {
log.Info("AJ-OrgFound", "orgId", orgId)
return ent.(*OrgInfo)
}
return nil
}
func (o *OrgCache) Show() {
for i, k := range o.c.Keys() {
v, _ := o.c.Get(k)
log.Info("AJ-Org", "i", i, "key", k, "value", v)
}
}
func (o *OrgCache) GetOrgList() []OrgInfo {
var olist []OrgInfo
for _, k := range o.c.Keys() {
@ -221,32 +211,16 @@ func (n *NodeCache) UpsertNode(orgId string, url string, status NodeStatus) {
func (n *NodeCache) GetNodeByUrl(url string) *NodeInfo {
defer n.mux.Unlock()
n.mux.Lock()
var key NodeKey
var found = false
for _, k := range n.c.Keys() {
ent := k.(NodeKey)
if ent.Url == url {
key = ent
found = true
break
v, _ := n.c.Get(ent)
return v.(*NodeInfo)
}
}
if found {
v, _ := n.c.Get(key)
ent := v.(*NodeInfo)
log.Info("AJ-NodeFound", "url", ent.Url, "orgId", ent.OrgId)
return ent
}
return nil
}
func (o *NodeCache) Show() {
for i, k := range o.c.Keys() {
v, _ := o.c.Get(k)
log.Info("AJ-Node", "i", i, "key", k, "value", v)
}
}
func (o *NodeCache) GetNodeList() []NodeInfo {
var olist []NodeInfo
for _, k := range o.c.Keys() {
@ -260,47 +234,51 @@ func (o *NodeCache) GetNodeList() []NodeInfo {
func (a *AcctCache) UpsertAccount(orgId string, role string, acct common.Address, orgAdmin bool, status AcctStatus) {
defer a.mux.Unlock()
a.mux.Lock()
key := AccountKey{orgId, role, acct}
key := AccountKey{acct}
a.c.Add(key, &AccountInfo{orgId, role, acct, orgAdmin, status})
}
func (a *AcctCache) GetAccountByAccount(acct common.Address) *AccountInfo {
func (a *AcctCache) GetAccount(acct common.Address) *AccountInfo {
defer a.mux.Unlock()
a.mux.Lock()
var key AccountKey
var found = false
for _, k := range a.c.Keys() {
ent := k.(AccountKey)
if ent.AcctId == acct {
key = ent
found = true
break
}
}
if found {
v, _ := a.c.Get(key)
ent := v.(*AccountInfo)
log.Info("AJ-AccountFound", "org", ent.OrgId, "role", ent.RoleId, "acct", ent.AcctId)
return ent
if v, ok := a.c.Get(AccountKey{acct}); ok {
return v.(*AccountInfo)
}
return nil
}
func (o *AcctCache) Show() {
for i, k := range o.c.Keys() {
v, _ := o.c.Get(k)
log.Info("AJ-Accounts", "i", i, "key", k, "value", v)
func (a *AcctCache) GetAcctList() []AccountInfo {
var alist []AccountInfo
for _, k := range a.c.Keys() {
v, _ := a.c.Get(k)
vp := v.(*AccountInfo)
alist = append(alist, *vp)
}
return alist
}
func (o *AcctCache) GetAcctList() []AccountInfo {
var olist []AccountInfo
for _, k := range o.c.Keys() {
v, _ := o.c.Get(k)
func (a *AcctCache) GetAcctListOrg(orgId string) []AccountInfo {
var alist []AccountInfo
for _, k := range a.c.Keys() {
v, _ := a.c.Get(k)
vp := v.(*AccountInfo)
olist = append(olist, *vp)
if vp.OrgId == orgId {
alist = append(alist, *vp)
}
return olist
}
return alist
}
func (a *AcctCache) GetAcctListRole(orgId, roleId string) []AccountInfo {
var alist []AccountInfo
for _, k := range a.c.Keys() {
v, _ := a.c.Get(k)
vp := v.(*AccountInfo)
if vp.OrgId == orgId && vp.RoleId == roleId {
alist = append(alist, *vp)
}
}
return alist
}
func (r *RoleCache) UpsertRole(orgId string, role string, voter bool, access AccessType, active bool) {
@ -316,19 +294,11 @@ func (r *RoleCache) GetRole(orgId string, roleId string) *RoleInfo {
r.mux.Lock()
key := RoleKey{OrgId: orgId, RoleId: roleId}
if ent, ok := r.c.Get(key); ok {
log.Info("AJ-RoleFound", "orgId", orgId, "roleId", roleId)
return ent.(*RoleInfo)
}
return nil
}
func (r *RoleCache) Show() {
for i, k := range r.c.Keys() {
v, _ := r.c.Get(k)
log.Info("AJ-Role", "i", i, "key", k, "value", v)
}
}
func (o *RoleCache) GetRoleList() []RoleInfo {
var olist []RoleInfo
for _, k := range o.c.Keys() {
@ -342,24 +312,14 @@ func (o *RoleCache) GetRoleList() []RoleInfo {
// Returns the access type for an account. If not found returns
// default access
func GetAcctAccess(acctId common.Address) AccessType {
log.Info("AJ-get acct access ", "acct", acctId)
if a := AcctInfoMap.GetAccountByAccount(acctId); a != nil {
log.Info("AJ-Acct found", "a", a)
if a := AcctInfoMap.GetAccount(acctId); a != nil {
o := OrgInfoMap.GetOrg(a.OrgId)
r := RoleInfoMap.GetRole(a.OrgId, a.RoleId)
if o != nil && r != nil {
log.Info("AJ-org role found")
if (o.Status == OrgApproved || o.Status == OrgRevokeSuspension) && r.Active {
log.Info("AJ-access found", "access", r.Access)
if o.Status == OrgApproved && r.Active {
return r.Access
} else {
log.Info("AJ-access org or role invalid")
}
} else {
log.Info("AJ-access org or role is missing")
}
} else {
log.Info("AJ-Acct not found", "def access", DefaultAccess)
}
return DefaultAccess
}

View File

@ -6,7 +6,7 @@ Account permissioning feature introduces controls at account level. This will co
It should be noted that both the above features will be available when Quorum geth is brought in `--permissioned` mode with the set up as described in the next section.
## Set up
Node permissioning and account access control is managed by a smart contract [Permission.sol](../controls/permission/Permission.sol). The precompiled byte code of the smart contract is deployed at address `0x000000000000000000020` in network boot-up process. The binding of the precompiled byte code with the address is in `genesis.json`. The initial set of account that will have full access when the network is up, should given as a part of `genesis.json` as shown below:
Node permissioning and account access control is managed by a smart contract [PermissionsInterface.sol](../controls/permission/PermissionsInterface.sol). The precompiled byte code of the smart contract is deployed at address `0x000000000000000000020` in network boot-up process. The binding of the precompiled byte code with the address is in `genesis.json`. The initial set of account that will have full access when the network is up, should given as a part of `genesis.json` as shown below:
```
{
"alloc": {

View File

@ -748,14 +748,14 @@ web3._extend({
new web3._extend.Method({
name: 'addOrg',
call: 'quorumPermission_addOrg',
params: 3,
inputFormatter: [null,null,web3._extend.formatters.inputTransactionFormatter]
params: 4,
inputFormatter: [null,null,web3._extend.formatters.inputAddressFormatter,web3._extend.formatters.inputTransactionFormatter]
}),
new web3._extend.Method({
name: 'approveOrg',
call: 'quorumPermission_approveOrg',
params: 3,
inputFormatter: [null,null,web3._extend.formatters.inputTransactionFormatter]
params: 4,
inputFormatter: [null,null,web3._extend.formatters.inputAddressFormatter,web3._extend.formatters.inputTransactionFormatter]
}),
new web3._extend.Method({
name: 'updateOrgStatus',