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
|
||||
transient private PriceFeedService priceFeedService;
|
||||
|
||||
// Used only as cache
|
||||
@Nullable
|
||||
transient private String currencyCode;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
@ -346,8 +350,9 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
||||
|
||||
|
||||
public Optional<String> getAccountAgeWitnessHashAsHex() {
|
||||
if (getExtraDataMap() != null && getExtraDataMap().containsKey(OfferPayload.ACCOUNT_AGE_WITNESS_HASH))
|
||||
return Optional.of(getExtraDataMap().get(OfferPayload.ACCOUNT_AGE_WITNESS_HASH));
|
||||
Map<String, String> extraDataMap = getExtraDataMap();
|
||||
if (extraDataMap != null && extraDataMap.containsKey(OfferPayload.ACCOUNT_AGE_WITNESS_HASH))
|
||||
return Optional.of(extraDataMap.get(OfferPayload.ACCOUNT_AGE_WITNESS_HASH));
|
||||
else
|
||||
return Optional.empty();
|
||||
}
|
||||
@ -421,9 +426,14 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
||||
}
|
||||
|
||||
public String getCurrencyCode() {
|
||||
return offerPayload.getBaseCurrencyCode().equals("BTC") ?
|
||||
if (currencyCode != null) {
|
||||
return currencyCode;
|
||||
}
|
||||
|
||||
currencyCode = offerPayload.getBaseCurrencyCode().equals("BTC") ?
|
||||
offerPayload.getCounterCurrencyCode() :
|
||||
offerPayload.getBaseCurrencyCode();
|
||||
return currencyCode;
|
||||
}
|
||||
|
||||
public long getProtocolVersion() {
|
||||
|
Loading…
Reference in New Issue
Block a user