Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support different supervisor modes in exonum-java #1361

Merged
merged 4 commits into from
Jan 15, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions exonum-java-binding/core/rust/exonum-java/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you take node_config from above? And, possibly, move the remaining extraction code inside supervisor_service?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because node_config from above isn't config.run_config.node_config. It's exonum core's internal node configuration which does not have supervisor mode option. ECR-4116 created to address API inconvenience that forced this.

.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)
Expand Down Expand Up @@ -110,6 +116,9 @@ fn create_database(config: &Config) -> Result<Arc<dyn Database>, 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(),
}
}