Skip to content

Commit

Permalink
rust: Update electrs, remove workaround for fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
shesek committed Oct 20, 2020
1 parent 06f4459 commit 8ddc1c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..
Expand Down
22 changes: 6 additions & 16 deletions subprojects/gdk_rust/gdk_electrum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ impl Session<Error> 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");

Expand All @@ -442,34 +442,24 @@ impl Session<Error> 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) {
Expand Down

0 comments on commit 8ddc1c8

Please sign in to comment.