Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/web3ext, les: update clique JS and make it work with the light client #20318

Merged
merged 2 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions internal/web3ext/web3ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ web3._extend({
name: 'getSnapshot',
call: 'clique_getSnapshot',
params: 1,
inputFormatter: [null]
inputFormatter: [web3._extend.utils.fromDecimal]
}),
new web3._extend.Method({
name: 'getSnapshotAtHash',
Expand All @@ -85,7 +85,7 @@ web3._extend({
name: 'getSigners',
call: 'clique_getSigners',
params: 1,
inputFormatter: [null]
inputFormatter: [web3._extend.utils.fromDecimal]
}),
new web3._extend.Method({
name: 'getSignersAtHash',
Expand All @@ -102,6 +102,11 @@ web3._extend({
call: 'clique_discard',
params: 1
}),
new web3._extend.Method({
name: 'status',
call: 'clique_status',
params: 0
}),
],
properties: [
new web3._extend.Property({
Expand Down
4 changes: 3 additions & 1 deletion les/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ func (s *LightDummyAPI) Mining() bool {
// APIs returns the collection of RPC services the ethereum package offers.
// NOTE, some of these services probably need to be moved to somewhere else.
func (s *LightEthereum) APIs() []rpc.API {
return append(ethapi.GetAPIs(s.ApiBackend), []rpc.API{
apis := ethapi.GetAPIs(s.ApiBackend)
apis = append(apis, s.engine.APIs(s.BlockChain().HeaderChain())...)
return append(apis, []rpc.API{
{
Namespace: "eth",
Version: "1.0",
Expand Down
5 changes: 5 additions & 0 deletions light/lightchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ func (lc *LightChain) Odr() OdrBackend {
return lc.odr
}

// HeaderChain returns the underlying header chain.
func (lc *LightChain) HeaderChain() *core.HeaderChain {
Copy link
Member

Choose a reason for hiding this comment

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

I check the APIs, it seems we only use it for header retrieval. So is it possible we change the interface to ChainHeaderReader, and define another interface like ChainReader. In this way we can use LightChain directly

Copy link
Contributor Author

@fjl fjl Nov 19, 2019

Choose a reason for hiding this comment

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

Good idea, but right now I just want to get the APIs to work and didn't want to change consensus engine for that.

return lc.hc
}

// loadLastState loads the last known chain state from the database. This method
// assumes that the chain manager mutex is held.
func (lc *LightChain) loadLastState() error {
Expand Down