forked from WalletWasabi/WalletWasabi
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Turbolay
committed
Jan 9, 2024
1 parent
9fe6ab4
commit 885374f
Showing
2 changed files
with
8 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,7 +119,7 @@ private set | |
public PaymentBatch BatchedPayments { get; } | ||
|
||
public int AnonScoreTarget => KeyManager.AnonScoreTarget; | ||
public bool ConsolidationMode { get; set; } = false; | ||
public bool ConsolidationMode { get; set; } | ||
|
||
public bool IsMixable => | ||
State == WalletState.Started // Only running wallets | ||
|
@@ -164,9 +164,9 @@ public IEnumerable<SmartTransaction> GetTransactions() | |
/// <summary> | ||
/// Get all wallet transactions along with corresponding amounts ordered by blockchain. | ||
/// </summary> | ||
/// <param name="sortForUI"><c>true</c> to sort by "first seen", "height", and "block index", <c>false</c> to sort by "height", "block index", and "first seen".</param> | ||
/// <param name="sortForUi"><c>true</c> to sort by "first seen", "height", and "block index", <c>false</c> to sort by "height", "block index", and "first seen".</param> | ||
/// <remarks>Transaction amount specifies how it affected your final wallet balance (spend some bitcoin, received some bitcoin, or no change).</remarks> | ||
public List<TransactionSummary> BuildHistorySummary(bool sortForUI = false) | ||
public List<TransactionSummary> BuildHistorySummary(bool sortForUi = false) | ||
{ | ||
Dictionary<uint256, TransactionSummary> mapByTxid = new(); | ||
|
||
|
@@ -196,7 +196,7 @@ public List<TransactionSummary> BuildHistorySummary(bool sortForUI = false) | |
} | ||
} | ||
|
||
return sortForUI | ||
return sortForUi | ||
? mapByTxid.Values.OrderBy(x => x.FirstSeen).ThenBy(x => x.Height).ThenBy(x => x.BlockIndex).ToList() | ||
: mapByTxid.Values.OrderByBlockchain().ToList(); | ||
} | ||
|
@@ -433,11 +433,6 @@ private async void IndexDownloader_NewFiltersAsync(object? sender, IEnumerable<F | |
NewFiltersProcessed?.Invoke(this, filterModels); | ||
await Task.Delay(100).ConfigureAwait(false); | ||
|
||
if (Synchronizer is null || BitcoinStore?.SmartHeaderChain is null) | ||
{ | ||
return; | ||
} | ||
|
||
// Make sure fully synced and this filter is the latest filter. | ||
if (BitcoinStore.SmartHeaderChain.HashesLeft != 0 || BitcoinStore.SmartHeaderChain.TipHash != filterModels.Last().Header.BlockHash) | ||
{ | ||
|
@@ -446,10 +441,7 @@ private async void IndexDownloader_NewFiltersAsync(object? sender, IEnumerable<F | |
|
||
var task = BitcoinStore.MempoolService.TryPerformMempoolCleanupAsync(Synchronizer.HttpClientFactory); | ||
|
||
if (task is { }) | ||
{ | ||
await task.ConfigureAwait(false); | ||
} | ||
await task.ConfigureAwait(false); | ||
} | ||
catch (OperationCanceledException) | ||
{ | ||
|
@@ -486,6 +478,7 @@ private async Task LoadWalletStateAsync(CancellationToken cancel) | |
KeyManager.SetBestTurboSyncHeight(startingSegwitHeight); | ||
} | ||
|
||
// ReSharper disable once ExplicitCallerInfoArgument | ||
using (BenchmarkLogger.Measure(LogLevel.Info, "Initial Transaction Processing")) | ||
{ | ||
TransactionProcessor.Process(BitcoinStore.TransactionStore.ConfirmedStore.GetTransactions().TakeWhile(x => x.Height <= bestTurboSyncHeight)); | ||
|
@@ -535,7 +528,7 @@ private async Task LoadDummyMempoolAsync() | |
foreach (var tx in BitcoinStore.TransactionStore.MempoolStore.GetTransactions()) | ||
{ | ||
uint256 hash = tx.GetHash(); | ||
if (mempoolHashes.Contains(hash.ToString()[..compactness])) | ||
if (mempoolHashes.Contains(hash.ToString()?[..compactness] ?? string.Empty)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
turbolay
Owner
|
||
{ | ||
txsToProcess.Add(tx); | ||
Logger.LogInfo($"'{WalletName}': Transaction was successfully tested against the backend's mempool hashes: {hash}."); | ||
|
I think that the approach should be slightly different: kiminuo@699d4fc and even that
hash.ToString()
is totally inefficient as it allocates as crazy:-> I think that there should be a method in NBitcoin for converting
uint256
toReadOnlyMemory<char>
which would prevent many and many allocations.But then I understand that the algo here is not entirely great so maybe it's not worth doing it. But I think it would be a great improvement.