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

Refactor dispute agent selection. #6776

Merged

Conversation

ghost
Copy link

@ghost ghost commented Jul 19, 2023

  • Dispute agent can be chosen randomly.
  • Eliminates internal dependencies, simplifies code.

Tests output:

ArbitratorSelectionTest > testGetRandomArbitratorFromThree() STANDARD_OUT

testArbitratorSelection with 3 arbitrators 10000 iterations, expected percentage=0.333333
arb=arb2 result=3339 percentage=0.333900
arb=arb1 result=3262 percentage=0.326200
arb=arb3 result=3399 percentage=0.339900

ArbitratorSelectionTest > testGetRandomArbitratorFromFour() STANDARD_OUT

testArbitratorSelection with 4 arbitrators 1000 iterations, expected percentage=0.250000
arb=arb2 result=236 percentage=0.236000
arb=arb1 result=243 percentage=0.243000
arb=arb4 result=267 percentage=0.267000
arb=arb3 result=254 percentage=0.254000

ArbitratorSelectionTest > testGetRandomArbitratorFromOne() STANDARD_OUT

testArbitratorSelection with 1 arbitrators 10 iterations, expected percentage=1.000000
arb=arb1 result=10 percentage=1.000000

ArbitratorSelectionTest > testGetRandomArbitratorFromTwo() STANDARD_OUT

testArbitratorSelection with 2 arbitrators 10000 iterations, expected percentage=0.500000
arb=arb2 result=5060 percentage=0.506000
arb=arb1 result=4940 percentage=0.494000

@ghost ghost force-pushed the refactor_arbitrator_selection branch from 3c14a28 to 2d34043 Compare July 19, 2023 16:19
Copy link
Contributor

@alvasw alvasw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit
Looks good!

Here are some suggestions:
We only need to iterate once over the disputeAgentManager.getObservableMap() by using Collections.shuffle(disputeAgents). Furthermore, we can use getRandomMediator in the tests and get rid of the getRandomDisputeAgent method. I pushed an example to my repository. See: alvasw@ddfae00

Co-Authored-By: Alva Swanson <alvasw@protonmail.com>
Copy link
Contributor

@alvasw alvasw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

Copy link
Contributor

@alejandrogarcia83 alejandrogarcia83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@alejandrogarcia83 alejandrogarcia83 merged commit 05bc477 into bisq-network:master Jul 20, 2023
13 checks passed
@alejandrogarcia83 alejandrogarcia83 added this to the v1.9.13 milestone Jul 20, 2023
@ghost ghost mentioned this pull request Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants