Allow same-node Alice tradebot entries for AT offers#293
Open
QuickMythril wants to merge 1 commit intoQortal:masterfrom
Open
Allow same-node Alice tradebot entries for AT offers#293QuickMythril wants to merge 1 commit intoQortal:masterfrom
QuickMythril wants to merge 1 commit intoQortal:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This fixes the “same-node buy fails for a different local account” bug (#292). Today, any local trade-bot entry for an AT blocks a response, so Bob’s offer entry prevents a different account on the same node from accepting the offer. That’s a node-local guard and not account-aware, which is why same-node trades fail.
Reason for fix
We only need to prevent multiple concurrent Alice responses for the same AT. A Bob offer and a single Alice response can coexist safely. Scoping the guard to active ALICE entries preserves the safety invariant while allowing same-node trades.
Changes
src/main/java/org/qortal/repository/CrossChainRepository.java: addexistsAliceTradeWithAtExcludingStates(...)to support ALICE-only checks.src/main/java/org/qortal/repository/hsqldb/HSQLDBCrossChainRepository.java: implement ALICE-only existence query usingtrade_state LIKE 'ALICE_%'while still excluding end states.src/main/java/org/qortal/controller/tradebot/TradeBot.java: use the ALICE-only guard instartResponseandstartResponseMultipleso Bob’s entry no longer blocks a same-node Alice response.src/test/java/org/qortal/test/CrossChainRepositoryTests.java: add coverage ensuring Bob-only does not block, active Alice does block, and Alice end-state no longer blocks.Tests
mvn -q -Dtest=CrossChainRepositoryTests test