mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 18:03:12 +01:00
Cache currencyCode
Extract variable getCurrencyCode get called very often (Comparatos) so we cache result.
This commit is contained in:
parent
02d163f5dc
commit
9fc4f61bf6
@ -109,6 +109,10 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
|||||||
@Setter
|
@Setter
|
||||||
transient private PriceFeedService priceFeedService;
|
transient private PriceFeedService priceFeedService;
|
||||||
|
|
||||||
|
// Used only as cache
|
||||||
|
@Nullable
|
||||||
|
transient private String currencyCode;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
@ -346,8 +350,9 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
|||||||
|
|
||||||
|
|
||||||
public Optional<String> getAccountAgeWitnessHashAsHex() {
|
public Optional<String> getAccountAgeWitnessHashAsHex() {
|
||||||
if (getExtraDataMap() != null && getExtraDataMap().containsKey(OfferPayload.ACCOUNT_AGE_WITNESS_HASH))
|
Map<String, String> extraDataMap = getExtraDataMap();
|
||||||
return Optional.of(getExtraDataMap().get(OfferPayload.ACCOUNT_AGE_WITNESS_HASH));
|
if (extraDataMap != null && extraDataMap.containsKey(OfferPayload.ACCOUNT_AGE_WITNESS_HASH))
|
||||||
|
return Optional.of(extraDataMap.get(OfferPayload.ACCOUNT_AGE_WITNESS_HASH));
|
||||||
else
|
else
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
@ -421,9 +426,14 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getCurrencyCode() {
|
public String getCurrencyCode() {
|
||||||
return offerPayload.getBaseCurrencyCode().equals("BTC") ?
|
if (currencyCode != null) {
|
||||||
|
return currencyCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
currencyCode = offerPayload.getBaseCurrencyCode().equals("BTC") ?
|
||||||
offerPayload.getCounterCurrencyCode() :
|
offerPayload.getCounterCurrencyCode() :
|
||||||
offerPayload.getBaseCurrencyCode();
|
offerPayload.getBaseCurrencyCode();
|
||||||
|
return currencyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getProtocolVersion() {
|
public long getProtocolVersion() {
|
||||||
|
Loading…
Reference in New Issue
Block a user