good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 93e2ac27 authored by Jaynti Kanani's avatar Jaynti Kanani Committed by GitHub
Browse files

Merge pull request #88 from maticnetwork/arpit/mat-2318

mat-2318 (Create `bor.getAuthor()` api for bor module)
parents 21bbd174 0e4487db
Branches
Tags
No related merge requests found
...@@ -62,6 +62,23 @@ func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error) { ...@@ -62,6 +62,23 @@ func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error) {
return api.bor.snapshot(api.chain, header.Number.Uint64(), header.Hash(), nil) return api.bor.snapshot(api.chain, header.Number.Uint64(), header.Hash(), nil)
} }
// GetAuthor retrieves the author a block.
func (api *API) GetAuthor(number *rpc.BlockNumber) (*common.Address, error) {
// Retrieve the requested block number (or current if none requested)
var header *types.Header
if number == nil || *number == rpc.LatestBlockNumber {
header = api.chain.CurrentHeader()
} else {
header = api.chain.GetHeaderByNumber(uint64(number.Int64()))
}
// Ensure we have an actually valid block and return its snapshot
if header == nil {
return nil, errUnknownBlock
}
author, err := api.bor.Author(header)
return &author, err
}
// GetSnapshotAtHash retrieves the state snapshot at a given block. // GetSnapshotAtHash retrieves the state snapshot at a given block.
func (api *API) GetSnapshotAtHash(hash common.Hash) (*Snapshot, error) { func (api *API) GetSnapshotAtHash(hash common.Hash) (*Snapshot, error) {
header := api.chain.GetHeaderByHash(hash) header := api.chain.GetHeaderByHash(hash)
......
...@@ -129,6 +129,12 @@ web3._extend({ ...@@ -129,6 +129,12 @@ web3._extend({
params: 1, params: 1,
inputFormatter: [null] inputFormatter: [null]
}), }),
new web3._extend.Method({
name: 'getAuthor',
call: 'bor_getAuthor',
params: 1,
inputFormatter: [null]
}),
new web3._extend.Method({ new web3._extend.Method({
name: 'getSnapshotAtHash', name: 'getSnapshotAtHash',
call: 'bor_getSnapshotAtHash', call: 'bor_getSnapshotAtHash',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment