mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 21:45:41 +00:00
chain_head: Rename runtimeUpdates flag to withRuntime (#14244)
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
@@ -34,7 +34,7 @@ pub trait ChainHeadApi<Hash> {
|
|||||||
unsubscribe = "chainHead_unstable_unfollow",
|
unsubscribe = "chainHead_unstable_unfollow",
|
||||||
item = FollowEvent<Hash>,
|
item = FollowEvent<Hash>,
|
||||||
)]
|
)]
|
||||||
fn chain_head_unstable_follow(&self, runtime_updates: bool);
|
fn chain_head_unstable_follow(&self, with_runtime: bool);
|
||||||
|
|
||||||
/// Retrieves the body (list of transactions) of a pinned block.
|
/// Retrieves the body (list of transactions) of a pinned block.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ where
|
|||||||
fn chain_head_unstable_follow(
|
fn chain_head_unstable_follow(
|
||||||
&self,
|
&self,
|
||||||
mut sink: SubscriptionSink,
|
mut sink: SubscriptionSink,
|
||||||
runtime_updates: bool,
|
with_runtime: bool,
|
||||||
) -> SubscriptionResult {
|
) -> SubscriptionResult {
|
||||||
let sub_id = match self.accept_subscription(&mut sink) {
|
let sub_id = match self.accept_subscription(&mut sink) {
|
||||||
Ok(sub_id) => sub_id,
|
Ok(sub_id) => sub_id,
|
||||||
@@ -162,7 +162,7 @@ where
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
// Keep track of the subscription.
|
// Keep track of the subscription.
|
||||||
let Some(rx_stop) = self.subscriptions.insert_subscription(sub_id.clone(), runtime_updates) else {
|
let Some(rx_stop) = self.subscriptions.insert_subscription(sub_id.clone(), with_runtime) else {
|
||||||
// Inserting the subscription can only fail if the JsonRPSee
|
// Inserting the subscription can only fail if the JsonRPSee
|
||||||
// generated a duplicate subscription ID.
|
// generated a duplicate subscription ID.
|
||||||
debug!(target: LOG_TARGET, "[follow][id={:?}] Subscription already accepted", sub_id);
|
debug!(target: LOG_TARGET, "[follow][id={:?}] Subscription already accepted", sub_id);
|
||||||
@@ -179,7 +179,7 @@ where
|
|||||||
client,
|
client,
|
||||||
backend,
|
backend,
|
||||||
subscriptions.clone(),
|
subscriptions.clone(),
|
||||||
runtime_updates,
|
with_runtime,
|
||||||
sub_id.clone(),
|
sub_id.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -410,8 +410,8 @@ where
|
|||||||
};
|
};
|
||||||
|
|
||||||
let fut = async move {
|
let fut = async move {
|
||||||
// Reject subscription if runtime_updates is false.
|
// Reject subscription if with_runtime is false.
|
||||||
if !block_guard.has_runtime_updates() {
|
if !block_guard.has_runtime() {
|
||||||
let _ = sink.reject(ChainHeadRpcError::InvalidParam(
|
let _ = sink.reject(ChainHeadRpcError::InvalidParam(
|
||||||
"The runtime updates flag must be set".into(),
|
"The runtime updates flag must be set".into(),
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ pub struct ChainHeadFollower<BE: Backend<Block>, Block: BlockT, Client> {
|
|||||||
/// Subscriptions handle.
|
/// Subscriptions handle.
|
||||||
sub_handle: Arc<SubscriptionManagement<Block, BE>>,
|
sub_handle: Arc<SubscriptionManagement<Block, BE>>,
|
||||||
/// Subscription was started with the runtime updates flag.
|
/// Subscription was started with the runtime updates flag.
|
||||||
runtime_updates: bool,
|
with_runtime: bool,
|
||||||
/// Subscription ID.
|
/// Subscription ID.
|
||||||
sub_id: String,
|
sub_id: String,
|
||||||
/// The best reported block by this subscription.
|
/// The best reported block by this subscription.
|
||||||
@@ -65,10 +65,10 @@ impl<BE: Backend<Block>, Block: BlockT, Client> ChainHeadFollower<BE, Block, Cli
|
|||||||
client: Arc<Client>,
|
client: Arc<Client>,
|
||||||
backend: Arc<BE>,
|
backend: Arc<BE>,
|
||||||
sub_handle: Arc<SubscriptionManagement<Block, BE>>,
|
sub_handle: Arc<SubscriptionManagement<Block, BE>>,
|
||||||
runtime_updates: bool,
|
with_runtime: bool,
|
||||||
sub_id: String,
|
sub_id: String,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { client, backend, sub_handle, runtime_updates, sub_id, best_block_cache: None }
|
Self { client, backend, sub_handle, with_runtime, sub_id, best_block_cache: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ where
|
|||||||
parent: Option<Block::Hash>,
|
parent: Option<Block::Hash>,
|
||||||
) -> Option<RuntimeEvent> {
|
) -> Option<RuntimeEvent> {
|
||||||
// No runtime versions should be reported.
|
// No runtime versions should be reported.
|
||||||
if !self.runtime_updates {
|
if !self.with_runtime {
|
||||||
return None
|
return None
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ where
|
|||||||
let initialized_event = FollowEvent::Initialized(Initialized {
|
let initialized_event = FollowEvent::Initialized(Initialized {
|
||||||
finalized_block_hash,
|
finalized_block_hash,
|
||||||
finalized_block_runtime,
|
finalized_block_runtime,
|
||||||
runtime_updates: self.runtime_updates,
|
with_runtime: self.with_runtime,
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut finalized_block_descendants = Vec::with_capacity(initial_blocks.len() + 1);
|
let mut finalized_block_descendants = Vec::with_capacity(initial_blocks.len() + 1);
|
||||||
@@ -243,7 +243,7 @@ where
|
|||||||
block_hash: child,
|
block_hash: child,
|
||||||
parent_block_hash: parent,
|
parent_block_hash: parent,
|
||||||
new_runtime,
|
new_runtime,
|
||||||
runtime_updates: self.runtime_updates,
|
with_runtime: self.with_runtime,
|
||||||
});
|
});
|
||||||
|
|
||||||
finalized_block_descendants.push(event);
|
finalized_block_descendants.push(event);
|
||||||
@@ -274,7 +274,7 @@ where
|
|||||||
block_hash,
|
block_hash,
|
||||||
parent_block_hash,
|
parent_block_hash,
|
||||||
new_runtime,
|
new_runtime,
|
||||||
runtime_updates: self.runtime_updates,
|
with_runtime: self.with_runtime,
|
||||||
});
|
});
|
||||||
|
|
||||||
if !is_best_block {
|
if !is_best_block {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ pub struct RuntimeVersionEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The runtime event generated if the `follow` subscription
|
/// The runtime event generated if the `follow` subscription
|
||||||
/// has set the `runtime_updates` flag.
|
/// has set the `with_runtime` flag.
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
@@ -88,7 +88,7 @@ impl From<ApiError> for RuntimeEvent {
|
|||||||
/// This is the first event generated by the `follow` subscription
|
/// This is the first event generated by the `follow` subscription
|
||||||
/// and is submitted only once.
|
/// and is submitted only once.
|
||||||
///
|
///
|
||||||
/// If the `runtime_updates` flag is set, then this event contains
|
/// If the `with_runtime` flag is set, then this event contains
|
||||||
/// the `RuntimeEvent`, otherwise the `RuntimeEvent` is not present.
|
/// the `RuntimeEvent`, otherwise the `RuntimeEvent` is not present.
|
||||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
@@ -99,23 +99,23 @@ pub struct Initialized<Hash> {
|
|||||||
///
|
///
|
||||||
/// # Note
|
/// # Note
|
||||||
///
|
///
|
||||||
/// This is present only if the `runtime_updates` flag is set for
|
/// This is present only if the `with_runtime` flag is set for
|
||||||
/// the `follow` subscription.
|
/// the `follow` subscription.
|
||||||
pub finalized_block_runtime: Option<RuntimeEvent>,
|
pub finalized_block_runtime: Option<RuntimeEvent>,
|
||||||
/// Privately keep track if the `finalized_block_runtime` should be
|
/// Privately keep track if the `finalized_block_runtime` should be
|
||||||
/// serialized.
|
/// serialized.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub(crate) runtime_updates: bool,
|
pub(crate) with_runtime: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Hash: Serialize> Serialize for Initialized<Hash> {
|
impl<Hash: Serialize> Serialize for Initialized<Hash> {
|
||||||
/// Custom serialize implementation to include the `RuntimeEvent` depending
|
/// Custom serialize implementation to include the `RuntimeEvent` depending
|
||||||
/// on the internal `runtime_updates` flag.
|
/// on the internal `with_runtime` flag.
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
{
|
{
|
||||||
if self.runtime_updates {
|
if self.with_runtime {
|
||||||
let mut state = serializer.serialize_struct("Initialized", 2)?;
|
let mut state = serializer.serialize_struct("Initialized", 2)?;
|
||||||
state.serialize_field("finalizedBlockHash", &self.finalized_block_hash)?;
|
state.serialize_field("finalizedBlockHash", &self.finalized_block_hash)?;
|
||||||
state.serialize_field("finalizedBlockRuntime", &self.finalized_block_runtime)?;
|
state.serialize_field("finalizedBlockRuntime", &self.finalized_block_runtime)?;
|
||||||
@@ -140,23 +140,23 @@ pub struct NewBlock<Hash> {
|
|||||||
///
|
///
|
||||||
/// # Note
|
/// # Note
|
||||||
///
|
///
|
||||||
/// This is present only if the `runtime_updates` flag is set for
|
/// This is present only if the `with_runtime` flag is set for
|
||||||
/// the `follow` subscription.
|
/// the `follow` subscription.
|
||||||
pub new_runtime: Option<RuntimeEvent>,
|
pub new_runtime: Option<RuntimeEvent>,
|
||||||
/// Privately keep track if the `finalized_block_runtime` should be
|
/// Privately keep track if the `finalized_block_runtime` should be
|
||||||
/// serialized.
|
/// serialized.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub(crate) runtime_updates: bool,
|
pub(crate) with_runtime: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Hash: Serialize> Serialize for NewBlock<Hash> {
|
impl<Hash: Serialize> Serialize for NewBlock<Hash> {
|
||||||
/// Custom serialize implementation to include the `RuntimeEvent` depending
|
/// Custom serialize implementation to include the `RuntimeEvent` depending
|
||||||
/// on the internal `runtime_updates` flag.
|
/// on the internal `with_runtime` flag.
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
{
|
{
|
||||||
if self.runtime_updates {
|
if self.with_runtime {
|
||||||
let mut state = serializer.serialize_struct("NewBlock", 3)?;
|
let mut state = serializer.serialize_struct("NewBlock", 3)?;
|
||||||
state.serialize_field("blockHash", &self.block_hash)?;
|
state.serialize_field("blockHash", &self.block_hash)?;
|
||||||
state.serialize_field("parentBlockHash", &self.parent_block_hash)?;
|
state.serialize_field("parentBlockHash", &self.parent_block_hash)?;
|
||||||
@@ -253,7 +253,7 @@ mod tests {
|
|||||||
let event: FollowEvent<String> = FollowEvent::Initialized(Initialized {
|
let event: FollowEvent<String> = FollowEvent::Initialized(Initialized {
|
||||||
finalized_block_hash: "0x1".into(),
|
finalized_block_hash: "0x1".into(),
|
||||||
finalized_block_runtime: None,
|
finalized_block_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
let ser = serde_json::to_string(&event).unwrap();
|
let ser = serde_json::to_string(&event).unwrap();
|
||||||
@@ -278,7 +278,7 @@ mod tests {
|
|||||||
let mut initialized = Initialized {
|
let mut initialized = Initialized {
|
||||||
finalized_block_hash: "0x1".into(),
|
finalized_block_hash: "0x1".into(),
|
||||||
finalized_block_runtime: Some(runtime_event),
|
finalized_block_runtime: Some(runtime_event),
|
||||||
runtime_updates: true,
|
with_runtime: true,
|
||||||
};
|
};
|
||||||
let event: FollowEvent<String> = FollowEvent::Initialized(initialized.clone());
|
let event: FollowEvent<String> = FollowEvent::Initialized(initialized.clone());
|
||||||
|
|
||||||
@@ -291,8 +291,8 @@ mod tests {
|
|||||||
assert_eq!(ser, exp);
|
assert_eq!(ser, exp);
|
||||||
|
|
||||||
let event_dec: FollowEvent<String> = serde_json::from_str(exp).unwrap();
|
let event_dec: FollowEvent<String> = serde_json::from_str(exp).unwrap();
|
||||||
// The `runtime_updates` field is used for serialization purposes.
|
// The `with_runtime` field is used for serialization purposes.
|
||||||
initialized.runtime_updates = false;
|
initialized.with_runtime = false;
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
event_dec, FollowEvent::Initialized(ref dec) if dec == &initialized
|
event_dec, FollowEvent::Initialized(ref dec) if dec == &initialized
|
||||||
));
|
));
|
||||||
@@ -305,7 +305,7 @@ mod tests {
|
|||||||
block_hash: "0x1".into(),
|
block_hash: "0x1".into(),
|
||||||
parent_block_hash: "0x2".into(),
|
parent_block_hash: "0x2".into(),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
let ser = serde_json::to_string(&event).unwrap();
|
let ser = serde_json::to_string(&event).unwrap();
|
||||||
@@ -331,7 +331,7 @@ mod tests {
|
|||||||
block_hash: "0x1".into(),
|
block_hash: "0x1".into(),
|
||||||
parent_block_hash: "0x2".into(),
|
parent_block_hash: "0x2".into(),
|
||||||
new_runtime: Some(runtime_event),
|
new_runtime: Some(runtime_event),
|
||||||
runtime_updates: true,
|
with_runtime: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
let event: FollowEvent<String> = FollowEvent::NewBlock(new_block.clone());
|
let event: FollowEvent<String> = FollowEvent::NewBlock(new_block.clone());
|
||||||
@@ -345,8 +345,8 @@ mod tests {
|
|||||||
assert_eq!(ser, exp);
|
assert_eq!(ser, exp);
|
||||||
|
|
||||||
let event_dec: FollowEvent<String> = serde_json::from_str(exp).unwrap();
|
let event_dec: FollowEvent<String> = serde_json::from_str(exp).unwrap();
|
||||||
// The `runtime_updates` field is used for serialization purposes.
|
// The `with_runtime` field is used for serialization purposes.
|
||||||
new_block.runtime_updates = false;
|
new_block.with_runtime = false;
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
event_dec, FollowEvent::NewBlock(ref dec) if dec == &new_block
|
event_dec, FollowEvent::NewBlock(ref dec) if dec == &new_block
|
||||||
));
|
));
|
||||||
@@ -356,7 +356,7 @@ mod tests {
|
|||||||
block_hash: "0x1".into(),
|
block_hash: "0x1".into(),
|
||||||
parent_block_hash: "0x2".into(),
|
parent_block_hash: "0x2".into(),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: true,
|
with_runtime: true,
|
||||||
};
|
};
|
||||||
let event: FollowEvent<String> = FollowEvent::NewBlock(new_block.clone());
|
let event: FollowEvent<String> = FollowEvent::NewBlock(new_block.clone());
|
||||||
|
|
||||||
@@ -364,7 +364,7 @@ mod tests {
|
|||||||
let exp =
|
let exp =
|
||||||
r#"{"event":"newBlock","blockHash":"0x1","parentBlockHash":"0x2","newRuntime":null}"#;
|
r#"{"event":"newBlock","blockHash":"0x1","parentBlockHash":"0x2","newRuntime":null}"#;
|
||||||
assert_eq!(ser, exp);
|
assert_eq!(ser, exp);
|
||||||
new_block.runtime_updates = false;
|
new_block.with_runtime = false;
|
||||||
let event_dec: FollowEvent<String> = serde_json::from_str(exp).unwrap();
|
let event_dec: FollowEvent<String> = serde_json::from_str(exp).unwrap();
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
event_dec, FollowEvent::NewBlock(ref dec) if dec == &new_block
|
event_dec, FollowEvent::NewBlock(ref dec) if dec == &new_block
|
||||||
|
|||||||
@@ -112,8 +112,8 @@ struct BlockState {
|
|||||||
|
|
||||||
/// The state of a single subscription ID.
|
/// The state of a single subscription ID.
|
||||||
struct SubscriptionState<Block: BlockT> {
|
struct SubscriptionState<Block: BlockT> {
|
||||||
/// The `runtime_updates` parameter flag of the subscription.
|
/// The `with_runtime` parameter flag of the subscription.
|
||||||
runtime_updates: bool,
|
with_runtime: bool,
|
||||||
/// Signals the "Stop" event.
|
/// Signals the "Stop" event.
|
||||||
tx_stop: Option<oneshot::Sender<()>>,
|
tx_stop: Option<oneshot::Sender<()>>,
|
||||||
/// Track the block hashes available for this subscription.
|
/// Track the block hashes available for this subscription.
|
||||||
@@ -234,7 +234,7 @@ impl<Block: BlockT> SubscriptionState<Block> {
|
|||||||
/// executing an RPC method call.
|
/// executing an RPC method call.
|
||||||
pub struct BlockGuard<Block: BlockT, BE: Backend<Block>> {
|
pub struct BlockGuard<Block: BlockT, BE: Backend<Block>> {
|
||||||
hash: Block::Hash,
|
hash: Block::Hash,
|
||||||
runtime_updates: bool,
|
with_runtime: bool,
|
||||||
backend: Arc<BE>,
|
backend: Arc<BE>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ pub struct BlockGuard<Block: BlockT, BE: Backend<Block>> {
|
|||||||
// testing.
|
// testing.
|
||||||
impl<Block: BlockT, BE: Backend<Block>> std::fmt::Debug for BlockGuard<Block, BE> {
|
impl<Block: BlockT, BE: Backend<Block>> std::fmt::Debug for BlockGuard<Block, BE> {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "BlockGuard hash {:?} runtime_updates {:?}", self.hash, self.runtime_updates)
|
write!(f, "BlockGuard hash {:?} with_runtime {:?}", self.hash, self.with_runtime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,19 +250,19 @@ impl<Block: BlockT, BE: Backend<Block>> BlockGuard<Block, BE> {
|
|||||||
/// Construct a new [`BlockGuard`] .
|
/// Construct a new [`BlockGuard`] .
|
||||||
fn new(
|
fn new(
|
||||||
hash: Block::Hash,
|
hash: Block::Hash,
|
||||||
runtime_updates: bool,
|
with_runtime: bool,
|
||||||
backend: Arc<BE>,
|
backend: Arc<BE>,
|
||||||
) -> Result<Self, SubscriptionManagementError> {
|
) -> Result<Self, SubscriptionManagementError> {
|
||||||
backend
|
backend
|
||||||
.pin_block(hash)
|
.pin_block(hash)
|
||||||
.map_err(|err| SubscriptionManagementError::Custom(err.to_string()))?;
|
.map_err(|err| SubscriptionManagementError::Custom(err.to_string()))?;
|
||||||
|
|
||||||
Ok(Self { hash, runtime_updates, backend })
|
Ok(Self { hash, with_runtime, backend })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The `runtime_updates` flag of the subscription.
|
/// The `with_runtime` flag of the subscription.
|
||||||
pub fn has_runtime_updates(&self) -> bool {
|
pub fn has_runtime(&self) -> bool {
|
||||||
self.runtime_updates
|
self.with_runtime
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,12 +310,12 @@ impl<Block: BlockT, BE: Backend<Block>> SubscriptionsInner<Block, BE> {
|
|||||||
pub fn insert_subscription(
|
pub fn insert_subscription(
|
||||||
&mut self,
|
&mut self,
|
||||||
sub_id: String,
|
sub_id: String,
|
||||||
runtime_updates: bool,
|
with_runtime: bool,
|
||||||
) -> Option<oneshot::Receiver<()>> {
|
) -> Option<oneshot::Receiver<()>> {
|
||||||
if let Entry::Vacant(entry) = self.subs.entry(sub_id) {
|
if let Entry::Vacant(entry) = self.subs.entry(sub_id) {
|
||||||
let (tx_stop, rx_stop) = oneshot::channel();
|
let (tx_stop, rx_stop) = oneshot::channel();
|
||||||
let state = SubscriptionState::<Block> {
|
let state = SubscriptionState::<Block> {
|
||||||
runtime_updates,
|
with_runtime,
|
||||||
tx_stop: Some(tx_stop),
|
tx_stop: Some(tx_stop),
|
||||||
blocks: Default::default(),
|
blocks: Default::default(),
|
||||||
};
|
};
|
||||||
@@ -501,7 +501,7 @@ impl<Block: BlockT, BE: Backend<Block>> SubscriptionsInner<Block, BE> {
|
|||||||
return Err(SubscriptionManagementError::BlockHashAbsent)
|
return Err(SubscriptionManagementError::BlockHashAbsent)
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockGuard::new(hash, sub.runtime_updates, self.backend.clone())
|
BlockGuard::new(hash, sub.with_runtime, self.backend.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -608,7 +608,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn sub_state_register_twice() {
|
fn sub_state_register_twice() {
|
||||||
let mut sub_state = SubscriptionState::<Block> {
|
let mut sub_state = SubscriptionState::<Block> {
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
tx_stop: None,
|
tx_stop: None,
|
||||||
blocks: Default::default(),
|
blocks: Default::default(),
|
||||||
};
|
};
|
||||||
@@ -633,7 +633,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn sub_state_register_unregister() {
|
fn sub_state_register_unregister() {
|
||||||
let mut sub_state = SubscriptionState::<Block> {
|
let mut sub_state = SubscriptionState::<Block> {
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
tx_stop: None,
|
tx_stop: None,
|
||||||
blocks: Default::default(),
|
blocks: Default::default(),
|
||||||
};
|
};
|
||||||
@@ -709,7 +709,7 @@ mod tests {
|
|||||||
|
|
||||||
let block = subs.lock_block(&id, hash).unwrap();
|
let block = subs.lock_block(&id, hash).unwrap();
|
||||||
// Subscription started with runtime updates
|
// Subscription started with runtime updates
|
||||||
assert_eq!(block.has_runtime_updates(), true);
|
assert_eq!(block.has_runtime(), true);
|
||||||
|
|
||||||
let invalid_id = "abc-invalid".to_string();
|
let invalid_id = "abc-invalid".to_string();
|
||||||
let err = subs.unpin_block(&invalid_id, hash).unwrap_err();
|
let err = subs.unpin_block(&invalid_id, hash).unwrap_err();
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ async fn follow_subscription_produces_blocks() {
|
|||||||
let expected = FollowEvent::Initialized(Initialized {
|
let expected = FollowEvent::Initialized(Initialized {
|
||||||
finalized_block_hash: format!("{:?}", finalized_hash),
|
finalized_block_hash: format!("{:?}", finalized_hash),
|
||||||
finalized_block_runtime: None,
|
finalized_block_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ async fn follow_subscription_produces_blocks() {
|
|||||||
block_hash: format!("{:?}", best_hash),
|
block_hash: format!("{:?}", best_hash),
|
||||||
parent_block_hash: format!("{:?}", finalized_hash),
|
parent_block_hash: format!("{:?}", finalized_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ async fn follow_with_runtime() {
|
|||||||
let expected = FollowEvent::Initialized(Initialized {
|
let expected = FollowEvent::Initialized(Initialized {
|
||||||
finalized_block_hash: format!("{:?}", finalized_hash),
|
finalized_block_hash: format!("{:?}", finalized_hash),
|
||||||
finalized_block_runtime,
|
finalized_block_runtime,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ async fn follow_with_runtime() {
|
|||||||
block_hash: format!("{:?}", best_hash),
|
block_hash: format!("{:?}", best_hash),
|
||||||
parent_block_hash: format!("{:?}", finalized_hash),
|
parent_block_hash: format!("{:?}", finalized_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -264,7 +264,7 @@ async fn follow_with_runtime() {
|
|||||||
block_hash: format!("{:?}", best_hash),
|
block_hash: format!("{:?}", best_hash),
|
||||||
parent_block_hash: format!("{:?}", finalized_hash),
|
parent_block_hash: format!("{:?}", finalized_hash),
|
||||||
new_runtime,
|
new_runtime,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
}
|
}
|
||||||
@@ -492,7 +492,7 @@ async fn call_runtime_without_flag() {
|
|||||||
FollowEvent::BestBlockChanged(_)
|
FollowEvent::BestBlockChanged(_)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Valid runtime call on a subscription started with `runtime_updates` false.
|
// Valid runtime call on a subscription started with `with_runtime` false.
|
||||||
let alice_id = AccountKeyring::Alice.to_account_id();
|
let alice_id = AccountKeyring::Alice.to_account_id();
|
||||||
let call_parameters = format!("0x{:?}", HexDisplay::from(&alice_id.encode()));
|
let call_parameters = format!("0x{:?}", HexDisplay::from(&alice_id.encode()));
|
||||||
let err = api
|
let err = api
|
||||||
@@ -681,7 +681,7 @@ async fn follow_generates_initial_blocks() {
|
|||||||
let expected = FollowEvent::Initialized(Initialized {
|
let expected = FollowEvent::Initialized(Initialized {
|
||||||
finalized_block_hash: format!("{:?}", finalized_hash),
|
finalized_block_hash: format!("{:?}", finalized_hash),
|
||||||
finalized_block_runtime: None,
|
finalized_block_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -691,7 +691,7 @@ async fn follow_generates_initial_blocks() {
|
|||||||
block_hash: format!("{:?}", block_1_hash),
|
block_hash: format!("{:?}", block_1_hash),
|
||||||
parent_block_hash: format!("{:?}", finalized_hash),
|
parent_block_hash: format!("{:?}", finalized_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -701,7 +701,7 @@ async fn follow_generates_initial_blocks() {
|
|||||||
block_hash: format!("{:?}", block_2_hash),
|
block_hash: format!("{:?}", block_2_hash),
|
||||||
parent_block_hash: format!("{:?}", block_1_hash),
|
parent_block_hash: format!("{:?}", block_1_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
// Check block 3.
|
// Check block 3.
|
||||||
@@ -710,7 +710,7 @@ async fn follow_generates_initial_blocks() {
|
|||||||
block_hash: format!("{:?}", block_3_hash),
|
block_hash: format!("{:?}", block_3_hash),
|
||||||
parent_block_hash: format!("{:?}", block_1_hash),
|
parent_block_hash: format!("{:?}", block_1_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -730,7 +730,7 @@ async fn follow_generates_initial_blocks() {
|
|||||||
block_hash: format!("{:?}", block_4_hash),
|
block_hash: format!("{:?}", block_4_hash),
|
||||||
parent_block_hash: format!("{:?}", block_2_hash),
|
parent_block_hash: format!("{:?}", block_2_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -913,7 +913,7 @@ async fn follow_prune_best_block() {
|
|||||||
let expected = FollowEvent::Initialized(Initialized {
|
let expected = FollowEvent::Initialized(Initialized {
|
||||||
finalized_block_hash: format!("{:?}", finalized_hash),
|
finalized_block_hash: format!("{:?}", finalized_hash),
|
||||||
finalized_block_runtime: None,
|
finalized_block_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -963,7 +963,7 @@ async fn follow_prune_best_block() {
|
|||||||
block_hash: format!("{:?}", block_1_hash),
|
block_hash: format!("{:?}", block_1_hash),
|
||||||
parent_block_hash: format!("{:?}", finalized_hash),
|
parent_block_hash: format!("{:?}", finalized_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
let event: FollowEvent<String> = get_next_event(&mut sub).await;
|
let event: FollowEvent<String> = get_next_event(&mut sub).await;
|
||||||
@@ -978,7 +978,7 @@ async fn follow_prune_best_block() {
|
|||||||
block_hash: format!("{:?}", block_3_hash),
|
block_hash: format!("{:?}", block_3_hash),
|
||||||
parent_block_hash: format!("{:?}", block_1_hash),
|
parent_block_hash: format!("{:?}", block_1_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
let event: FollowEvent<String> = get_next_event(&mut sub).await;
|
let event: FollowEvent<String> = get_next_event(&mut sub).await;
|
||||||
@@ -993,7 +993,7 @@ async fn follow_prune_best_block() {
|
|||||||
block_hash: format!("{:?}", block_4_hash),
|
block_hash: format!("{:?}", block_4_hash),
|
||||||
parent_block_hash: format!("{:?}", block_3_hash),
|
parent_block_hash: format!("{:?}", block_3_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
let event: FollowEvent<String> = get_next_event(&mut sub).await;
|
let event: FollowEvent<String> = get_next_event(&mut sub).await;
|
||||||
@@ -1008,7 +1008,7 @@ async fn follow_prune_best_block() {
|
|||||||
block_hash: format!("{:?}", block_2_hash),
|
block_hash: format!("{:?}", block_2_hash),
|
||||||
parent_block_hash: format!("{:?}", block_1_hash),
|
parent_block_hash: format!("{:?}", block_1_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
let event: FollowEvent<String> = get_next_event(&mut sub).await;
|
let event: FollowEvent<String> = get_next_event(&mut sub).await;
|
||||||
@@ -1118,7 +1118,7 @@ async fn follow_forks_pruned_block() {
|
|||||||
let expected = FollowEvent::Initialized(Initialized {
|
let expected = FollowEvent::Initialized(Initialized {
|
||||||
finalized_block_hash: format!("{:?}", block_3_hash),
|
finalized_block_hash: format!("{:?}", block_3_hash),
|
||||||
finalized_block_runtime: None,
|
finalized_block_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -1142,7 +1142,7 @@ async fn follow_forks_pruned_block() {
|
|||||||
block_hash: format!("{:?}", block_6_hash),
|
block_hash: format!("{:?}", block_6_hash),
|
||||||
parent_block_hash: format!("{:?}", block_3_hash),
|
parent_block_hash: format!("{:?}", block_3_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
let event: FollowEvent<String> = get_next_event(&mut sub).await;
|
let event: FollowEvent<String> = get_next_event(&mut sub).await;
|
||||||
@@ -1233,7 +1233,7 @@ async fn follow_report_multiple_pruned_block() {
|
|||||||
let expected = FollowEvent::Initialized(Initialized {
|
let expected = FollowEvent::Initialized(Initialized {
|
||||||
finalized_block_hash: format!("{:?}", finalized_hash),
|
finalized_block_hash: format!("{:?}", finalized_hash),
|
||||||
finalized_block_runtime: None,
|
finalized_block_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -1242,7 +1242,7 @@ async fn follow_report_multiple_pruned_block() {
|
|||||||
block_hash: format!("{:?}", block_1_hash),
|
block_hash: format!("{:?}", block_1_hash),
|
||||||
parent_block_hash: format!("{:?}", finalized_hash),
|
parent_block_hash: format!("{:?}", finalized_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -1251,7 +1251,7 @@ async fn follow_report_multiple_pruned_block() {
|
|||||||
block_hash: format!("{:?}", block_2_hash),
|
block_hash: format!("{:?}", block_2_hash),
|
||||||
parent_block_hash: format!("{:?}", block_1_hash),
|
parent_block_hash: format!("{:?}", block_1_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -1260,7 +1260,7 @@ async fn follow_report_multiple_pruned_block() {
|
|||||||
block_hash: format!("{:?}", block_3_hash),
|
block_hash: format!("{:?}", block_3_hash),
|
||||||
parent_block_hash: format!("{:?}", block_2_hash),
|
parent_block_hash: format!("{:?}", block_2_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -1270,7 +1270,7 @@ async fn follow_report_multiple_pruned_block() {
|
|||||||
block_hash: format!("{:?}", block_4_hash),
|
block_hash: format!("{:?}", block_4_hash),
|
||||||
parent_block_hash: format!("{:?}", block_1_hash),
|
parent_block_hash: format!("{:?}", block_1_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -1279,7 +1279,7 @@ async fn follow_report_multiple_pruned_block() {
|
|||||||
block_hash: format!("{:?}", block_5_hash),
|
block_hash: format!("{:?}", block_5_hash),
|
||||||
parent_block_hash: format!("{:?}", block_4_hash),
|
parent_block_hash: format!("{:?}", block_4_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -1325,7 +1325,7 @@ async fn follow_report_multiple_pruned_block() {
|
|||||||
block_hash: format!("{:?}", block_6_hash),
|
block_hash: format!("{:?}", block_6_hash),
|
||||||
parent_block_hash: format!("{:?}", block_3_hash),
|
parent_block_hash: format!("{:?}", block_3_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
let event: FollowEvent<String> = get_next_event(&mut sub).await;
|
let event: FollowEvent<String> = get_next_event(&mut sub).await;
|
||||||
@@ -1511,7 +1511,7 @@ async fn follow_finalized_before_new_block() {
|
|||||||
let expected = FollowEvent::Initialized(Initialized {
|
let expected = FollowEvent::Initialized(Initialized {
|
||||||
finalized_block_hash: format!("{:?}", finalized_hash),
|
finalized_block_hash: format!("{:?}", finalized_hash),
|
||||||
finalized_block_runtime: None,
|
finalized_block_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -1521,7 +1521,7 @@ async fn follow_finalized_before_new_block() {
|
|||||||
block_hash: format!("{:?}", block_1_hash),
|
block_hash: format!("{:?}", block_1_hash),
|
||||||
parent_block_hash: format!("{:?}", finalized_hash),
|
parent_block_hash: format!("{:?}", finalized_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
@@ -1556,7 +1556,7 @@ async fn follow_finalized_before_new_block() {
|
|||||||
block_hash: format!("{:?}", block_2_hash),
|
block_hash: format!("{:?}", block_2_hash),
|
||||||
parent_block_hash: format!("{:?}", block_1_hash),
|
parent_block_hash: format!("{:?}", block_1_hash),
|
||||||
new_runtime: None,
|
new_runtime: None,
|
||||||
runtime_updates: false,
|
with_runtime: false,
|
||||||
});
|
});
|
||||||
assert_eq!(event, expected);
|
assert_eq!(event, expected);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user