mirror of https://github.com/poanetwork/quorum.git
added api for listing the voters for a master org
This commit is contained in:
parent
45189d42c7
commit
b40b7ab148
File diff suppressed because one or more lines are too long
|
@ -213,6 +213,17 @@ contract Clusterkeys {
|
|||
}
|
||||
// All extenal view functions
|
||||
|
||||
// Get number of voters
|
||||
function getNumberOfVoters(string _morgId) public view returns (uint)
|
||||
{
|
||||
return masterOrgList[getMasterOrgIndex(_morgId)].voterAccount.length;
|
||||
}
|
||||
|
||||
// Get voter
|
||||
function getVoter(string _morgId, uint i) public view returns (address _addr)
|
||||
{
|
||||
return masterOrgList[getMasterOrgIndex(_morgId)].voterAccount[i];
|
||||
}
|
||||
// returns the number of orgs
|
||||
function getNumberOfOrgs() external view returns (uint){
|
||||
return orgNum;
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -92,7 +92,7 @@ contract Permissions {
|
|||
/* public and external functions */
|
||||
// view functions
|
||||
|
||||
// Get number of nodes
|
||||
// Get number of voters
|
||||
function getNumberOfVoters() public view returns (uint)
|
||||
{
|
||||
return voterAcctList.length;
|
||||
|
|
|
@ -591,6 +591,35 @@ func (s *QuorumControlsAPI) executePermAction(action PermAction, args txArgs) Ex
|
|||
return ExecSuccess
|
||||
}
|
||||
|
||||
func (s *QuorumControlsAPI) GetOrgVoterList(morgId string) []string {
|
||||
if !s.orgEnabled {
|
||||
voterArr := make([]string, 1)
|
||||
voterArr[0] = "Permissions control not enabled for the network"
|
||||
return voterArr
|
||||
}
|
||||
ps := s.newOrgKeySessionWithNodeKeySigner()
|
||||
// get the total number of accounts with permissions
|
||||
voterCnt, err := ps.GetNumberOfVoters(morgId)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
voterCntI := voterCnt.Int64()
|
||||
log.Debug("total voters", "count", voterCntI)
|
||||
voterArr := make([]string, voterCntI)
|
||||
// loop for each index and get the node details from the contract
|
||||
i := int64(0)
|
||||
for i < voterCntI {
|
||||
a, err := ps.GetVoter(morgId, big.NewInt(i))
|
||||
if err != nil {
|
||||
log.Error("error getting voter info", "err", err)
|
||||
} else {
|
||||
voterArr[i] = a.String()
|
||||
}
|
||||
i++
|
||||
}
|
||||
return voterArr
|
||||
}
|
||||
|
||||
func (s *QuorumControlsAPI) OrgKeyInfo() []orgInfo {
|
||||
if !s.orgEnabled {
|
||||
orgInfoArr := make([]orgInfo, 1)
|
||||
|
@ -611,7 +640,7 @@ func (s *QuorumControlsAPI) OrgKeyInfo() []orgInfo {
|
|||
for i < orgCntI {
|
||||
orgId, morgId, err := ps.GetOrgInfo(big.NewInt(i))
|
||||
if err != nil {
|
||||
log.Error("error getting voter info", "err", err)
|
||||
log.Error("error getting org info", "err", err)
|
||||
} else {
|
||||
orgArr[i].SubOrgId = orgId
|
||||
orgArr[i].MasterOrgId = morgId
|
||||
|
|
|
@ -840,6 +840,12 @@ web3._extend({
|
|||
params: 1,
|
||||
inputFormatter: [null]
|
||||
}),
|
||||
new web3._extend.Method({
|
||||
name: 'getOrgVoterList',
|
||||
call: 'quorumOrgMgmt_getOrgVoterList',
|
||||
params: 1,
|
||||
inputFormatter: [null]
|
||||
}),
|
||||
],
|
||||
properties:
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue