aboutsummaryrefslogtreecommitdiffstats
path: root/consensus/clique/api.go
diff options
context:
space:
mode:
Diffstat (limited to 'consensus/clique/api.go')
-rw-r--r--consensus/clique/api.go24
1 files changed, 23 insertions, 1 deletions
diff --git a/consensus/clique/api.go b/consensus/clique/api.go
index 0cf25abff..b875eef01 100644
--- a/consensus/clique/api.go
+++ b/consensus/clique/api.go
@@ -31,7 +31,7 @@ type API struct {
}
// GetSnapshot retrieves the state snapshot at a given block.
-func (api *API) GetSnapshot(number *rpc.BlockNumber) (interface{}, error) {
+func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error) {
// Retrieve the requested block number (or current if none requested)
var header *types.Header
if number == nil || *number == rpc.LatestBlockNumber {
@@ -46,6 +46,15 @@ func (api *API) GetSnapshot(number *rpc.BlockNumber) (interface{}, error) {
return api.clique.snapshot(api.chain, header.Number.Uint64(), header.Hash(), nil)
}
+// GetSnapshotAtHash retrieves the state snapshot at a given block.
+func (api *API) GetSnapshotAtHash(hash common.Hash) (*Snapshot, error) {
+ header := api.chain.GetHeaderByHash(hash)
+ if header == nil {
+ return nil, errUnknownBlock
+ }
+ return api.clique.snapshot(api.chain, header.Number.Uint64(), header.Hash(), nil)
+}
+
// GetSigners retrieves the list of authorized signers at the specified block.
func (api *API) GetSigners(number *rpc.BlockNumber) ([]common.Address, error) {
// Retrieve the requested block number (or current if none requested)
@@ -66,6 +75,19 @@ func (api *API) GetSigners(number *rpc.BlockNumber) ([]common.Address, error) {
return snap.signers(), nil
}
+// GetSignersAtHash retrieves the state snapshot at a given block.
+func (api *API) GetSignersAtHash(hash common.Hash) ([]common.Address, error) {
+ header := api.chain.GetHeaderByHash(hash)
+ if header == nil {
+ return nil, errUnknownBlock
+ }
+ snap, err := api.clique.snapshot(api.chain, header.Number.Uint64(), header.Hash(), nil)
+ if err != nil {
+ return nil, err
+ }
+ return snap.signers(), nil
+}
+
// Proposals returns the current proposals the node tries to uphold and vote on.
func (api *API) Proposals() map[common.Address]bool {
api.clique.lock.RLock()