From 8ddc1c8e53be12df988f21ea5eeb51ec8489ade9 Mon Sep 17 00:00:00 2001 From: Nadav Ivgi Date: Mon, 19 Oct 2020 21:00:56 +0300 Subject: [PATCH] rust: Update electrs, remove workaround for fixed bug --- .gitlab-ci.yml | 2 +- subprojects/gdk_rust/gdk_electrum/src/lib.rs | 22 ++++++-------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d4446c9ac..aed44558b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -162,7 +162,7 @@ integration_test_rust: - cd libwally-core && git checkout 88fc78ff72a4f3345fcb87d1c19dc5f6cc5b0e4c && ./tools/autogen.sh && ./configure --enable-debug --prefix=$PWD/build --enable-static --disable-shared --enable-elements --enable-ecmult-static-precomputation && make && make install && cd .. - export WALLY_DIR=$PWD/libwally-core/build/lib/ - git clone https://github.com/Blockstream/electrs electrs-elements - - cd electrs-elements && git checkout 5bae341585f70699cf12b587a1e9d392df43d674 + - cd electrs-elements && git checkout d6043203310168bee18e47c19772ef375b9daaee - cargo install --debug --root /tmp/electrs_bitcoin --locked --path . - cargo install --debug --root /tmp/electrs_liquid --locked --path . --features liquid - cd .. diff --git a/subprojects/gdk_rust/gdk_electrum/src/lib.rs b/subprojects/gdk_rust/gdk_electrum/src/lib.rs index 8146d70a0..2ff593195 100644 --- a/subprojects/gdk_rust/gdk_electrum/src/lib.rs +++ b/subprojects/gdk_rust/gdk_electrum/src/lib.rs @@ -424,7 +424,7 @@ impl Session for ElectrumSession { let headers_url = self.url.clone(); let (close_headers, r) = channel(); self.closer.senders.push(close_headers); - let mut chunk_size = DIFFCHANGE_INTERVAL as usize; + let chunk_size = DIFFCHANGE_INTERVAL as usize; let headers_handle = thread::spawn(move || { info!("starting headers thread"); @@ -442,34 +442,24 @@ impl Session for ElectrumSession { } match headers.ask(chunk_size, &client) { Ok(headers_found) => { - if headers_found == 0 { - chunk_size = 1 + if headers_found < chunk_size { + break; } else { info!("headers found: {}", headers_found); } } Err(Error::InvalidHeaders) => { + warn!("invalid headers"); // this should handle reorgs and also broke IO writes update if headers.remove(144).is_err() { break; } } Err(e) => { - // usual error is because I reached the tip, trying asking half - //TODO this is due to an esplora electrs bug, according to spec it should - // just return available headers, remove when fix is deployed and change previous - // break condition to headers_found < chunk_size - info!("error while asking headers {}", e); - if chunk_size > 1 { - chunk_size /= 2 - } else { - break; - } + warn!("error while asking headers {}", e); + thread::sleep(Duration::from_millis(500)); } } - if chunk_size == 1 { - break; - } } match headers.get_proofs(&client) {