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

feat(dot/rpc) implement chain_subscribeAllHeads RPC #1740

Merged
merged 6 commits into from
Aug 24, 2021

Conversation

EclesioMeloJunior
Copy link
Member

@EclesioMeloJunior EclesioMeloJunior commented Aug 20, 2021

Changes

  • Implement chain_subscribeAllHeads and chain_unsubscribeAllHeads
  • Create channels and register them into BlockAPI and notify the websocket every new block or finalization

Tests

go test -run ^TestSubscribeAllHeads$ github.com/ChainSafe/gossamer/dot/rpc/subscription

Issues

Primary Reviewer

continue
}

res := newSubcriptionBaseResponseJSON()
Copy link
Contributor

Choose a reason for hiding this comment

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

can you change this constructor to just take Method and Params. Seems odd that we need to populate it ourselves.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

Comment on lines 282 to 288
listener := new(AllBlocksListener)
listener.cancel = make(chan struct{})
listener.done = make(chan struct{})
listener.cancelTimeout = defaultCancelTimeout
listener.wsconn = c
listener.finalizedChan = make(chan *types.FinalisationInfo, DEFAULT_BUFFER_SIZE)
listener.importedChan = make(chan *types.Block, DEFAULT_BUFFER_SIZE)
Copy link
Contributor

Choose a reason for hiding this comment

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

move to constructor newAllBlocksListener

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

@codecov
Copy link

codecov bot commented Aug 20, 2021

Codecov Report

Merging #1740 (dc0bb69) into development (9b80e0a) will increase coverage by 0.02%.
The diff coverage is 73.33%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #1740      +/-   ##
===============================================
+ Coverage        59.08%   59.10%   +0.02%     
===============================================
  Files              184      184              
  Lines            19336    19396      +60     
===============================================
+ Hits             11424    11464      +40     
- Misses            5931     5945      +14     
- Partials          1981     1987       +6     
Flag Coverage Δ
unit-tests 59.10% <73.33%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
dot/rpc/subscription/subscription.go 61.90% <0.00%> (-3.10%) ⬇️
dot/rpc/subscription/listeners.go 71.66% <64.10%> (-2.10%) ⬇️
dot/rpc/subscription/websocket.go 64.56% <100.00%> (+2.86%) ⬆️
lib/trie/proof.go 59.67% <0.00%> (-3.23%) ⬇️
lib/babe/babe.go 56.70% <0.00%> (-1.15%) ⬇️
dot/network/connmgr.go 82.40% <0.00%> (-0.93%) ⬇️
dot/network/sync.go 64.97% <0.00%> (-0.40%) ⬇️
lib/blocktree/blocktree.go 56.74% <0.00%> (+1.12%) ⬆️
lib/babe/epoch.go 66.66% <0.00%> (+2.15%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9b80e0a...dc0bb69. Read the comment docs.

Copy link
Contributor

@noot noot left a comment

Choose a reason for hiding this comment

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

looks good!

Co-authored-by: noot <36753753+noot@users.noreply.github.com>
@EclesioMeloJunior EclesioMeloJunior merged commit f46e6dd into development Aug 24, 2021
@EclesioMeloJunior EclesioMeloJunior deleted the eclesio/rpc-subscribe-all-heads branch August 24, 2021 20:02
@github-actions
Copy link

github-actions bot commented Dec 3, 2021

🎉 This PR is included in version 0.6.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

timwu20 pushed a commit to timwu20/gossamer that referenced this pull request Dec 6, 2021
* feat: implement chain subscribe all heads

* chore: add unit tests to subscribe all heads

* chore: fix lint

* chore: create constructor

* chore: improve AllBlocksListener export comment

Co-authored-by: noot <36753753+noot@users.noreply.github.com>

Co-authored-by: noot <36753753+noot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants