Skip to content

Commit

Permalink
Wallet db to use sqlite (instead of litedbv4) (#272)
Browse files Browse the repository at this point in the history
* sqlite data table and serialization code

* Final table changes and fix tests to work

* in memory store for tests

* Fix some tests

* Fix some more tests

* fix minor history problem

* Add wallet version for future upgrades

* add comments in memory constructor

* Act on review

* Regenerate test data
  • Loading branch information
dangershony authored Feb 19, 2021
1 parent ef16368 commit ad2fca4
Show file tree
Hide file tree
Showing 32 changed files with 544 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public static WalletHistoryModel GetHistory(IWalletManager walletManager, Networ

// Sort and filter the history items.
List<TransactionItemModel> itemsToInclude = transactionItems.OrderByDescending(t => t.Timestamp)
.Where(x => String.IsNullOrEmpty(request.SearchQuery) || (x.Id.ToString() == request.SearchQuery || x.ToAddress == request.SearchQuery || x.Payments.Any(p => p.DestinationAddress == request.SearchQuery)))
.Where(x => string.IsNullOrEmpty(request.SearchQuery) || (x.Id.ToString() == request.SearchQuery || x.ToAddress == request.SearchQuery || x.Payments.Any(p => p.DestinationAddress == request.SearchQuery)))
.Skip(request.Skip ?? 0)
.Take(request.Take ?? transactionItems.Count)
.ToList();
Expand All @@ -350,4 +350,4 @@ private static TransactionItemModel FindSimilarReceivedTransactionOutput(List<Tr
return existingTransaction;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.11" />
<PackageReference Include="Dapper" Version="2.0.78" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="5.0.2" />
<PackageReference Include="System.Reactive" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.11" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.11" />
Expand Down
57 changes: 57 additions & 0 deletions src/Features/Blockcore.Features.Wallet/Database/WalletData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class WalletData

public HashHeightPair WalletTip { get; set; }

public int WalletVersion { get; set; }

public ICollection<uint256> BlockLocator { get; set; }
}

Expand Down Expand Up @@ -55,4 +57,59 @@ public class WalletHistoryPaymentData
public Money Amount { get; set; }
public bool? PayToSelf { get; set; }
}

public class TransactionData
{
public TransactionData()
{
this.SpendingDetailsPayments = new List<PaymentDetails>();
}

public OutPoint OutPoint { get; set; }

public string Address { get; set; }

public int AccountIndex { get; set; }

public uint256 Id { get; set; }

public Money Amount { get; set; }

public bool? IsCoinBase { get; set; }

public bool? IsCoinStake { get; set; }

public bool? IsColdCoinStake { get; set; }

public int IndexInTransaction { get; set; }

public int? BlockHeight { get; set; }

public uint256 BlockHash { get; set; }

public int? BlockIndex { get; set; }

public DateTimeOffset CreationTime { get; set; }

public PartialMerkleTree MerkleProof { get; set; }
public string Hex { get; set; }

public Script ScriptPubKey { get; set; }

public bool? IsPropagated { get; set; }

public uint256 SpendingDetailsTransactionId { get; set; }

public ICollection<PaymentDetails> SpendingDetailsPayments { get; set; }

public int? SpendingDetailsBlockHeight { get; set; }

public int? SpendingDetailsBlockIndex { get; set; }

public bool? SpendingDetailsIsCoinStake { get; set; }

public DateTimeOffset? SpendingDetailsCreationTime { get; set; }

public string SpendingDetailsHex { get; set; }
}
}
Loading

0 comments on commit ad2fca4

Please sign in to comment.