From 1471a1cb961ac52029708e7243f0983cb9ee6a6c Mon Sep 17 00:00:00 2001 From: Ilya Bogdanov Date: Mon, 13 Jan 2020 18:34:14 +0300 Subject: [PATCH 1/3] Support different supervisor modes in exonum-java --- .../core/rust/exonum-java/src/node.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/exonum-java-binding/core/rust/exonum-java/src/node.rs b/exonum-java-binding/core/rust/exonum-java/src/node.rs index 58c35b3c62..4cdbbfdad5 100644 --- a/exonum-java-binding/core/rust/exonum-java/src/node.rs +++ b/exonum-java-binding/core/rust/exonum-java/src/node.rs @@ -14,7 +14,7 @@ * limitations under the License. */ -use exonum_supervisor::Supervisor; +use exonum_supervisor::{mode::Mode as SupervisorMode, Supervisor}; use exonum_time::TimeServiceFactory; use java_bindings::{ create_java_vm, create_service_runtime, @@ -70,7 +70,13 @@ fn create_blockchain( let blockchain = Blockchain::new(database, keypair, api_sender); - let supervisor_service = supervisor_service(); + let supervisor_mode = &config + .run_config + .node_config + .public_config + .general + .supervisor_mode; + let supervisor_service = supervisor_service(supervisor_mode); let genesis_config = GenesisConfigBuilder::with_consensus_config(node_config.consensus) .with_artifact(Supervisor.artifact_id()) .with_instance(supervisor_service) @@ -110,6 +116,9 @@ fn create_database(config: &Config) -> Result, failure::Error> Ok(database) } -fn supervisor_service() -> InstanceInitParams { - Supervisor::simple() +fn supervisor_service(mode: &SupervisorMode) -> InstanceInitParams { + match *mode { + SupervisorMode::Simple => Supervisor::simple(), + SupervisorMode::Decentralized => Supervisor::decentralized(), + } } From d903ab5170bcb7998a00212802368303734d2c4c Mon Sep 17 00:00:00 2001 From: Ilya Bogdanov Date: Tue, 14 Jan 2020 16:14:48 +0300 Subject: [PATCH 2/3] Update changelog --- exonum-java-binding/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/exonum-java-binding/CHANGELOG.md b/exonum-java-binding/CHANGELOG.md index bbf4675240..2dff5abf4f 100644 --- a/exonum-java-binding/CHANGELOG.md +++ b/exonum-java-binding/CHANGELOG.md @@ -23,6 +23,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. `ProofListIndexProxy.getProof`, `ProofListIndexProxy.getRangeProof` and `ListProof`. - `ProofEntryIndexProxy` collection. +- `supervisor-mode` CLI parameter added for `generate-template` command. It + allows to configure the mode of the Supervisor service. Possible values are + "simple" and "decentralized". (#1361) ### Changed - Transactions are now implemented as service methods annotated with From 2898a395651c43c74e03a827d0c9ab4f48d058f6 Mon Sep 17 00:00:00 2001 From: Ilya Bogdanov Date: Tue, 14 Jan 2020 16:16:35 +0300 Subject: [PATCH 3/3] Move mode extraction to supervisor_service --- .../core/rust/exonum-java/src/node.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/exonum-java-binding/core/rust/exonum-java/src/node.rs b/exonum-java-binding/core/rust/exonum-java/src/node.rs index 4cdbbfdad5..d04967a5ee 100644 --- a/exonum-java-binding/core/rust/exonum-java/src/node.rs +++ b/exonum-java-binding/core/rust/exonum-java/src/node.rs @@ -70,13 +70,7 @@ fn create_blockchain( let blockchain = Blockchain::new(database, keypair, api_sender); - let supervisor_mode = &config - .run_config - .node_config - .public_config - .general - .supervisor_mode; - let supervisor_service = supervisor_service(supervisor_mode); + let supervisor_service = supervisor_service(&config); let genesis_config = GenesisConfigBuilder::with_consensus_config(node_config.consensus) .with_artifact(Supervisor.artifact_id()) .with_instance(supervisor_service) @@ -116,7 +110,13 @@ fn create_database(config: &Config) -> Result, failure::Error> Ok(database) } -fn supervisor_service(mode: &SupervisorMode) -> InstanceInitParams { +fn supervisor_service(config: &Config) -> InstanceInitParams { + let mode = &config + .run_config + .node_config + .public_config + .general + .supervisor_mode; match *mode { SupervisorMode::Simple => Supervisor::simple(), SupervisorMode::Decentralized => Supervisor::decentralized(),