Introduce Additional Data to Store Blob and move obsolete props to migration (#2065)

* Introduce Additional Data to Store Blob and move obsolete props to migration

* Fixes and tests

* Small adjustements to prevent tracking too many objects

Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
This commit is contained in:
Andrew Camilleri
2020-12-29 09:58:35 +01:00
committed by GitHub
parent 5803512820
commit ae32fdeea7
8 changed files with 262 additions and 153 deletions

View File

@@ -52,46 +52,6 @@ namespace BTCPayServer.Data
return result;
}
public static List<PaymentMethodCriteria> GetPaymentMethodCriteria(this StoreData storeData, BTCPayNetworkProvider networkProvider,StoreBlob storeBlob = null)
{
#pragma warning disable 612
storeBlob ??= storeData.GetStoreBlob();
return storeData.GetEnabledPaymentIds(networkProvider).Select(paymentMethodId=>
{
var matchedFromBlob =
#pragma warning disable CS0618 // Type or member is obsolete
storeBlob.PaymentMethodCriteria?.SingleOrDefault(criteria => criteria.PaymentMethod == paymentMethodId && criteria.Value != null);
#pragma warning restore CS0618 // Type or member is obsolete
if (matchedFromBlob is null && paymentMethodId.PaymentType == LightningPaymentType.Instance && storeBlob.LightningMaxValue != null)
{
return new PaymentMethodCriteria()
{
Above = false,
PaymentMethod = paymentMethodId,
Value = storeBlob.LightningMaxValue
};
}
if (matchedFromBlob is null && paymentMethodId.PaymentType == BitcoinPaymentType.Instance && storeBlob.OnChainMinValue != null)
{
return new PaymentMethodCriteria()
{
Above = true,
PaymentMethod = paymentMethodId,
Value = storeBlob.OnChainMinValue
};
}
return new PaymentMethodCriteria()
{
PaymentMethod = paymentMethodId,
Above = matchedFromBlob?.Above??true,
Value = matchedFromBlob?.Value
};
}).ToList();
#pragma warning restore 612
}
public static bool SetStoreBlob(this StoreData storeData, StoreBlob storeBlob)
{
var original = new Serializer(null).ToString(storeData.GetStoreBlob());