mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-11 14:33:52 +00:00
Expose API methods
This commit is contained in:
parent
4037b09968
commit
04f5abcc13
2 changed files with 55 additions and 6 deletions
|
|
@ -88,12 +88,20 @@ func (api *API) GetSignersAtHash(hash common.Hash) ([]common.Address, error) {
|
||||||
return snap.signers(), nil
|
return snap.signers(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSpan gets the current span details
|
// GetCurrentProposer gets the current proposer
|
||||||
func (api *API) GetCurrentProposer() (common.Address, error) {
|
func (api *API) GetCurrentProposer() (common.Address, error) {
|
||||||
header := api.chain.CurrentHeader()
|
snap, err := api.GetSnapshot(nil)
|
||||||
snap, err := api.bor.snapshot(api.chain, header.Number.Uint64(), header.Hash(), nil)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.BytesToAddress(make([]byte, 20)), err
|
return common.Address{}, err
|
||||||
}
|
}
|
||||||
return snap.ValidatorSet.GetProposer().Address, nil
|
return snap.ValidatorSet.GetProposer().Address, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetCurrentValidators gets the current validators
|
||||||
|
func (api *API) GetCurrentValidators() ([]*Validator, error) {
|
||||||
|
snap, err := api.GetSnapshot(nil)
|
||||||
|
if err != nil {
|
||||||
|
return make([]*Validator, 0), err
|
||||||
|
}
|
||||||
|
return snap.ValidatorSet.Validators, nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ var Modules = map[string]string{
|
||||||
"admin": AdminJs,
|
"admin": AdminJs,
|
||||||
"chequebook": ChequebookJs,
|
"chequebook": ChequebookJs,
|
||||||
"clique": CliqueJs,
|
"clique": CliqueJs,
|
||||||
|
"bor": BorJs,
|
||||||
"ethash": EthashJs,
|
"ethash": EthashJs,
|
||||||
"debug": DebugJs,
|
"debug": DebugJs,
|
||||||
"eth": EthJs,
|
"eth": EthJs,
|
||||||
|
|
@ -112,6 +113,46 @@ web3._extend({
|
||||||
});
|
});
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const BorJs = `
|
||||||
|
web3._extend({
|
||||||
|
property: 'bor',
|
||||||
|
methods: [
|
||||||
|
new web3._extend.Method({
|
||||||
|
name: 'getSnapshot',
|
||||||
|
call: 'bor_getSnapshot',
|
||||||
|
params: 1,
|
||||||
|
inputFormatter: [null]
|
||||||
|
}),
|
||||||
|
new web3._extend.Method({
|
||||||
|
name: 'getSnapshotAtHash',
|
||||||
|
call: 'bor_getSnapshotAtHash',
|
||||||
|
params: 1
|
||||||
|
}),
|
||||||
|
new web3._extend.Method({
|
||||||
|
name: 'getSigners',
|
||||||
|
call: 'bor_getSigners',
|
||||||
|
params: 1,
|
||||||
|
inputFormatter: [null]
|
||||||
|
}),
|
||||||
|
new web3._extend.Method({
|
||||||
|
name: 'getSignersAtHash',
|
||||||
|
call: 'bor_getSignersAtHash',
|
||||||
|
params: 1
|
||||||
|
}),
|
||||||
|
new web3._extend.Method({
|
||||||
|
name: 'getCurrentProposer',
|
||||||
|
call: 'bor_getCurrentProposer',
|
||||||
|
params: 0
|
||||||
|
}),
|
||||||
|
new web3._extend.Method({
|
||||||
|
name: 'getCurrentValidators',
|
||||||
|
call: 'bor_getCurrentValidators',
|
||||||
|
params: 0
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
});
|
||||||
|
`
|
||||||
|
|
||||||
const EthashJs = `
|
const EthashJs = `
|
||||||
web3._extend({
|
web3._extend({
|
||||||
property: 'ethash',
|
property: 'ethash',
|
||||||
|
|
@ -765,7 +806,7 @@ web3._extend({
|
||||||
const LESJs = `
|
const LESJs = `
|
||||||
web3._extend({
|
web3._extend({
|
||||||
property: 'les',
|
property: 'les',
|
||||||
methods:
|
methods:
|
||||||
[
|
[
|
||||||
new web3._extend.Method({
|
new web3._extend.Method({
|
||||||
name: 'getCheckpoint',
|
name: 'getCheckpoint',
|
||||||
|
|
@ -773,7 +814,7 @@ web3._extend({
|
||||||
params: 1
|
params: 1
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
properties:
|
properties:
|
||||||
[
|
[
|
||||||
new web3._extend.Property({
|
new web3._extend.Property({
|
||||||
name: 'latestCheckpoint',
|
name: 'latestCheckpoint',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue