69
69
public final class TradeStatistics3 implements ProcessOncePersistableNetworkPayload , PersistableNetworkPayload ,
70
70
CapabilityRequiringPayload , DateSortedTruncatablePayload {
71
71
72
+ private static final String VERSION_KEY = "v" ; // single character key which can be used for versioning if needed
73
+
72
74
@ JsonExclude
73
75
private transient static final ZoneId ZONE_ID = ZoneId .systemDefault ();
74
76
@@ -94,10 +96,11 @@ private static TradeStatistics3 from(Trade trade,
94
96
extraDataMap .put (OfferPayload .REFERRAL_ID , referralId );
95
97
}
96
98
97
- // Store protocol version in order to invert prices of legacy crypto stats.
98
- // This can be removed in the future after all trades use trade protocol version 3+,
99
- // then invert only stats which are missing this field prior to then.
100
- extraDataMap .put (Trade .PROTOCOL_VERSION , trade .getOffer ().getOfferPayload ().getProtocolVersion () + "" );
99
+ // Store a key to indicate that crypto prices are not inverted in this version.
100
+ // This can be removed in the future after all stats are expected to not be inverted,
101
+ // then only stats which are missing this field prior to then need to be uninverted.
102
+ boolean isCryptoCurrency = CurrencyUtil .isCryptoCurrency (trade .getOffer ().getCurrencyCode ());
103
+ if (isCryptoCurrency ) extraDataMap .put (VERSION_KEY , "" ); // value is not currently needed
101
104
102
105
NodeAddress arbitratorNodeAddress = checkNotNull (trade .getArbitrator ().getNodeAddress (), "Arbitrator address is null" , trade .getClass ().getSimpleName (), trade .getId ());
103
106
@@ -416,8 +419,7 @@ public Price getTradePrice() {
416
419
public long getPrice () {
417
420
boolean isInverted = CurrencyUtil .isCryptoCurrency (currency ) &&
418
421
(extraDataMap == null ||
419
- !extraDataMap .containsKey (Trade .PROTOCOL_VERSION ) ||
420
- Integer .parseInt (extraDataMap .get (Trade .PROTOCOL_VERSION )) < 3 );
422
+ !extraDataMap .containsKey (VERSION_KEY )); // price is inverted if missing key
421
423
return isInverted ? PriceUtil .invertLongPrice (price , currency ) : price ;
422
424
}
423
425
0 commit comments