ExchangeUnion / xud

Exchange Union Daemon 🔁 ⚡️
https://exchangeunion.com
GNU Affero General Public License v3.0
115 stars 44 forks source link

Use `.lock` file for data directory #1989

Open michael1011 opened 4 years ago

michael1011 commented 4 years ago

When playing with two XUDs on a local regtest network, I noticed that they were using the same database and node public key. This is not a critical issue since I don't think that this could cause data corruption of any files, but it is an inconvenience that XUD does not prevent that from happening. There is no use case for using the same data directory for two nodes at the same time, so we should not let XUD do that since it could cause some weird behaviour.

What I propose is creating an empty .lock file for the data directory (or maybe node public key and database file) on startup and removing that file when XUD shuts down. When XUD detects that such a file exists, it should abort the startup and log that there might be an XUD running with that data directory already