Skip to content

Conversation

@luisschwab
Copy link
Contributor

@luisschwab luisschwab commented Feb 4, 2025

What is the purpose of this pull request?

  • Bug fix
  • Documentation update
  • New feature
  • Test
  • Other:

Which crates are being modified?

  • floresta-chain
  • floresta-cli
  • floresta-common
  • floresta-compact-filters
  • floresta-electrum
  • floresta-watch-only
  • floresta-wire
  • floresta
  • florestad
  • Other: .

Description

This PR handles errors when trying to bind to already already bound resources (datadir, RPC and Electrum ports).

It logs an error! and then exits via std::process::exit(1):

$ ./target/debug/florestad
[2025-02-04 09:59:04 ERROR florestad::florestad] Cannot obtain a lock on data directory $HOME/.floresta/. Floresta is probably already running.

If using another datadir:

$ ./target/debug/florestad --data-dir=data
[2025-02-04 09:59:13 INFO florestad::florestad] Starting server
[2025-02-04 09:59:13 WARN florestad::florestad] Failed to load SSL certificates, ignoring SSL
[2025-02-04 09:59:13 ERROR florestad::florestad] Failed to bind to address 0.0.0.0:50001. There is probably an Electrum server already running.

Notes to the reviewers

Two tests fail when running cargo test, but they are also failing on master:

failures:

---- tests::test_get_height stdout ----
thread 'tests::test_get_height' panicked at crates/floresta-cli/src/lib.rs:216:47:
called `Result::unwrap()` on an `Err` value: JsonRpc(Rpc(RpcError { code: -32601, message: "Method not found", data: None }))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- tests::test_stop stdout ----
thread 'tests::test_stop' panicked at crates/floresta-cli/src/lib.rs:142:34:
rpc not working: JsonRpc(Json(Error("invalid type: boolean `true`, expected a string", line: 1, column: 4)))

Checklist

  • I've signed all my commits
  • I ran just lint
  • I ran cargo test
  • I've checked the integration tests
  • I've followed the contribution guidelines
  • I'm linking the issue being fixed by this PR (if any)

@luisschwab luisschwab changed the title fix(floresta): don't panic if a lock cannot be obtained to the datadir, RPC and Electrum ports fix(florestad): don't panic if a lock cannot be obtained to the datadir, RPC and Electrum ports Feb 4, 2025
@luisschwab luisschwab force-pushed the fix/dont-panic branch 2 times, most recently from e4ee153 to 89ad5a4 Compare February 4, 2025 12:58
@jaoleal
Copy link
Collaborator

jaoleal commented Feb 4, 2025

ACK 8c44251

@Davidson-Souza Davidson-Souza merged commit 0c447bf into vinteumorg:master Feb 4, 2025
7 checks passed
@jaoleal
Copy link
Collaborator

jaoleal commented Feb 4, 2025

Two tests fail when running cargo test, but they are also failing on master:

@luisschwab
This is because the binary in your target/ is from a different version of Floresta than the one your checked into... you need to clear your debug builds and compile florestad right before testing and this error will disappear.

@luisschwab luisschwab deleted the fix/dont-panic branch June 25, 2025 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants