Skip to content

Commit

Permalink
RPC: endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Jul 10, 2021
1 parent 4364e92 commit 3783958
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,26 @@ func (rpc *NodeRPC) HeadMetadata() (head HeadMetadata, err error) {
err = rpc.get("chains/main/blocks/head/metadata", &head)
return
}

// ActiveDelegatesWithRolls -
func (rpc *NodeRPC) ActiveDelegatesWithRolls() (delegates []string, err error) {
err = rpc.get("chains/main/blocks/head/context/raw/json/active_delegates_with_rolls", &delegates)
return
}

// Delegates -
func (rpc *NodeRPC) Delegates(active *bool) (delegates []string, err error) {
uri := "chains/main/blocks/head/context/delegates"
if active != nil {
uri = fmt.Sprintf("%s?active=%t", uri, *active)
}
err = rpc.get(uri, &delegates)
return
}

// StakingBalance -
func (rpc *NodeRPC) StakingBalance(address string) (balance string, err error) {
uri := fmt.Sprintf("/chains/main/blocks/head/context/delegates/%s/staking_balance", address)
err = rpc.get(uri, &balance)
return
}

1 comment on commit 3783958

@aopoltorzhicky
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.