aboutsummaryrefslogtreecommitdiffstats
path: root/consensus/clique/api.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-04-12 20:37:10 +0800
committerGitHub <noreply@github.com>2017-04-12 20:37:10 +0800
commit6b7ae4e751dbaee0f31032f045fd35b0c1079388 (patch)
treee63f021ae31976fa78e2f5c76a9d1399264db942 /consensus/clique/api.go
parent050ceff1aed3d06b4ebf4aead0dc03e7cac34458 (diff)
downloaddexon-6b7ae4e751dbaee0f31032f045fd35b0c1079388.tar
dexon-6b7ae4e751dbaee0f31032f045fd35b0c1079388.tar.gz
dexon-6b7ae4e751dbaee0f31032f045fd35b0c1079388.tar.bz2
dexon-6b7ae4e751dbaee0f31032f045fd35b0c1079388.tar.lz
dexon-6b7ae4e751dbaee0f31032f045fd35b0c1079388.tar.xz
dexon-6b7ae4e751dbaee0f31032f045fd35b0c1079388.tar.zst
dexon-6b7ae4e751dbaee0f31032f045fd35b0c1079388.zip
consensus/clique, internal/web3ext: support hash based API queries (#14321)
* consensus/clique, internal/web3ext: support hash based API queries * consensus/clique: make RPC return types public
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()