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

[r2r] Repeatable future #1564

Merged
merged 16 commits into from
Dec 27, 2022
Merged

[r2r] Repeatable future #1564

merged 16 commits into from
Dec 27, 2022

Conversation

sergeyboyko0791
Copy link

No description provided.

* Use the `repeatable` future as an example at `utxo_coin_builder.rs`
* Refactor `custom_futures`
* Remove `SendAll` future
* Add `Repeatable::inspect_err`
* Add the possibility to convert `Result<T, E>` into `Action<T, E>`
* Add `retry_on_err` macro that expects from the future to return a result
@sergeyboyko0791 sergeyboyko0791 linked an issue Dec 4, 2022 that may be closed by this pull request
@sergeyboyko0791 sergeyboyko0791 changed the title [wip] Repeatable future [r2r] Repeatable future Dec 5, 2022
Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this very useful feature. Just one question and a small change :)

mm2src/coins/utxo/spv.rs Show resolved Hide resolved
mm2src/coins/utxo/utxo_common.rs Show resolved Hide resolved
mm2src/common/custom_futures/repeatable/mod.rs Outdated Show resolved Hide resolved
@sergeyboyko0791 sergeyboyko0791 changed the title [r2r] Repeatable future [wip] Repeatable future Dec 6, 2022
@sergeyboyko0791 sergeyboyko0791 changed the title [wip] Repeatable future [r2r] Repeatable future Dec 19, 2022
@sergeyboyko0791
Copy link
Author

@shamardy @borngraced @laruh @caglaryucekaya, PR is ready for the review :)

while now_ms() / 1000 < wait_until {
Timer::sleep(3.).await;
// Let the storage to be initialized for the given coin.
Timer::sleep(1.).await;
Copy link
Member

Choose a reason for hiding this comment

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

you changed the time?? why tho?

Copy link
Author

Choose a reason for hiding this comment

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

I've left the sleep timeout between attempts the same - 3 seconds as before:

.repeat_every(Duration::from_secs(3))

But as you can see (before my changes), the sleep timer was at the beginning of this function (i.e. before the first attempt). It's required to let the storage to initialize everything it needs before the first my_tx_history_v2_impl attempt.
repeatable doesn't allow to sleep before the first attempt, so I decided to put a sleep at the beginning of this function.
It's enough to sleep for 1 second to let the storage to initialize all required SQL tables.

Copy link
Member

Choose a reason for hiding this comment

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

gotcha 👌🏼

borngraced
borngraced previously approved these changes Dec 19, 2022
Copy link
Member

@borngraced borngraced left a comment

Choose a reason for hiding this comment

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

GREAT! looks very good.

just a thought and question.

laruh
laruh previously approved these changes Dec 20, 2022
Copy link
Member

@laruh laruh left a comment

Choose a reason for hiding this comment

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

Awesome 🔥
I have just small suggestions :)

mm2src/common/custom_futures/repeatable.rs Outdated Show resolved Hide resolved
mm2src/common/custom_futures/repeatable.rs Outdated Show resolved Hide resolved
@borngraced borngraced self-requested a review December 20, 2022 11:21
borngraced
borngraced previously approved these changes Dec 20, 2022
shamardy
shamardy previously approved these changes Dec 20, 2022
Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

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

🔥

@artemii235 artemii235 self-requested a review December 22, 2022 10:15
Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

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

One question, but it's a major one 🙂

mm2src/coins/utxo/utxo_builder/utxo_coin_builder.rs Outdated Show resolved Hide resolved
Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

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

Next review iteration 🙂

mm2src/common/custom_futures/repeatable.rs Outdated Show resolved Hide resolved
mm2src/common/custom_futures/repeatable.rs Show resolved Hide resolved
mm2src/common/custom_futures/repeatable.rs Outdated Show resolved Hide resolved
mm2src/common/custom_futures/repeatable.rs Outdated Show resolved Hide resolved
mm2src/common/custom_futures/repeatable.rs Outdated Show resolved Hide resolved
mm2src/common/custom_futures/repeatable.rs Outdated Show resolved Hide resolved
* Allow the user to specify only `until_ms`
* Avoid declaring `exec_fut: F` and `repeat_every: Duration` optional
* Add `RepeatUntil` enum
* Set the default `repeat_every` to 1s
* Panic on `total_attempts == 0`
@sergeyboyko0791 sergeyboyko0791 changed the title [r2r] Repeatable future [wip] Repeatable future Dec 26, 2022
@sergeyboyko0791 sergeyboyko0791 changed the title [wip] Repeatable future [r2r] Repeatable future Dec 27, 2022
@sergeyboyko0791
Copy link
Author

@artemii235 the PR is ready for the next review

Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

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

Last note 🙂

mm2src/common/custom_futures/repeatable.rs Outdated Show resolved Hide resolved
Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

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

🔥

@artemii235 artemii235 merged commit 9f1f4e9 into dev Dec 27, 2022
@artemii235 artemii235 deleted the repeatable-future branch December 27, 2022 13:30
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.

Consider adding repeatable future PoC
6 participants