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

feat(utxo): prioritize electrum connections #1966

Merged
merged 206 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
bd00a99
stash
rozhkovdmitrii Aug 26, 2023
a31179a
stash
Aug 29, 2023
da4e5f9
save state of being able to be compiled
Sep 4, 2023
38e3cc4
save state
Sep 7, 2023
50c8052
introduce conn_mng guarded state
Sep 8, 2023
4ba4a1a
stash
Sep 10, 2023
9466e53
get rid of warnings
Sep 11, 2023
ae5ed65
pushing secondary connection is implemented
Sep 21, 2023
c1bffff
move connect_to
Sep 21, 2023
03af8ce
Conn manager works as it was supposed
Sep 21, 2023
b31a9ff
refactor: get `get_conn` and `get_conn_by_address` apart
Sep 21, 2023
f325ebf
refactor: electrum_request_multi rolled back
Sep 21, 2023
39a7475
feat: introduce conn_mng_policy and start moving parts into the files…
Sep 22, 2023
0e612bb
feat: started to implement multiple_conn_mng based on dev branch
Sep 22, 2023
d5fa172
feat: stash
Sep 25, 2023
e7a10f0
feat: multiple conn mng has been simplified
Sep 25, 2023
cfbeea0
doc: get rid of typo
Sep 27, 2023
99408ce
refactor: Bring Priority enum into mm2_rpc::rpc_data
Sep 27, 2023
de14a3f
feat: Provide setting conn_mng_policy during config initialization us…
Sep 27, 2023
8363353
refactor: Prefer &str in some places
Sep 27, 2023
04eae35
feat: implement rotate_servers for conn_mng_multiple
Sep 27, 2023
48d507c
get rid of redundant trace
Sep 27, 2023
a193f5d
revert doc comment
Sep 27, 2023
7b98067
revert commenting
Sep 27, 2023
3663716
process creating subsystem errors
Sep 27, 2023
7f10b19
Merge branch 'dev' into 1520-prioritize-nodes
Sep 28, 2023
4c1a577
commit working state
Sep 28, 2023
da4d58d
make wasm version working
Sep 29, 2023
5686619
Get rid of some warnings
Sep 29, 2023
3534ddb
Renaming
Sep 29, 2023
d98521f
refactor: implement `duplicate_suspend_timeout` and `reset_supend_tim…
Oct 1, 2023
9031c9f
fix: getting of connecting state
Oct 1, 2023
fa25b6f
refactor: spit and polish
Oct 1, 2023
6500dbd
refactor: get_conn_ctx and get_conn_ctx_mut for the selective con_mng
Oct 1, 2023
41c1872
refactor: bring ConnMngTrait into separate file
Oct 1, 2023
22116e1
refactor: introduce ConnMngError
Oct 1, 2023
0d09323
refactor: rollback some changes
Oct 3, 2023
9d045ef
refactor: rollback some changes
Oct 3, 2023
4fce08b
Revert "refactor: rollback some changes"
Oct 3, 2023
95bf9fa
refactor: rollback some changes
Oct 3, 2023
2373174
refactor: rollback some changes
Oct 3, 2023
9608966
refactor: spit and polish
Oct 3, 2023
d05347d
refactor: spit and polish
Oct 3, 2023
291d901
refactor: spit and polish
Oct 3, 2023
5e51798
refactor: spit and polish
Oct 3, 2023
5b23e37
refactor: spit and polish
Oct 3, 2023
eb82125
refactor: spit and polish
Oct 3, 2023
3e98a42
refactor: spit and polish
Oct 3, 2023
5663668
refactor: spit and polish
Oct 3, 2023
79e6850
refactor: spit and polish
Oct 3, 2023
0e10bcb
refactor: spit and polish
Oct 3, 2023
6f96d6e
Merge branch 'dev' into 1520-prioritize-nodes
borngraced Jan 30, 2024
c630ee0
fix merge conflicts
borngraced Jan 30, 2024
71d9664
fix wasm clippy warnings
borngraced Jan 30, 2024
b2434da
rename conn_mng -> connection_manager
borngraced Jan 30, 2024
935bee5
merge ConnectionManagerSelectiveQueue with ConnectionManagerSelective…
borngraced Jan 31, 2024
2097e53
manage sending multiple sub requests for same scripthash and other fi…
borngraced Feb 6, 2024
0ed6c3a
Merge remote-tracking branch 'origin/dev' into 1520-prioritize-nodes
borngraced Feb 12, 2024
e6585ee
fix merge conflicts
borngraced Feb 12, 2024
9cc0378
fix review notes and improvements
borngraced Feb 15, 2024
0e59572
rename guarded to state_guard and move connect impl to impl trait for…
borngraced Feb 15, 2024
e6f2ba3
move get_connection_ctx_mut and get_connection_ctx to ConnectionManag…
borngraced Feb 15, 2024
5eede71
move ElectrumConnCtx to rpc_clients::connection_manager_common and co…
borngraced Feb 16, 2024
350a992
merge get_suspend_timeout and duplicate_suspend_timeout and other ver…
borngraced Feb 16, 2024
2d24da3
connection is_connected is properly checked for selective
borngraced Feb 16, 2024
7b7110d
move state related/only method to it's impl
borngraced Feb 16, 2024
10ff5c8
revert is_connected impl for multiple
borngraced Feb 16, 2024
ef6ff41
handle error in ConnectionManagerMultipleImpl
borngraced Feb 16, 2024
f87278d
Refactor ConnectionManagerMultiple & ConnectionManagerSelective
mariocynicys Feb 15, 2024
61af931
fix merge conflicts
borngraced Mar 22, 2024
a1d0a9a
set the state as running when we start executing the future
mariocynicys Apr 17, 2024
ebb5394
this type annotation isn't needed
mariocynicys Apr 17, 2024
9bed9d1
remove deadcode
mariocynicys Apr 17, 2024
5666936
stashing
mariocynicys Apr 18, 2024
426037c
stashing
mariocynicys Apr 19, 2024
94a90aa
stashing
mariocynicys Apr 21, 2024
20c70bf
pushing working tree for starter review - still messy tho
mariocynicys Apr 22, 2024
0471735
stashing
mariocynicys Apr 30, 2024
bf3781f
stashing
mariocynicys May 5, 2024
2129a8f
compiles for linux targets only
mariocynicys May 5, 2024
dafff72
atomically start connections
mariocynicys May 13, 2024
a9a56fe
fix wasm build
mariocynicys May 13, 2024
7cffd67
some lint fixes and formatting
mariocynicys May 13, 2024
1b49971
add back scripthash notification sender since it's used to send Subsc…
mariocynicys May 13, 2024
af03de3
multiple connection manager
mariocynicys May 17, 2024
b296728
record a fixme
mariocynicys May 17, 2024
5a06371
fix lint issues
mariocynicys May 20, 2024
85c3609
abort all jobs in the queue but keep it intact
mariocynicys May 22, 2024
c2f4488
add get_all_server_addresses method to connection manager trait
mariocynicys May 22, 2024
dd7cb96
fix: reuse type def - RpcTransportEventHandler
mariocynicys May 22, 2024
6bb5e4f
fix: get rid of useless async closure
mariocynicys May 22, 2024
2d72df4
add fixme: reminder to fire a ping loop to keep connections alive
mariocynicys May 22, 2024
d31f648
fix: send ping requests to all the active servers
mariocynicys May 22, 2024
d8c11b9
fix: add a pinging loop and manage it from the connection manager
mariocynicys May 22, 2024
5f91ca5
store next suspend time in terms of seconds and not milliseconds
mariocynicys May 22, 2024
518819b
bound establish_connecion_loop method with a timeout
mariocynicys May 23, 2024
2be78df
refactor constant names
mariocynicys May 23, 2024
dfc4bc7
discuss -> fixme, to better find problems in the PR
mariocynicys May 23, 2024
769304b
complete the selective connection manager, fixmes left
mariocynicys May 29, 2024
dc47f67
fix some bugs and fixmes
mariocynicys May 30, 2024
cce2ec4
temp fix: leak the abortable system to keep its children systems alive
mariocynicys May 30, 2024
4c76491
remove panic
mariocynicys May 30, 2024
ed6801d
wait till one of the electrum server connects
mariocynicys May 30, 2024
3d9680a
don't query for the version again
mariocynicys May 31, 2024
229a809
don't create an extra child subsystem, use the parent directly
mariocynicys May 31, 2024
1e0e162
wait till one of the electrum server connects, applied while initiali…
mariocynicys May 31, 2024
8d9ac1c
set the test timeout back to 120s
mariocynicys May 31, 2024
4c8d834
get rid of debuging printlns
mariocynicys May 31, 2024
732e00e
fix wasm issues
mariocynicys Jun 2, 2024
3185860
merge with origin/dev
mariocynicys Jun 3, 2024
ffa086d
fix adex-cli compilation issue
mariocynicys Jun 3, 2024
d908ec6
fix wrong electrum script hash calculation
mariocynicys Jun 4, 2024
eddb9ee
adapt test_unavailable_electrum_proto_version to the new design
mariocynicys Jun 4, 2024
c4592fc
fmt
mariocynicys Jun 4, 2024
f7297b5
implement common trait methods for duplicated impls
mariocynicys Jun 14, 2024
84fc19d
also generalize add_subscriptions method
mariocynicys Jun 14, 2024
76b2f68
fix wasm tests: use wasm's `now_ms` func & don't mutate the original …
mariocynicys Jun 23, 2024
ef4f458
add doc comments for the configuration types
mariocynicys Jun 28, 2024
a447eff
use hashset instead of vec for the subs list
mariocynicys Jun 28, 2024
0103f0b
package `disconnected_at` and `next_suspend_time` in one mutex
mariocynicys Jun 28, 2024
6dab399
don't collect connections list to avoid unnecessary allocations
mariocynicys Jun 28, 2024
d81bd8b
move priority next to electrum stuff :/
mariocynicys Jun 28, 2024
8ae8d02
play safe: call abort on the previous system only after the new system
mariocynicys Jun 28, 2024
220d70b
use mem::take instead of mem::replace + default
mariocynicys Jun 28, 2024
54acd8e
remove fixmes
mariocynicys Jun 28, 2024
d9549ab
connection context: use atomics for u64 feilds
mariocynicys Jul 1, 2024
260192e
adex cli: use closer versions in cargo toml
mariocynicys Jul 1, 2024
5b92281
remove irrelevant comment
mariocynicys Jul 1, 2024
0eedd97
don't convert to json back and forth in wasm
mariocynicys Jul 1, 2024
0395e2c
merge with origin/dev
mariocynicys Jul 1, 2024
8513b37
decide the connection manager policy per coin in the electrum request
mariocynicys Jul 29, 2024
62993a0
merge with origin/dev
mariocynicys Aug 13, 2024
33075e9
retry connections in parallel in selective mode
mariocynicys Aug 14, 2024
064a12d
make sure we don't stuck in the case where all connections are suspended
mariocynicys Aug 14, 2024
ae04b68
add important note
mariocynicys Aug 14, 2024
bf01ba0
add more robustness to `get_active_connections`
mariocynicys Aug 14, 2024
21b0799
endlessly try `electrum_request_multi`
mariocynicys Aug 15, 2024
22fb7ff
only try endlessly on non-test env
mariocynicys Aug 15, 2024
484143a
cfg! is better structured than #[cfg]
mariocynicys Aug 15, 2024
6d71546
trigger disconnecting a connection if it errored
mariocynicys Aug 29, 2024
6c48485
fix: resolve a couple of fixmes optimisitcally
mariocynicys Aug 29, 2024
4b2464c
refactor: replace multiple & selective manager with one more dynamic …
mariocynicys Sep 2, 2024
1a0058c
some macros to simplify if-let & let-else patterns
mariocynicys Sep 2, 2024
7a458e3
only aquire write lock when needed
mariocynicys Sep 2, 2024
ced724b
try connections sequentially on the background task
mariocynicys Sep 2, 2024
21fda09
remove trigger_disconnect
mariocynicys Sep 2, 2024
09f34ca
resolve fixme: version negotiation logic is correct
mariocynicys Sep 3, 2024
7e5e8dd
introduce a connection establishment synchronizer
mariocynicys Sep 3, 2024
4809812
simplify timeouting with a new macro
mariocynicys Sep 3, 2024
f836f04
revert to trying connections in parallel in background task (to some …
mariocynicys Sep 3, 2024
678601f
clean up unused methods, structs, fields
mariocynicys Sep 3, 2024
a6e8d69
merge with origin/dev
mariocynicys Sep 3, 2024
6945ad1
fix the qrc20 issue on CI
mariocynicys Sep 3, 2024
48f5ddd
fix adex-cli compilation (removing traces of conn_manager_policy)
mariocynicys Sep 4, 2024
62d26c7
refactor expirable map
mariocynicys Sep 4, 2024
4a16d78
let the responses map in eletrum connections be expriable
mariocynicys Sep 4, 2024
ea0cbe3
make wait_till_connected test-only
mariocynicys Sep 4, 2024
c37cc9b
split the connection manager into multiple impl blocks
mariocynicys Sep 4, 2024
8fd92df
let connections map inside the manager be dynaimc
mariocynicys Sep 4, 2024
122cf7d
not important; organization
mariocynicys Sep 4, 2024
bf3608d
resolve the last fixmes
mariocynicys Sep 4, 2024
3fb958b
simplfying establish_connection_loop method as much as possible
mariocynicys Sep 5, 2024
69db230
don't retry forever, and also try all connections when the active one…
mariocynicys Sep 10, 2024
eead6a8
properly respect the max_connected threshold
mariocynicys Sep 10, 2024
ffd2052
suggestion from omar - 1
mariocynicys Sep 12, 2024
f9866b1
suggestion from omar - 2 - (un)maintain methods
mariocynicys Sep 12, 2024
d98fd21
testing if this would fix tests
mariocynicys Sep 12, 2024
ff8833a
Revert "testing if this would fix tests"
mariocynicys Sep 15, 2024
df2fdcc
bug: don't disconnect the connection we want to connect while version…
mariocynicys Sep 16, 2024
0971d9c
don't disconnect immediately
mariocynicys Sep 18, 2024
fe90391
abandon the wait_till_connected test-only method
mariocynicys Sep 18, 2024
69a6810
fix test_electrum_rpc_client_error
mariocynicys Sep 18, 2024
9bda46b
fix: flaky test_unavailable_electrum_proto_version
mariocynicys Sep 19, 2024
2c61c61
yield in both test and non-test environment
mariocynicys Sep 24, 2024
25b174a
suggestions from omar: don't send to all
mariocynicys Sep 24, 2024
b546bbd
merge with origin/dev
mariocynicys Sep 24, 2024
49564b3
add a todo regarding abortablequeue abort vs finish
mariocynicys Sep 24, 2024
4c2a5e0
patch on_future_finished to not mark id as finished if it was aborted
mariocynicys Sep 24, 2024
2f9c568
add a todo
mariocynicys Sep 26, 2024
417d054
fix test_one_unavailable_electrum_proto_version
mariocynicys Oct 3, 2024
b791204
review(omar): let version mismatch be an irrecoverable error
mariocynicys Oct 3, 2024
989ec9e
review(omar): use simpiler method args
mariocynicys Oct 4, 2024
e0e7708
simplyfy timeouting - handle timeout in establish_connection_loop only
mariocynicys Oct 4, 2024
db93005
simplify erroring: handle disconnection in establish_connection_loop …
mariocynicys Oct 4, 2024
d2906ff
fix: electrum server labels as irrecoverable when DNS is down
mariocynicys Oct 4, 2024
1e92dfd
review(omar): don't provide a defualt impl for event handler trait
mariocynicys Oct 4, 2024
fc3f172
actually validate min & max connected
mariocynicys Oct 4, 2024
dc8a84e
merge with origin/dev
mariocynicys Oct 4, 2024
c93bcb9
add clear() back to expirable map
mariocynicys Oct 4, 2024
be219ee
reduce the btree key of json bach request to its hash
mariocynicys Oct 4, 2024
556b65f
use a deterministically-selected rpc_id from the batch
mariocynicys Oct 4, 2024
72b3ab9
don't overwrite connection data that's already set
mariocynicys Oct 7, 2024
ee7f6a4
omit unnecessary json conversion
mariocynicys Oct 7, 2024
e99fd25
label version mismatch only when the electrum server replys
mariocynicys Oct 7, 2024
a2e4348
add coin name in error logs
mariocynicys Oct 7, 2024
decacb8
to revert: try to deser the electrum response as json and log it
mariocynicys Oct 7, 2024
89bad4f
disable the coin if the balance query fails
mariocynicys Oct 7, 2024
5e38086
run rpc futures in a tokio thread till completion
mariocynicys Oct 8, 2024
643d1f3
reduce the default connection establishment timeout to 20s
mariocynicys Oct 9, 2024
2060704
cap the electrum request to 5s
mariocynicys Oct 9, 2024
d5b2ef3
mitigate the noisy logs from the endless retries
mariocynicys Oct 10, 2024
00b71c3
Revert "to revert: try to deser the electrum response as json and log…
mariocynicys Oct 10, 2024
cae9842
convert async mutexs to sync ones
mariocynicys Oct 16, 2024
596cba0
parallelize the request when all connections fail
mariocynicys Oct 16, 2024
2457b96
review(sami): let max & min connected be usize
mariocynicys Oct 18, 2024
24a64e3
review(sami): split up the background_task of the connection manager
mariocynicys Oct 20, 2024
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,4 @@ The current state can be considered as a alpha version.

## Help and troubleshooting

If you have any question/want to report a bug/suggest an improvement feel free to [open an issue](https://github.com/artemii235/SuperNET/issues/new) or join the [Komodo Platform Discord](https://discord.gg/PGxVm2y) `dev-marketmaker` channel.
If you have any question/want to report a bug/suggest an improvement feel free to [open an issue](https://github.com/artemii235/SuperNET/issues/new) or join the [Komodo Platform Discord](https://discord.gg/PGxVm2y) `dev-marketmaker` channel. buildbusi
borngraced marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions mm2src/adex_cli/src/adex_proc/adex_proc_impl.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{anyhow, bail, Result};
use log::{error, info, warn};
use log::{debug, error, info, warn};
use mm2_rpc::data::legacy::{BalanceResponse, CoinInitResponse, GetEnabledResponse, Mm2RpcResult, MmVersionResponse,
OrderbookRequest, OrderbookResponse, SellBuyRequest, SellBuyResponse, Status};
use serde_json::{json, Value as Json};
Expand Down Expand Up @@ -38,7 +38,7 @@ impl<T: Transport, P: ResponseHandler, C: AdexConfig + 'static> AdexProc<'_, '_,

let activation_scheme = get_activation_scheme()?;
let activation_method = activation_scheme.get_activation_method(asset)?;

debug!("Got activation scheme for the coin: {}, {:?}", asset, activation_method);
let enable = Command::builder()
.flatten_data(activation_method)
.userpass(self.get_rpc_password()?)
Expand Down
15 changes: 15 additions & 0 deletions mm2src/adex_cli/src/rpc_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,19 @@ pub(super) struct Server {
protocol: ElectrumProtocol,
#[serde(default)]
disable_cert_verification: bool,
#[serde(default)]
pub priority: Priority,
pub timeout_sec: Option<u64>,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum Priority {
Primary,
Secondary,
Tertiary,
}

impl Default for Priority {
fn default() -> Self { Priority::Secondary }
borngraced marked this conversation as resolved.
Show resolved Hide resolved
}
1 change: 1 addition & 0 deletions mm2src/adex_cli/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use log::trace;
borngraced marked this conversation as resolved.
Show resolved Hide resolved
use std::io::Write;
use std::time::Duration;
use tokio::io::AsyncWriteExt;
Expand Down
32 changes: 21 additions & 11 deletions mm2src/coins/lp_coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering as AtomicOrdering;
use std::sync::Arc;
use std::time::Duration;
use tokio::sync::Notify;
use utxo_signer::with_key_pair::UtxoSignWithKeyPairError;
use zcash_primitives::transaction::Transaction as ZTransaction;

Expand Down Expand Up @@ -2843,35 +2844,43 @@ pub enum CoinProtocol {

pub type RpcTransportEventHandlerShared = Arc<dyn RpcTransportEventHandler + Send + Sync + 'static>;

/// Common methods to measure the outgoing requests and incoming responses statistics.
#[async_trait]
borngraced marked this conversation as resolved.
Show resolved Hide resolved
pub trait RpcTransportEventHandler {
fn debug_info(&self) -> String;

fn on_outgoing_request(&self, data: &[u8]);

fn on_incoming_response(&self, data: &[u8]);

fn on_connected(&self, address: String) -> Result<(), String>;
fn on_connected(&self, address: String, conn_spawner: WeakSpawner, verified: Arc<Notify>) -> Result<(), String>;

fn on_connected_async(&self, _address: String) -> Result<(), String> { Ok(()) }
borngraced marked this conversation as resolved.
Show resolved Hide resolved

fn on_disconnected(&self, address: String) -> Result<(), String>;
fn on_disconnected(&self, address: String, conn_spawner: WeakSpawner) -> Result<(), String>;
}

impl fmt::Debug for dyn RpcTransportEventHandler + Send + Sync {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.debug_info()) }
}

#[async_trait]
impl RpcTransportEventHandler for RpcTransportEventHandlerShared {
fn debug_info(&self) -> String { self.deref().debug_info() }

fn on_outgoing_request(&self, data: &[u8]) { self.as_ref().on_outgoing_request(data) }

fn on_incoming_response(&self, data: &[u8]) { self.as_ref().on_incoming_response(data) }

fn on_connected(&self, address: String) -> Result<(), String> { self.as_ref().on_connected(address) }
fn on_connected(&self, address: String, conn_spawner: WeakSpawner, verified: Arc<Notify>) -> Result<(), String> {
self.as_ref().on_connected(address, conn_spawner, verified)
}

fn on_disconnected(&self, address: String) -> Result<(), String> { self.as_ref().on_disconnected(address) }
fn on_disconnected(&self, address: String, conn_spawner: WeakSpawner) -> Result<(), String> {
self.as_ref().on_disconnected(address, conn_spawner)
}
}

#[async_trait]
impl<T: RpcTransportEventHandler> RpcTransportEventHandler for Vec<T> {
fn debug_info(&self) -> String {
let selfi: Vec<String> = self.iter().map(|x| x.debug_info()).collect();
Expand All @@ -2890,16 +2899,16 @@ impl<T: RpcTransportEventHandler> RpcTransportEventHandler for Vec<T> {
}
}

fn on_connected(&self, address: String) -> Result<(), String> {
fn on_connected(&self, address: String, conn_spawner: WeakSpawner, verified: Arc<Notify>) -> Result<(), String> {
for handler in self {
try_s!(handler.on_connected(address.clone()))
try_s!(handler.on_connected(address.clone(), conn_spawner.clone(), verified.clone()))
}
Ok(())
}

fn on_disconnected(&self, address: String) -> Result<(), String> {
fn on_disconnected(&self, address: String, conn_spawner: WeakSpawner) -> Result<(), String> {
for handler in self {
try_s!(handler.on_disconnected(address.clone()))
try_s!(handler.on_disconnected(address.clone(), conn_spawner.clone()))
}
Ok(())
}
Expand Down Expand Up @@ -2943,6 +2952,7 @@ impl CoinTransportMetrics {
fn into_shared(self) -> RpcTransportEventHandlerShared { Arc::new(self) }
}

#[async_trait]
impl RpcTransportEventHandler for CoinTransportMetrics {
fn debug_info(&self) -> String { "CoinTransportMetrics".into() }

Expand All @@ -2960,13 +2970,13 @@ impl RpcTransportEventHandler for CoinTransportMetrics {
"coin" => self.ticker.to_owned(), "client" => self.client.to_owned());
}

fn on_connected(&self, _address: String) -> Result<(), String> {
fn on_connected(&self, _address: String, _conn_spawner: WeakSpawner, _verified: Arc<Notify>) -> Result<(), String> {
// Handle a new connected endpoint if necessary.
// Now just return the Ok
Ok(())
}

fn on_disconnected(&self, _address: String) -> Result<(), String> {
fn on_disconnected(&self, _address: String, _conn_spawner: WeakSpawner) -> Result<(), String> {
// Handle disconnected endpoint if necessary.
// Now just return the Ok
Ok(())
Expand Down
30 changes: 15 additions & 15 deletions mm2src/coins/utxo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ use bitcoin::network::constants::Network as BitcoinNetwork;
pub use bitcrypto::{dhash160, sha256, ChecksumType};
pub use chain::Transaction as UtxoTx;
use chain::{OutPoint, TransactionOutput, TxHashAlgo};
use common::executor::abortable_queue::AbortableQueue;
use common::executor::abortable_queue::{AbortableQueue, WeakSpawner};
#[cfg(not(target_arch = "wasm32"))]
use common::first_char_to_upper;
use common::jsonrpc_client::JsonRpcError;
use common::log::LogOnError;
use common::log::{debug, LogOnError};
use common::{now_sec, now_sec_u32};
use crypto::{Bip32DerPathOps, Bip32Error, Bip44Chain, ChildNumber, DerivationPath, Secp256k1ExtendedPublicKey,
StandardHDPathError, StandardHDPathToAccount, StandardHDPathToCoin};
Expand Down Expand Up @@ -89,21 +89,22 @@ use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::sync::atomic::{AtomicBool, AtomicU64};
use std::sync::{Arc, Mutex, Weak};
use tokio::sync::Notify;
use utxo_builder::UtxoConfBuilder;
use utxo_common::{big_decimal_from_sat, UtxoTxBuilder};
use utxo_signer::with_key_pair::sign_tx;
use utxo_signer::{TxProvider, TxProviderError, UtxoSignTxError, UtxoSignTxResult};

use self::rpc_clients::{electrum_script_hash, ElectrumClient, ElectrumRpcRequest, EstimateFeeMethod, EstimateFeeMode,
NativeClient, UnspentInfo, UnspentMap, UtxoRpcClientEnum, UtxoRpcError, UtxoRpcFut,
UtxoRpcResult};
use self::rpc_clients::{electrum_script_hash, ElectrumClient, ElectrumConnSettings, EstimateFeeMethod,
EstimateFeeMode, NativeClient, UnspentInfo, UnspentMap, UtxoRpcClientEnum, UtxoRpcError,
UtxoRpcFut, UtxoRpcResult};
use super::{big_decimal_from_sat_unsigned, BalanceError, BalanceFut, BalanceResult, CoinBalance, CoinFutSpawner,
CoinsContext, DerivationMethod, FeeApproxStage, FoundSwapTxSpend, HistorySyncState, KmdRewardsDetails,
MarketCoinOps, MmCoin, NumConversError, NumConversResult, PrivKeyActivationPolicy, PrivKeyPolicy,
PrivKeyPolicyNotAllowed, RawTransactionFut, RawTransactionRequest, RawTransactionResult,
RpcTransportEventHandler, RpcTransportEventHandlerShared, TradeFee, TradePreimageError, TradePreimageFut,
TradePreimageResult, Transaction, TransactionDetails, TransactionEnum, TransactionErr,
UnexpectedDerivationMethod, VerificationError, WithdrawError, WithdrawRequest};
RpcTransportEventHandler, TradeFee, TradePreimageError, TradePreimageFut, TradePreimageResult,
Transaction, TransactionDetails, TransactionEnum, TransactionErr, UnexpectedDerivationMethod,
VerificationError, WithdrawError, WithdrawRequest};
use crate::coin_balance::{EnableCoinScanPolicy, EnabledCoinBalanceParams, HDAddressBalanceScanner};
use crate::hd_wallet::{HDAccountOps, HDAccountsMutex, HDAddress, HDAddressId, HDWalletCoinOps, HDWalletOps,
InvalidBip44ChainError};
Expand Down Expand Up @@ -1320,25 +1321,24 @@ struct ElectrumProtoVerifier {
on_event_tx: UnboundedSender<ElectrumProtoVerifierEvent>,
}

impl ElectrumProtoVerifier {
fn into_shared(self) -> RpcTransportEventHandlerShared { Arc::new(self) }
}

#[async_trait]
impl RpcTransportEventHandler for ElectrumProtoVerifier {
fn debug_info(&self) -> String { "ElectrumProtoVerifier".into() }

fn on_outgoing_request(&self, _data: &[u8]) {}

fn on_incoming_response(&self, _data: &[u8]) {}

fn on_connected(&self, address: String) -> Result<(), String> {
fn on_connected(&self, address: String, _conn_spawner: WeakSpawner, _verified: Arc<Notify>) -> Result<(), String> {
debug!("Connected to the electrum server: {}", address);
try_s!(self
.on_event_tx
.unbounded_send(ElectrumProtoVerifierEvent::Connected(address)));
Ok(())
}

fn on_disconnected(&self, address: String) -> Result<(), String> {
fn on_disconnected(&self, address: String, _conn_spawner: WeakSpawner) -> Result<(), String> {
debug!("Disconnected from the electrum server: {}", address);
try_s!(self
.on_event_tx
.unbounded_send(ElectrumProtoVerifierEvent::Disconnected(address)));
Expand Down Expand Up @@ -1437,7 +1437,7 @@ impl UtxoActivationParams {
#[serde(tag = "rpc", content = "rpc_data")]
pub enum UtxoRpcMode {
Native,
Electrum { servers: Vec<ElectrumRpcRequest> },
Electrum { servers: Vec<ElectrumConnSettings> },
}

impl UtxoRpcMode {
Expand Down
Loading
Loading