Skip to content

Commit

Permalink
introduce an async version of stratum server. (#2468)
Browse files Browse the repository at this point in the history
It seems that current approach stops workring after amount of parallel
connection exceeds ~500. This PR introduces an 'async' feature which
enable asyncronius, tokio based implementation of stratum server.

* fix bug with passing current_difficulty in Handler

I passed in Handler current_difficulty as an u64, so it was copied
and all later changes were ignored. In this commit I pass referece on
RwLock with current_difficulty.

* fix crash in build_block

* improve  error handling

* print error message on unknown error

* replace original server by tokio based one

* fixes after review

* reduce sleep time in mail loop to 5ms
  • Loading branch information
e-max authored and ignopeverell committed Feb 9, 2019
1 parent d8605a4 commit 0d36acf
Show file tree
Hide file tree
Showing 4 changed files with 582 additions and 514 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions servers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ serde_json = "1"
chrono = "0.4.4"
bufstream = "~0.1"
jsonrpc-core = "~8.0"
tokio = "0.1.11"

grin_api = { path = "../api", version = "1.0.1" }
grin_chain = { path = "../chain", version = "1.0.1" }
Expand Down
4 changes: 2 additions & 2 deletions servers/src/grin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,12 @@ impl Server {
self.chain.clone(),
self.tx_pool.clone(),
self.verifier_cache.clone(),
self.state_info.stratum_stats.clone(),
);
let stratum_stats = self.state_info.stratum_stats.clone();
let _ = thread::Builder::new()
.name("stratum_server".to_string())
.spawn(move || {
stratum_server.run_loop(stratum_stats, edge_bits as u32, proof_size, sync_state);
stratum_server.run_loop(edge_bits as u32, proof_size, sync_state);
});
}

Expand Down
Loading

0 comments on commit 0d36acf

Please sign in to comment.