Skip to content

Commit

Permalink
Merge pull request #3980 from sqrrm/fix-refresh-interval
Browse files Browse the repository at this point in the history
Allow 4 refreshes per trade
  • Loading branch information
ripcurlx authored Feb 18, 2020
2 parents 54918c0 + 0cf7169 commit e7b60d2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 4 additions & 5 deletions core/src/main/java/bisq/core/trade/Trade.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

import java.time.temporal.ChronoUnit;

import java.util.Date;
import java.util.HashSet;
import java.util.Optional;
Expand All @@ -101,8 +99,6 @@
@Slf4j
public abstract class Trade implements Tradable, Model {

public static final long REFRESH_INTERVAL = ChronoUnit.DAYS.getDuration().toMillis();

///////////////////////////////////////////////////////////////////////////////////////////
// Enums
///////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -426,6 +422,8 @@ public static protobuf.Trade.TradePeriodState toProtoMessage(Trade.TradePeriodSt
@Getter
@Setter
private long lastRefreshRequestDate;
@Getter
private long refreshInterval;

///////////////////////////////////////////////////////////////////////////////////////////
// Constructor, initialization
Expand Down Expand Up @@ -456,6 +454,7 @@ protected Trade(Offer offer,
takeOfferDate = new Date().getTime();
processModel = new ProcessModel();
lastRefreshRequestDate = takeOfferDate;
refreshInterval = offer.getPaymentMethod().getMaxTradePeriod() / 5;
}


Expand Down Expand Up @@ -1063,7 +1062,7 @@ public byte[] getArbitratorBtcPubKey() {
}

public boolean allowedRefresh() {
var allowRefresh = new Date().getTime() > lastRefreshRequestDate + REFRESH_INTERVAL;
var allowRefresh = new Date().getTime() > lastRefreshRequestDate + getRefreshInterval();
if (!allowRefresh) {
log.info("Refresh not allowed, last refresh at {}", lastRefreshRequestDate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ public void deactivate() {

private void activateRefreshButton() {
checkNotNull(model.dataModel.getTrade(), "No trade found");

Trade trade = model.dataModel.getTrade();
var timeToNextRefresh =
model.dataModel.getTrade().getLastRefreshRequestDate() + Trade.REFRESH_INTERVAL - new Date().getTime();
trade.getLastRefreshRequestDate() + trade.getRefreshInterval() - new Date().getTime();
if (timeToNextRefresh <= 0) {
refreshButtonPane.setVisible(true);
} else {
Expand Down

0 comments on commit e7b60d2

Please sign in to comment.