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

[WIP] Add cancel trade feature #4514

Closed
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
59860f6
Refactor: Rename method
chimp1984 Sep 10, 2020
3ef7599
Refactor: Move initialize before activate, add separator lines
chimp1984 Sep 10, 2020
2bfdcfb
Refactor: Move methods
chimp1984 Sep 10, 2020
1159836
Refactor: Make initialize public
chimp1984 Sep 10, 2020
59e4e98
Functional change: Do not call initialize in constructor
chimp1984 Sep 10, 2020
17ba6e9
Refactor: Do check for trade.getPayoutTx() == null at beginning and r…
chimp1984 Sep 10, 2020
1e2ea6d
Refactor: Move check for trade.getPayoutTx() == null to sub classes
chimp1984 Sep 10, 2020
88cd5b2
Refactor: Rename class for more generic use cases.
chimp1984 Sep 10, 2020
5f1d5f3
Functional change: Avoid possibility to add duplicated tradable to list
chimp1984 Sep 10, 2020
1f2241f
Add cancel trade domain
chimp1984 Sep 10, 2020
5dd81cb
Refactor: Rename id to tradeId
chimp1984 Sep 10, 2020
d50d825
Remove unused field
chimp1984 Sep 10, 2020
25db775
Refactor: Rename CanceledTradeState to HandleCancelTradeRequestState
chimp1984 Sep 10, 2020
68add41
Add RequestCancelTradeState
chimp1984 Sep 10, 2020
b28f507
Separate states completed
chimp1984 Sep 10, 2020
8236ce2
Remove cancel support at step 3. Once buyer has send payment we do
chimp1984 Sep 10, 2020
6f5e386
Rename RequestCancelTradePresentation and HandleCancelTradeRequestPre…
chimp1984 Sep 10, 2020
79a9ac9
Refactor: Move classes
chimp1984 Sep 10, 2020
7313458
Refactor: Rename enums
chimp1984 Sep 10, 2020
e483efd
Refactor: Move enums to seller and buyer trade
chimp1984 Sep 10, 2020
3e85ff6
Refactor: Rename enums
chimp1984 Sep 10, 2020
a134c74
Split buyer seller protocol classes.
chimp1984 Sep 10, 2020
fa00593
Refactor: Move method, improve comments
chimp1984 Sep 10, 2020
b4d9807
Refactor: Move message classes to new package
chimp1984 Sep 10, 2020
9ee586f
Refactor: Move dispute message classes to new dispute package
chimp1984 Sep 10, 2020
482c73a
Refactor: Rename package
chimp1984 Sep 10, 2020
54e4a08
Only log error at DelayedPayoutTx check if deposit tx is not null
chimp1984 Sep 10, 2020
dce1873
Merge branch 'master_upstream' into add-cancel-trade-feature
chimp1984 Sep 10, 2020
eae6a46
Improve text, dont use action style for button
chimp1984 Sep 10, 2020
4985435
Refactor: Rename classes
chimp1984 Sep 10, 2020
aa6721a
Getting the feature polished... Many small changes...
chimp1984 Sep 10, 2020
5148c77
Mark refreshInterval transient. Move static MAX_REFRESH_INTERVAL to top
chimp1984 Sep 10, 2020
9e917d5
Use more convenient TimeUnit.HOURS.toMillis API
chimp1984 Sep 10, 2020
5c62454
Add comments about wrong usage of trade protocol
chimp1984 Sep 10, 2020
8885e85
Move cancelTrade states to sub classes
chimp1984 Sep 10, 2020
f71b2fb
Update comments, remove todo
chimp1984 Sep 10, 2020
9047ab9
Remove mailbox msg at failure cases in trade protocol tasks
chimp1984 Sep 10, 2020
82fd068
Remove commented out code.
chimp1984 Sep 11, 2020
0f7f3d2
Try to get Codacy to ignore lines
chimp1984 Sep 11, 2020
0e9540d
Remove constructor as Codacy does not like empty constructors.
chimp1984 Sep 11, 2020
6b5e08d
Moved witness signing and msg sending to trade protocol task
chimp1984 Sep 11, 2020
e3c6aa2
Refactoring: Rename param to avoid confusion with allowBroadcast and
chimp1984 Sep 11, 2020
286402f
Add comments
chimp1984 Sep 11, 2020
f819a0d
Let signer broadcast signedWitness as well.
chimp1984 Sep 11, 2020
396c6f4
Use a deterministic id instead of uid
chimp1984 Sep 11, 2020
93f24a4
Refactor: Use SendMailboxMessageTask to avoid duplicated code
chimp1984 Sep 11, 2020
ab2e54f
Resend payment started message as long we dont get an ACK
chimp1984 Sep 11, 2020
873d2cf
Start BuyerSendCounterCurrencyTransferStartedMessage at startup again
chimp1984 Sep 11, 2020
00bb8db
Add comment
chimp1984 Sep 11, 2020
2b05638
Remove dev test value
chimp1984 Sep 11, 2020
bf3ce34
Refactor: Rename signAccountAgeWitness to signAndPublishAccountAgeWit…
chimp1984 Sep 11, 2020
5e46366
Remove duplicate broadcast of witness data
chimp1984 Sep 11, 2020
c2296d4
Send witness with PayoutTxPublishedMessage
chimp1984 Sep 11, 2020
37496c2
Remove refresh button
chimp1984 Sep 11, 2020
d53f5ed
Refactor: Rename display strings
chimp1984 Sep 11, 2020
1742da3
Refactor: Move display strings
chimp1984 Sep 11, 2020
8f7fe51
Merge branch 'master_upstream' into add-cancel-trade-feature
chimp1984 Sep 11, 2020
71e452f
Apply suggestions from code review. Add todos for required changes
chimp1984 Sep 17, 2020
7318b10
Merge branch 'master_upstream' into add-cancel-trade-feature
chimp1984 Sep 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -494,7 +494,10 @@ void addToMap(SignedWitness signedWitness) {
private void publishSignedWitness(SignedWitness signedWitness) {
if (!signedWitnessMap.containsKey(signedWitness.getHashAsByteArray())) {
log.info("broadcast signed witness {}", signedWitness.toString());
p2PService.addPersistableNetworkPayload(signedWitness, false);
// We set reBroadcast to true. The signer has broadcast the signedWitness as
// well, so it might be that we have received the data already, but we prefer to re-broadcast
// to achieve better resilience.
p2PService.addPersistableNetworkPayload(signedWitness, true);
addToMap(signedWitness);
}
}
Expand Down
Expand Up @@ -227,6 +227,9 @@ public void onFiatPaymentReceived(ResultHandler resultHandler, ErrorMessageHandl
handleTaskRunnerFault(errorMessage);
});

