mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Merge pull request #4954 from chimp1984/various-small-improvements
Various small improvements
This commit is contained in:
commit
9b8073b94a
@ -375,7 +375,10 @@ public class PersistenceManager<T extends PersistableEnvelope> {
|
|||||||
// reference to the persistable object.
|
// reference to the persistable object.
|
||||||
getWriteToDiskExecutor().execute(() -> writeToDisk(serialized, completeHandler));
|
getWriteToDiskExecutor().execute(() -> writeToDisk(serialized, completeHandler));
|
||||||
|
|
||||||
log.info("Serializing {} took {} msec", fileName, System.currentTimeMillis() - ts);
|
long duration = System.currentTimeMillis() - ts;
|
||||||
|
if (duration > 100) {
|
||||||
|
log.info("Serializing {} took {} msec", fileName, duration);
|
||||||
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error("Error in saveToFile toProtoMessage: {}, {}", persistable.getClass().getSimpleName(), fileName);
|
log.error("Error in saveToFile toProtoMessage: {}, {}", persistable.getClass().getSimpleName(), fileName);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -437,7 +440,10 @@ public class PersistenceManager<T extends PersistableEnvelope> {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log.error("Cannot close resources." + e.getMessage());
|
log.error("Cannot close resources." + e.getMessage());
|
||||||
}
|
}
|
||||||
log.info("Writing the serialized {} completed in {} msec", fileName, System.currentTimeMillis() - ts);
|
long duration = System.currentTimeMillis() - ts;
|
||||||
|
if (duration > 100) {
|
||||||
|
log.info("Writing the serialized {} completed in {} msec", fileName, duration);
|
||||||
|
}
|
||||||
persistenceRequested = false;
|
persistenceRequested = false;
|
||||||
if (completeHandler != null) {
|
if (completeHandler != null) {
|
||||||
UserThread.execute(completeHandler);
|
UserThread.execute(completeHandler);
|
||||||
|
@ -46,6 +46,9 @@ public final class Role implements PersistablePayload, NetworkPayload, BondedAss
|
|||||||
private final String link;
|
private final String link;
|
||||||
private final BondedRoleType bondedRoleType;
|
private final BondedRoleType bondedRoleType;
|
||||||
|
|
||||||
|
// Only used as cache
|
||||||
|
transient private final byte[] hash;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name Full name or nickname
|
* @param name Full name or nickname
|
||||||
* @param link GitHub account or forum account of user
|
* @param link GitHub account or forum account of user
|
||||||
@ -74,6 +77,8 @@ public final class Role implements PersistablePayload, NetworkPayload, BondedAss
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
this.link = link;
|
this.link = link;
|
||||||
this.bondedRoleType = bondedRoleType;
|
this.bondedRoleType = bondedRoleType;
|
||||||
|
|
||||||
|
hash = Hash.getSha256Ripemd160hash(toProtoMessage().toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,8 +105,7 @@ public final class Role implements PersistablePayload, NetworkPayload, BondedAss
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] getHash() {
|
public byte[] getHash() {
|
||||||
byte[] bytes = toProtoMessage().toByteArray();
|
return hash;
|
||||||
return Hash.getSha256Ripemd160hash(bytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -109,6 +109,11 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
|||||||
@Setter
|
@Setter
|
||||||
transient private PriceFeedService priceFeedService;
|
transient private PriceFeedService priceFeedService;
|
||||||
|
|
||||||
|
// Used only as cache
|
||||||
|
@Nullable
|
||||||
|
@JsonExclude
|
||||||
|
transient private String currencyCode;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
@ -346,8 +351,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 +427,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() {
|
||||||
|
@ -182,6 +182,10 @@ public final class TradeStatistics3 implements ProcessOncePersistableNetworkPayl
|
|||||||
@Getter
|
@Getter
|
||||||
private final Map<String, String> extraDataMap;
|
private final Map<String, String> extraDataMap;
|
||||||
|
|
||||||
|
// We cache the date object to avoid reconstructing a new Date at each getDate call.
|
||||||
|
@JsonExclude
|
||||||
|
private transient final Date dateObj;
|
||||||
|
|
||||||
public TradeStatistics3(String currency,
|
public TradeStatistics3(String currency,
|
||||||
long price,
|
long price,
|
||||||
long amount,
|
long amount,
|
||||||
@ -251,6 +255,8 @@ public final class TradeStatistics3 implements ProcessOncePersistableNetworkPayl
|
|||||||
this.extraDataMap = ExtraDataMapValidator.getValidatedExtraDataMap(extraDataMap);
|
this.extraDataMap = ExtraDataMapValidator.getValidatedExtraDataMap(extraDataMap);
|
||||||
|
|
||||||
this.hash = hash == null ? createHash() : hash;
|
this.hash = hash == null ? createHash() : hash;
|
||||||
|
|
||||||
|
dateObj = new Date(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] createHash() {
|
public byte[] createHash() {
|
||||||
@ -319,7 +325,7 @@ public final class TradeStatistics3 implements ProcessOncePersistableNetworkPayl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date getDate() {
|
public Date getDate() {
|
||||||
return new Date(date);
|
return dateObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getDateAsLong() {
|
public long getDateAsLong() {
|
||||||
|
@ -177,7 +177,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
|||||||
networkNode.addMessageListener(this);
|
networkNode.addMessageListener(this);
|
||||||
networkNode.addConnectionListener(this);
|
networkNode.addConnectionListener(this);
|
||||||
|
|
||||||
this.persistenceManager.initialize(sequenceNumberMap, PersistenceManager.Source.PRIVATE);
|
this.persistenceManager.initialize(sequenceNumberMap, PersistenceManager.Source.PRIVATE_LOW_PRIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user