mirror of
https://github.com/bisq-network/bisq.git
synced 2025-03-13 11:09:10 +01:00
Add CheckIfDaoStateIsInSync task in trade protocol as first task
Add ifDaoStateIsInSync method to DaoFacade Add ifDaoStateIsInSync to logs if DPT verification fails
This commit is contained in:
parent
8fd8586923
commit
f99d2f00ce
8 changed files with 69 additions and 4 deletions
|
@ -813,4 +813,9 @@ public class DaoFacade implements DaoSetupService {
|
|||
public boolean isParseBlockChainComplete() {
|
||||
return daoStateService.isParseBlockChainComplete();
|
||||
}
|
||||
|
||||
public boolean isDaoStateIsInSync() {
|
||||
return !daoStateMonitoringService.isInConflictWithSeedNode() &&
|
||||
!daoStateMonitoringService.isDaoStateBlockChainNotConnecting();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import bisq.core.trade.protocol.bisq_v1.messages.DepositTxAndDelayedPayoutTxMess
|
|||
import bisq.core.trade.protocol.bisq_v1.messages.InputsForDepositTxRequest;
|
||||
import bisq.core.trade.protocol.bisq_v1.messages.PayoutTxPublishedMessage;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.ApplyFilter;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.CheckIfDaoStateIsInSync;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.TradeTask;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.buyer.BuyerFinalizesDelayedPayoutTx;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.buyer.BuyerProcessDelayedPayoutTxSignatureRequest;
|
||||
|
@ -71,6 +72,7 @@ public class BuyerAsMakerProtocol extends BuyerProtocol implements MakerProtocol
|
|||
.with(message)
|
||||
.from(peer))
|
||||
.setup(tasks(
|
||||
CheckIfDaoStateIsInSync.class,
|
||||
MakerProcessesInputsForDepositTxRequest.class,
|
||||
ApplyFilter.class,
|
||||
getVerifyPeersFeePaymentClass(),
|
||||
|
|
|
@ -27,6 +27,7 @@ import bisq.core.trade.protocol.bisq_v1.messages.DepositTxAndDelayedPayoutTxMess
|
|||
import bisq.core.trade.protocol.bisq_v1.messages.InputsForDepositTxResponse;
|
||||
import bisq.core.trade.protocol.bisq_v1.messages.PayoutTxPublishedMessage;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.ApplyFilter;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.CheckIfDaoStateIsInSync;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.TradeTask;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.buyer.BuyerFinalizesDelayedPayoutTx;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.buyer.BuyerProcessDelayedPayoutTxSignatureRequest;
|
||||
|
@ -77,6 +78,7 @@ public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol
|
|||
expect(phase(Trade.Phase.INIT)
|
||||
.with(TakerEvent.TAKE_OFFER))
|
||||
.setup(tasks(
|
||||
CheckIfDaoStateIsInSync.class,
|
||||
ApplyFilter.class,
|
||||
getVerifyPeersFeePaymentClass(),
|
||||
CreateTakerFeeTx.class,
|
||||
|
|
|
@ -27,6 +27,7 @@ import bisq.core.trade.protocol.bisq_v1.messages.DelayedPayoutTxSignatureRespons
|
|||
import bisq.core.trade.protocol.bisq_v1.messages.DepositTxMessage;
|
||||
import bisq.core.trade.protocol.bisq_v1.messages.InputsForDepositTxRequest;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.ApplyFilter;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.CheckIfDaoStateIsInSync;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.TradeTask;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.maker.MakerCreateAndSignContract;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.maker.MakerProcessesInputsForDepositTxRequest;
|
||||
|
@ -73,6 +74,7 @@ public class SellerAsMakerProtocol extends SellerProtocol implements MakerProtoc
|
|||
.with(message)
|
||||
.from(peer))
|
||||
.setup(tasks(
|
||||
CheckIfDaoStateIsInSync.class,
|
||||
MaybeCreateSubAccount.class,
|
||||
MakerProcessesInputsForDepositTxRequest.class,
|
||||
ApplyFilter.class,
|
||||
|
|
|
@ -26,6 +26,7 @@ import bisq.core.trade.protocol.bisq_v1.messages.CounterCurrencyTransferStartedM
|
|||
import bisq.core.trade.protocol.bisq_v1.messages.DelayedPayoutTxSignatureResponse;
|
||||
import bisq.core.trade.protocol.bisq_v1.messages.InputsForDepositTxResponse;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.ApplyFilter;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.CheckIfDaoStateIsInSync;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.TradeTask;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.seller.MaybeCreateSubAccount;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.seller.SellerCreatesDelayedPayoutTx;
|
||||
|
@ -73,6 +74,7 @@ public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtoc
|
|||
.with(TakerEvent.TAKE_OFFER)
|
||||
.from(trade.getTradingPeerNodeAddress()))
|
||||
.setup(tasks(
|
||||
CheckIfDaoStateIsInSync.class,
|
||||
MaybeCreateSubAccount.class,
|
||||
ApplyFilter.class,
|
||||
getVerifyPeersFeePaymentClass(),
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.core.trade.protocol.bisq_v1.tasks;
|
||||
|
||||
import bisq.core.trade.model.bisq_v1.Trade;
|
||||
|
||||
import bisq.common.taskrunner.TaskRunner;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
@Slf4j
|
||||
public class CheckIfDaoStateIsInSync extends TradeTask {
|
||||
public CheckIfDaoStateIsInSync(TaskRunner<Trade> taskHandler, Trade trade) {
|
||||
super(taskHandler, trade);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run() {
|
||||
try {
|
||||
runInterceptHook();
|
||||
|
||||
checkArgument(processModel.getDaoFacade().isDaoStateIsInSync(), "DAO state is not in sync with seed nodes");
|
||||
} catch (Throwable t) {
|
||||
failed(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -75,12 +75,16 @@ public class BuyerVerifiesFinalDelayedPayoutTx extends TradeTask {
|
|||
lockTime);
|
||||
|
||||
if (!buyersDelayedPayoutTx.getTxId().equals(finalDelayedPayoutTx.getTxId())) {
|
||||
|
||||
String errorMsg = "TxIds of buyersDelayedPayoutTx and finalDelayedPayoutTx must be the same.";
|
||||
log.error("{} \nbuyersDelayedPayoutTx={}, \nfinalDelayedPayoutTx={}, " +
|
||||
"\nBtcWalletService.chainHeight={}, \nDaoState.chainHeight={}",
|
||||
"\nBtcWalletService.chainHeight={}, " +
|
||||
"\nDaoState.chainHeight={}, " +
|
||||
"\nisDaoStateIsInSync={}",
|
||||
errorMsg, buyersDelayedPayoutTx, finalDelayedPayoutTx,
|
||||
processModel.getBtcWalletService().getBestChainHeight(),
|
||||
processModel.getDaoFacade().getChainHeight());
|
||||
processModel.getDaoFacade().getChainHeight(),
|
||||
processModel.getDaoFacade().isDaoStateIsInSync());
|
||||
|
||||
throw new IllegalArgumentException(errorMsg);
|
||||
}
|
||||
|
|
|
@ -68,10 +68,13 @@ public class BuyerVerifiesPreparedDelayedPayoutTx extends TradeTask {
|
|||
if (!buyersPreparedDelayedPayoutTx.getTxId().equals(sellersPreparedDelayedPayoutTx.getTxId())) {
|
||||
String errorMsg = "TxIds of buyersPreparedDelayedPayoutTx and sellersPreparedDelayedPayoutTx must be the same.";
|
||||
log.error("{} \nbuyersPreparedDelayedPayoutTx={}, \nsellersPreparedDelayedPayoutTx={}, " +
|
||||
"\nBtcWalletService.chainHeight={}, \nDaoState.chainHeight={}",
|
||||
"\nBtcWalletService.chainHeight={}, " +
|
||||
"\nDaoState.chainHeight={}, " +
|
||||
"\nisDaoStateIsInSync={}",
|
||||
errorMsg, buyersPreparedDelayedPayoutTx, sellersPreparedDelayedPayoutTx,
|
||||
processModel.getBtcWalletService().getBestChainHeight(),
|
||||
processModel.getDaoFacade().getChainHeight());
|
||||
processModel.getDaoFacade().getChainHeight(),
|
||||
processModel.getDaoFacade().isDaoStateIsInSync());
|
||||
throw new IllegalArgumentException(errorMsg);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue