From 287bc091a8193f28fc89e4ee6514ae0cde3c0876 Mon Sep 17 00:00:00 2001 From: zhangsoledad <787953403@qq.com> Date: Fri, 7 Apr 2023 17:01:34 +0800 Subject: [PATCH] fix: softfork json style --- devtools/doc/rpc.py | 6 +----- rpc/README.md | 16 ++++++++-------- rpc/src/module/chain.rs | 4 ++-- rpc/src/module/stats.rs | 4 ++-- util/jsonrpc-types/src/blockchain.rs | 5 +++-- util/jsonrpc-types/src/info.rs | 2 ++ 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/devtools/doc/rpc.py b/devtools/doc/rpc.py index 7e0fbcaa88..3f703ec810 100755 --- a/devtools/doc/rpc.py +++ b/devtools/doc/rpc.py @@ -524,11 +524,7 @@ def handle_starttag(self, tag, attrs): if tag == 'section': attrs_dict = dict(attrs) if 'id' in attrs_dict and attrs_dict['id'].startswith('variant.') and ('class', 'variant') in attrs: - if self.name in ["DeploymentPos", "DeploymentState"]: - self.next_variant = attrs_dict['id'].split('.')[1] - else: - self.next_variant = camel_to_snake( - attrs_dict['id'].split('.')[1]) + self.next_variant = camel_to_snake(attrs_dict['id'].split('.')[1]) elif self.variant_parser is None: if tag == 'div' and attrs == [("class", "docblock")]: self.variant_parser = MarkdownParser(title_level=3) diff --git a/rpc/README.md b/rpc/README.md index 50a30e2470..3d94c59a68 100644 --- a/rpc/README.md +++ b/rpc/README.md @@ -1678,8 +1678,8 @@ Response "secp256k1_blake160_multisig_all_type_hash": null, "secp256k1_blake160_sighash_all_type_hash": null, "softforks": { - "Testdummy": { - "status": "Rfc0043", + "testdummy": { + "status": "rfc0043", "rfc0043": { "bit": 1, "min_activation_epoch": "0x0", @@ -4668,13 +4668,13 @@ Response "epoch": "0x1", "hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40", "deployments": { - "Testdummy": { + "testdummy": { "bit": 1, "min_activation_epoch": "0x0", "period": "0xa", "since": "0x0", "start": "0x0", - "state": "Failed", + "state": "failed", "timeout": "0x0", "threshold": { "numer": 3, @@ -5706,7 +5706,7 @@ An object containing various state info regarding deployments of consensus chang Deployment name -`DeploymentPos` is equivalent to `"Testdummy" | "LightClient"`. +`DeploymentPos` is equivalent to `"testdummy" | "light_client"`. * Dummy * light client protocol @@ -5716,7 +5716,7 @@ Deployment name The possible softfork deployment state -`DeploymentState` is equivalent to `"Defined" | "Started" | "LockedIn" | "Active" | "Failed"`. +`DeploymentState` is equivalent to `"defined" | "started" | "locked_in" | "active" | "failed"`. * First state that each softfork starts. The 0 epoch is by definition in this state for each deployment. * For epochs past the `start` epoch. @@ -6641,8 +6641,8 @@ SoftFork information `SoftFork` is equivalent to `"buried" | "rfc0043"`. -* the activation epoch is hard-coded into the client implementation -* the activation is controlled by rfc0043 signaling +* buried - the activation epoch is hard-coded into the client implementation +* rfc0043 - the activation is controlled by rfc0043 signaling ### Type `Status` diff --git a/rpc/src/module/chain.rs b/rpc/src/module/chain.rs index 52887563fc..f7ad6d02b6 100644 --- a/rpc/src/module/chain.rs +++ b/rpc/src/module/chain.rs @@ -1363,8 +1363,8 @@ pub trait ChainRpc { /// "secp256k1_blake160_multisig_all_type_hash": null, /// "secp256k1_blake160_sighash_all_type_hash": null, /// "softforks": { - /// "Testdummy": { - /// "status": "Rfc0043", + /// "testdummy": { + /// "status": "rfc0043", /// "rfc0043": { /// "bit": 1, /// "min_activation_epoch": "0x0", diff --git a/rpc/src/module/stats.rs b/rpc/src/module/stats.rs index e1eb62fbe7..b5d218507f 100644 --- a/rpc/src/module/stats.rs +++ b/rpc/src/module/stats.rs @@ -78,13 +78,13 @@ pub trait StatsRpc { /// "epoch": "0x1", /// "hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40", /// "deployments": { - /// "Testdummy": { + /// "testdummy": { /// "bit": 1, /// "min_activation_epoch": "0x0", /// "period": "0xa", /// "since": "0x0", /// "start": "0x0", - /// "state": "Failed", + /// "state": "failed", /// "timeout": "0x0", /// "threshold": { /// "numer": 3, diff --git a/util/jsonrpc-types/src/blockchain.rs b/util/jsonrpc-types/src/blockchain.rs index ed9235fb78..e7386fcf37 100644 --- a/util/jsonrpc-types/src/blockchain.rs +++ b/util/jsonrpc-types/src/blockchain.rs @@ -1384,6 +1384,7 @@ pub struct HardForkFeature { /// hard-coded into the client implementation), or `rfc0043` (for soft fork deployments /// where activation is controlled by rfc0043 signaling). #[derive(Clone, Copy, Serialize, Deserialize, Debug)] +#[serde(rename_all = "snake_case")] pub enum SoftForkStatus { /// the activation epoch is hard-coded into the client implementation Buried, @@ -1395,9 +1396,9 @@ pub enum SoftForkStatus { #[derive(Clone, Serialize, Deserialize, Debug)] #[serde(untagged)] pub enum SoftFork { - /// the activation epoch is hard-coded into the client implementation + /// buried - the activation epoch is hard-coded into the client implementation Buried(Buried), - /// the activation is controlled by rfc0043 signaling + /// rfc0043 - the activation is controlled by rfc0043 signaling Rfc0043(Rfc0043), } diff --git a/util/jsonrpc-types/src/info.rs b/util/jsonrpc-types/src/info.rs index a45dae22f1..5f985be3e4 100644 --- a/util/jsonrpc-types/src/info.rs +++ b/util/jsonrpc-types/src/info.rs @@ -5,6 +5,7 @@ use std::collections::BTreeMap; /// Deployment name #[derive(Clone, Hash, Deserialize, Serialize, Debug, Ord, PartialOrd, Eq, PartialEq)] +#[serde(rename_all = "snake_case")] pub enum DeploymentPos { /// Dummy Testdummy, @@ -14,6 +15,7 @@ pub enum DeploymentPos { /// The possible softfork deployment state #[derive(Deserialize, Serialize, Debug)] +#[serde(rename_all = "snake_case")] pub enum DeploymentState { /// First state that each softfork starts. /// The 0 epoch is by definition in this state for each deployment.