Do not overwrite existing block
MODIFY
WalletWasabi/Wallets/Wallet.cs
WalletWasabi/Wallets/Wallet.cs
@@ -712,11 +712,8 @@ namespace WalletWasabi.Wallets
}
// Save the block
- using (await BlockFolderLock.LockAsync())
- {
var path = Path.Combine(BlockFolderPath, hash.ToString());
- await File.WriteAllBytesAsync(path, block.ToBytes());
- }
+ await SaveBlockToDiskAsync(path, block);
}
finally
{
@@ -726,6 +723,20 @@ namespace WalletWasabi.Wallets
return block;
}
+ private async Task SaveBlockToDiskAsync(string path, Block block)
+ {
+ if (!File.Exists(path))
+ {
+ using (await BlockFolderLock.LockAsync())
+ {
+ if (!File.Exists(path))
+ {
+ await File.WriteAllBytesAsync(path, block.ToBytes());
+ }
+ }
+ }
+ }
+
private async Task<Block> TryDownloadBlockFromLocalNodeAsync(uint256 hash, CancellationToken cancel)
{
if (CoreNode?.RpcClient is null)

Do not overwrite existing block