Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions codechain/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern crate serde_json;
extern crate app_dirs;
extern crate codechain_core as ccore;
extern crate codechain_discovery as cdiscovery;
extern crate codechain_finally as cfinally;
extern crate codechain_key as ckey;
extern crate codechain_keystore as ckeystore;
#[macro_use]
Expand Down
15 changes: 14 additions & 1 deletion codechain/run_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use std::env;
use std::fs;
use std::path::Path;
use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};
use std::time::{Duration, SystemTime, UNIX_EPOCH};

use ccore::{
AccountProvider, Client, ClientService, EngineType, Miner, MinerService, Scheme, ShardValidator, Stratum,
StratumConfig, StratumError,
};
use cdiscovery::{KademliaConfig, KademliaExtension, UnstructuredConfig, UnstructuredExtension};
use cfinally::finally;
use ckeystore::accounts_dir::RootDiskDirectory;
use ckeystore::KeyStore;
use clap::ArgMatches;
Expand Down Expand Up @@ -170,6 +172,17 @@ pub fn run_node(matches: ArgMatches) -> Result<(), String> {
let _event_loop = EventLoop::spawn();
let config = load_config(&matches)?;

// FIXME: It is the hotfix for #348.
// Remove the below code if you find the proper way to solve #348.
let _wait = finally(|| {
const DEFAULT: u64 = 1;
let wait_before_shutdown = env::var_os("WAIT_BEFORE_SHUTDOWN")
.and_then(|sec| sec.into_string().ok())
.and_then(|sec| sec.parse().ok())
.unwrap_or(DEFAULT);
::std::thread::sleep(Duration::from_secs(wait_before_shutdown));
});

let scheme = config.operating.chain.scheme()?;

let instance_id = config.operating.instance_id.unwrap_or(
Expand Down