// SellerSendPayoutTxPublishedMessage and SellerMaybeSignWitnessAndSendWitnessMessage are sending both a
// msg which should have been consolidated in 1 message to avoid that the peer has to process 2 messages
// arriving around the same time. This breaks the concept of a strict sequential task execution.
taskRunner.addTasks(
ApplyFilter.class,
MakerVerifyTakerAccount.class,
Expand Down
Expand Up @@ -218,6 +218,9 @@ public void onFiatPaymentReceived(ResultHandler resultHandler, ErrorMessageHandl
handleTaskRunnerFault(errorMessage);
});

// SellerSendPayoutTxPublishedMessage and SellerMaybeSignWitnessAndSendWitnessMessage are sending both a
// msg which should have been consolidated in 1 message to avoid that the peer has to process 2 messages
// arriving around the same time. This breaks the concept of a strict sequential task execution.
taskRunner.addTasks(
ApplyFilter.class,
TakerVerifyMakerAccount.class,
Expand Down
10 changes: 7 additions & 3 deletions core/src/main/java/bisq/core/trade/protocol/TradeProtocol.java
Expand Up @@ -240,9 +240,13 @@ private void handle(PeerPublishedDelayedPayoutTxMessage tradeMessage, NodeAddres
// Peer has sent a SignedWitness
///////////////////////////////////////////////////////////////////////////////////////////

// TODO this should not be in the trade protocol. The sending is done in the domain, so should be the handling of
// the msg. If it is part of the normal trade protocol we should add the sending and handling to the steps where
// it happen.
// It would be unsafe to use the TradeTaskRunner framework here as we expect the PeerPublishedDelayedPayoutTxMessage
// around the same time. The ProcessPeerPublishedDelayedPayoutTxMessage task is synchronous so there would not be
// an issue if we start another task runner and set the trade message to the process model, but if the code in
// ProcessPeerPublishedDelayedPayoutTxMessage would become async in future it would introduce inconsistent model
// data. The TradeTaskRunner framework does not support parallel/concurrent execution. The 2 messages should have been
// packed into one and the problem would have been avoided. Now it seems to be the best approach to leave the
// protocol framework and process the message in the AccountAgeWitness domain.
private void handle(TraderSignedWitnessMessage tradeMessage) {
// Publish signed witness, if it is valid and ours
processModel.getAccountAgeWitnessService().publishOwnSignedWitness(tradeMessage.getSignedWitness());
Expand Down
Expand Up @@ -90,7 +90,13 @@ protected void run() {

signedWitness = signedWitnessOptional.get();

// Message sending is handled in base class.
// The signer broadcasts as well the signedWitness. In case the receiver will not get the message we have
// better resilience that the data is in the network. We set reBroadcast to true but do not expect that the
// signedWitness exists already as we just created it.
// TODO check with @sqrrm
processModel.getP2PService().addPersistableNetworkPayload(signedWitness, true);
chimp1984 marked this conversation as resolved.
Show resolved Hide resolved

// Message sending is handled in base class (SendMailboxMessageTask).
super.run();
} catch (Throwable t) {
failed(t);
Expand Down
Expand Up @@ -479,16 +479,16 @@ public void onError(Throwable throwable) {
* be broadcast to the P2P network.
* @param payload PersistableNetworkPayload to add to the network
* @param sender local NodeAddress, if available
* @param allowReBroadcast <code>true</code> if the PersistableNetworkPayload should be rebroadcast even if it
* @param reBroadcast <code>true</code> if the PersistableNetworkPayload should be rebroadcast even if it
* already exists locally
* @return <code>true</code> if the PersistableNetworkPayload passes all validation and exists in the P2PDataStore
* on completion
*/
public boolean addPersistableNetworkPayload(PersistableNetworkPayload payload,
@Nullable NodeAddress sender,
boolean allowReBroadcast) {
boolean reBroadcast) {
return addPersistableNetworkPayload(
payload, sender, true, allowReBroadcast, false);
payload, sender, true, reBroadcast, false);
}

private boolean addPersistableNetworkPayload(PersistableNetworkPayload payload,
Expand Down