Fetch multiple nodes from contract (#1430)
This commit is contained in:
parent
8baae97e2e
commit
f5875d62c5
|
@ -242,7 +242,7 @@ func (b *StatusBackend) CallRPC(inputJSON string) (string, error) {
|
||||||
return client.CallRaw(inputJSON), nil
|
return client.CallRaw(inputJSON), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNodesFromContract returns a list of mailservers
|
// GetNodesFromContract returns a list of nodes from the contract
|
||||||
func (b *StatusBackend) GetNodesFromContract(rpcEndpoint string, contractAddress string) ([]string, error) {
|
func (b *StatusBackend) GetNodesFromContract(rpcEndpoint string, contractAddress string) ([]string, error) {
|
||||||
var response []string
|
var response []string
|
||||||
|
|
||||||
|
@ -259,12 +259,20 @@ func (b *StatusBackend) GetNodesFromContract(rpcEndpoint string, contractAddress
|
||||||
return response, err
|
return response, err
|
||||||
}
|
}
|
||||||
|
|
||||||
node, err := contract.Nodes(nil, big.NewInt(0))
|
nodeCount, err := contract.NodeCount(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return response, err
|
return response, err
|
||||||
}
|
}
|
||||||
|
|
||||||
response = append(response, node)
|
one := big.NewInt(1)
|
||||||
|
for i := big.NewInt(0); i.Cmp(nodeCount) < 0; i.Add(i, one) {
|
||||||
|
node, err := contract.Nodes(nil, i)
|
||||||
|
if err != nil {
|
||||||
|
return response, err
|
||||||
|
}
|
||||||
|
response = append(response, node)
|
||||||
|
}
|
||||||
|
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
### Mailserver registry
|
||||||
|
|
||||||
|
The code for the contract interface used is at https://github.com/status-im/network-incentivisation/blob/master/contracts/Nodes.sol
|
||||||
|
and has been generated with abigen.
|
||||||
|
|
||||||
|
`abigen --sol contracts/Nodes.sol --pkg registry`
|
Loading…
Reference in New Issue