-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add Subscription RPC for Grandpa Finality #5732
Changes from 1 commit
2f5367f
9d369ac
0095b78
7719292
8c35b1e
07ef5fa
c9aa9e2
78250b7
fe31500
ba13ee6
fe360b9
254bebe
9c996ea
8090161
1150e5d
130a871
f42b6c3
d61d7ec
56e716b
c0c6508
1bc9103
30e3831
8b0850a
cf07f2f
ab64ecb
b1c04ba
ebad4d7
caaaa61
f3cc272
3c4505a
9a225ac
a85dd53
1b0344f
12dd5df
bca6a13
efaa0d1
9632988
964f1e3
82004cb
e526f95
6c71b8f
8bfb560
be7cb78
ac81cdf
3f8630d
3b387e6
bf4b19a
4c96b73
12158a2
e2584e5
dc3c888
410af1f
fb3ad63
5d80399
3f33fd2
57f1963
90ae56e
be1df4f
d4cddf3
8bd9e5c
127c19e
f43ee9b
39640c1
f3c6c54
44ba73e
01f7d73
3f3b136
908cf15
bb9ad4b
410ddea
ca126fd
452024f
8b0cf76
7ddffef
817b425
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,9 @@ | |||||
| // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||||||
|
|
||||||
| use serde::{Serialize, Deserialize}; | ||||||
| use parity_scale_codec::Encode; | ||||||
| use sp_runtime::traits::Block as BlockT; | ||||||
| use sc_finality_grandpa::GrandpaJustification; | ||||||
|
|
||||||
| /// Justification for a finalized block. | ||||||
| #[derive(Clone, Serialize, Deserialize)] | ||||||
|
|
@@ -28,11 +30,11 @@ pub struct JustificationNotification<Block: BlockT> { | |||||
| pub justification: Vec<u8>, | ||||||
|
||||||
| } | ||||||
|
|
||||||
| impl<Block: BlockT> From<(Block::Header, Vec<u8>)> for JustificationNotification<Block> { | ||||||
| fn from(notification: (Block::Header, Vec<u8>)) -> Self { | ||||||
| impl<Block: BlockT> From<(Block::Header, GrandpaJustification<Block>)> for JustificationNotification<Block> { | ||||||
| fn from(notification: (Block::Header, GrandpaJustification<Block>)) -> Self { | ||||||
| JustificationNotification { | ||||||
| header: notification.0, | ||||||
| justification: notification.1, | ||||||
| justification: notification.1.encode(), | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
||||||
| } | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1148,7 +1148,7 @@ pub(crate) fn finalize_block<BE, Block, Client>( | |
| // justifications for transition blocks which will be requested by | ||
| // syncing clients. | ||
| let justification = match justification_or_commit { | ||
| JustificationOrCommit::Justification(justification) => Some(justification.encode()), | ||
| JustificationOrCommit::Justification(justification) => Some(justification), | ||
| JustificationOrCommit::Commit((round_number, commit)) => { | ||
| let mut justification_required = | ||
| // justification is always required when block that enacts new authorities | ||
|
|
@@ -1175,17 +1175,18 @@ pub(crate) fn finalize_block<BE, Block, Client>( | |
| commit, | ||
| )?; | ||
|
|
||
| Some(justification.encode()) | ||
| Some(justification) | ||
| } else { | ||
| None | ||
| } | ||
| }, | ||
| }; | ||
|
|
||
| if let Some(justification) = justification.clone() { | ||
| // Notify any registered listeners in case we have a justification | ||
| if let Some(ref justification) = justification { | ||
| match client.header(BlockId::Hash(hash)) { | ||
| Ok(Some(header)) => { | ||
| let notification = (header, justification); | ||
| let notification = (header, justification.clone()); | ||
| if let Some(sender) = justification_sender { | ||
|
||
| let _ = sender.notify(notification); | ||
|
||
| } | ||
|
|
@@ -1195,6 +1196,8 @@ pub(crate) fn finalize_block<BE, Block, Client>( | |
| }; | ||
| } | ||
|
|
||
| let justification = justification.map(|j| j.encode()); | ||
|
|
||
| debug!(target: "afg", "Finalizing blocks up to ({:?}, {})", number, hash); | ||
|
|
||
| // ideally some handle to a synchronization oracle would be used | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused?