Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 94745e2

Browse files
authored
Updates for CC's recent upgrade (#1381)
* Updates for CC's recent upgrade - Version bump to 0.9.2 - Runtime version bump to v14 - Avoid misuse of error return type for system_health RPC * Fix tests
1 parent b5f7e4c commit 94745e2

File tree

7 files changed

+21
-25
lines changed

7 files changed

+21
-25
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ path = "node/src/main.rs"
44

55
[package]
66
name = "substrate"
7-
version = "0.9.1"
7+
version = "0.9.2"
88
authors = ["Parity Technologies <[email protected]>"]
99
build = "build.rs"
1010

core/rpc/src/system/helpers.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ pub struct Health {
4343
pub peers: usize,
4444
/// Is the node syncing
4545
pub is_syncing: bool,
46+
/// Should this node have any peers
47+
pub should_have_peers: bool,
4648
}
4749

4850
/// Network Peer information

core/rpc/src/system/mod.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,11 @@ impl<B: traits::Block> SystemApi<B::Hash, <B::Header as HeaderT>::Number> for Sy
103103

104104
fn system_health(&self) -> Result<Health> {
105105
let status = self.sync.status();
106-
107-
let is_syncing = status.sync.is_major_syncing();
108-
let peers = status.num_peers;
109-
110-
let health = Health {
111-
peers,
112-
is_syncing,
113-
};
114-
115-
let has_no_peers = peers == 0 && self.should_have_peers;
116-
if has_no_peers || is_syncing {
117-
Err(error::ErrorKind::NotHealthy(health))?
118-
} else {
119-
Ok(health)
120-
}
106+
Ok(Health {
107+
peers: status.num_peers,
108+
is_syncing: status.sync.is_major_syncing(),
109+
should_have_peers: self.should_have_peers,
110+
})
121111
}
122112

123113
fn system_peers(&self) -> Result<Vec<PeerInfo<B::Hash, <B::Header as HeaderT>::Number>>> {

core/rpc/src/system/tests.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,25 @@ fn system_properties_works() {
9797
#[test]
9898
fn system_health() {
9999
assert_matches!(
100-
api(None).system_health().unwrap_err().kind(),
101-
error::ErrorKind::NotHealthy(Health {
100+
api(None).system_health().unwrap(),
101+
Health {
102102
peers: 0,
103103
is_syncing: false,
104-
})
104+
should_have_peers: true,
105+
}
105106
);
106107

107108
assert_matches!(
108109
api(Status {
109110
peers: 5,
110111
is_syncing: true,
111112
is_dev: true,
112-
}).system_health().unwrap_err().kind(),
113-
error::ErrorKind::NotHealthy(Health {
113+
}).system_health().unwrap(),
114+
Health {
114115
peers: 5,
115116
is_syncing: true,
116-
})
117+
should_have_peers: false,
118+
}
117119
);
118120

119121
assert_eq!(
@@ -125,6 +127,7 @@ fn system_health() {
125127
Health {
126128
peers: 5,
127129
is_syncing: false,
130+
should_have_peers: true,
128131
}
129132
);
130133

@@ -137,6 +140,7 @@ fn system_health() {
137140
Health {
138141
peers: 0,
139142
is_syncing: false,
143+
should_have_peers: false,
140144
}
141145
);
142146
}

node/runtime/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
9696
spec_name: create_runtime_str!("node"),
9797
impl_name: create_runtime_str!("substrate-node"),
9898
authoring_version: 10,
99-
spec_version: 12,
100-
impl_version: 12,
99+
spec_version: 14,
100+
impl_version: 14,
101101
apis: RUNTIME_API_VERSIONS,
102102
};
103103

Binary file not shown.

0 commit comments

Comments
 (0)