Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow 4 refreshes per trade #3980

Merged
merged 1 commit into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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