Skip to content

Commit

Permalink
Pass index file path by parameter (WalletWasabi#13368)
Browse files Browse the repository at this point in the history
Co-authored-by: Turbolay <[email protected]>
  • Loading branch information
lontivero and turbolay authored Sep 7, 2024
1 parent 15f0384 commit 88ab412
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion WalletWasabi.Backend/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public Global(string dataDir, IRPCClient rpcClient, Config config)
// Initialize index building
var indexBuilderServiceDir = Path.Combine(DataDir, "IndexBuilderService");
var indexFilePath = Path.Combine(indexBuilderServiceDir, $"Index{RpcClient.Network}.dat");
IndexBuilderService = new(RpcClient, HostedServices.Get<BlockNotifier>());
IndexBuilderService = new(RpcClient, HostedServices.Get<BlockNotifier>(), indexFilePath);
}

public string DataDir { get; }
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi.Tests/RegressionTests/BackendTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public async Task FilterBuilderTestAsync()
var indexBuilderServiceDir = Helpers.Common.GetWorkDir();
var indexFilePath = Path.Combine(indexBuilderServiceDir, $"Index{rpc.Network}.dat");

IndexBuilderService indexBuilderService = new(rpc, global.HostedServices.Get<BlockNotifier>());
IndexBuilderService indexBuilderService = new(rpc, global.HostedServices.Get<BlockNotifier>(), "filters.txt");
try
{
indexBuilderService.Synchronize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public async Task SegwitTaprootUnsynchronizedBitcoinNodeAsync()
}),
};
using var blockNotifier = new BlockNotifier(rpc);
var indexer = new IndexBuilderService(rpc, blockNotifier);
var indexer = new IndexBuilderService(rpc, blockNotifier, "filters.txt");

indexer.Synchronize();

Expand All @@ -55,7 +55,7 @@ public async Task SegwitTaprootStalledBitcoinNodeAsync()
}
};
using var blockNotifier = new BlockNotifier(rpc);
var indexer = new IndexBuilderService(rpc, blockNotifier);
var indexer = new IndexBuilderService(rpc, blockNotifier, "filters.txt");

indexer.Synchronize();

Expand Down Expand Up @@ -86,7 +86,7 @@ public async Task SegwitTaprootSynchronizingBitcoinNodeAsync()
OnGetVerboseBlockAsync = (hash) => Task.FromResult(blockchain.Single(x => x.Hash == hash))
};
using var blockNotifier = new BlockNotifier(rpc);
var indexer = new IndexBuilderService(rpc, blockNotifier);
var indexer = new IndexBuilderService(rpc, blockNotifier, "filters.txt");

indexer.Synchronize();

Expand Down Expand Up @@ -156,7 +156,7 @@ public async Task SegwitTaprootSynchronizedBitcoinNodeAsync()
OnGetVerboseBlockAsync = (hash) => Task.FromResult(blockchain.Single(x => x.Hash == hash))
};
using var blockNotifier = new BlockNotifier(rpc);
var indexer = new IndexBuilderService(rpc, blockNotifier);
var indexer = new IndexBuilderService(rpc, blockNotifier, "filters.txt");

indexer.Synchronize();

Expand All @@ -182,7 +182,7 @@ public async Task TaprootUnsynchronizedBitcoinNodeAsync()
}),
};
using var blockNotifier = new BlockNotifier(rpc);
var indexer = new IndexBuilderService(rpc, blockNotifier);
var indexer = new IndexBuilderService(rpc, blockNotifier, "filters.txt");

indexer.Synchronize();

Expand All @@ -209,7 +209,7 @@ public async Task TaprootStalledBitcoinNodeAsync()
}
};
using var blockNotifier = new BlockNotifier(rpc);
var indexer = new IndexBuilderService(rpc, blockNotifier);
var indexer = new IndexBuilderService(rpc, blockNotifier, "filters.txt");

indexer.Synchronize();

Expand Down Expand Up @@ -240,7 +240,7 @@ public async Task TaprootSynchronizingBitcoinNodeAsync()
OnGetVerboseBlockAsync = (hash) => Task.FromResult(blockchain.Single(x => x.Hash == hash))
};
using var blockNotifier = new BlockNotifier(rpc);
var indexer = new IndexBuilderService(rpc, blockNotifier);
var indexer = new IndexBuilderService(rpc, blockNotifier, "filters.txt");

indexer.Synchronize();

Expand Down Expand Up @@ -268,7 +268,7 @@ public async Task TaprootSynchronizedBitcoinNodeAsync()
OnGetVerboseBlockAsync = (hash) => Task.FromResult(blockchain.Single(x => x.Hash == hash))
};
using var blockNotifier = new BlockNotifier(rpc);
var indexer = new IndexBuilderService(rpc, blockNotifier);
var indexer = new IndexBuilderService(rpc, blockNotifier, "filters.txt");

indexer.Synchronize();

Expand Down
4 changes: 1 addition & 3 deletions WalletWasabi/Blockchain/BlockFilters/IndexBuilderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ public class IndexBuilderService

private long _workerCount;

public IndexBuilderService(IRPCClient rpc, BlockNotifier blockNotifier)
public IndexBuilderService(IRPCClient rpc, BlockNotifier blockNotifier, string indexFilePath)
{
RpcClient = Guard.NotNull(nameof(rpc), rpc);
BlockNotifier = Guard.NotNull(nameof(blockNotifier), blockNotifier);
var indexBuilderServiceDir = Path.Combine(".", "IndexBuilderService");
var indexFilePath = Path.Combine(indexBuilderServiceDir, $"Index{rpc.Network}.dat");

IndexFilePath = Guard.NotNullOrEmptyOrWhitespace(nameof(indexFilePath), indexFilePath);
StartingHeight = SmartHeader.GetStartingHeader(RpcClient.Network).Height;
Expand Down

0 comments on commit 88ab412

Please sign in to comment.