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] fixed block_header_utxo_loop #1506

Merged
merged 9 commits into from
Oct 27, 2022
Merged

Conversation

borngraced
Copy link
Member

fixes this comment: #1482 (comment)

@borngraced borngraced changed the title fixed block_header_utxo_loop [wip] fixed block_header_utxo_loop Oct 21, 2022
@borngraced borngraced self-assigned this Oct 21, 2022
Copy link

@sergeyboyko0791 sergeyboyko0791 left a comment

Choose a reason for hiding this comment

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

Thanks for this fix! Please fix these two notes

mm2src/coins/utxo/utxo_builder/utxo_arc_builder.rs Outdated Show resolved Hide resolved
Comment on lines 298 to 301
pub struct BlockHeaderInMemoryStorage {
pub ticker: String,
pub conn: Arc<Mutex<Connection>>,
}

Choose a reason for hiding this comment

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

This can be simplified significantly since BlockHeaderInMemoryStorage is used in tests only:

pub struct BlockHeaderInMemoryStorage {
    pub ticker: String,
    // The block headers should be ordered to be able to return the last block header.
    pub block_headers: BTreeMap<u64, BlockHeader>,
    // This can be used on [`BlockHeaderStorageOps::get_block_height_by_hash`].
    pub block_headers_by_hash: HashMap<H256, BlockHeader>,
}

Please also note that get_last_block_height should be configurable from a test. For example, at the beginning of a test you can just upload one block header with a specified height. Also there could be a field like BlockHeaderInMemoryStorage::last_block_height.

Copy link
Member Author

Choose a reason for hiding this comment

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

noted for next PR. THANKS

@shamardy shamardy self-requested a review October 26, 2022 08:41
Copy link

@sergeyboyko0791 sergeyboyko0791 left a comment

Choose a reason for hiding this comment

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

A few more changes please

mm2src/coins/utxo/utxo_builder/utxo_arc_builder.rs Outdated Show resolved Hide resolved
mm2src/coins/utxo/utxo_builder/utxo_arc_builder.rs Outdated Show resolved Hide resolved
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.

First review iteration!

mm2src/coins/utxo/utxo_builder/utxo_arc_builder.rs Outdated Show resolved Hide resolved
mm2src/coins/utxo/utxo_builder/utxo_arc_builder.rs Outdated Show resolved Hide resolved
mm2src/coins/utxo/utxo_builder/utxo_arc_builder.rs Outdated Show resolved Hide resolved
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.

Great work! Only one minor comment. I still don't get why we got No headers available error with the old code, but this PR is an improvement for sure :)

mm2src/coins/utxo/utxo_builder/utxo_arc_builder.rs Outdated Show resolved Hide resolved
@borngraced borngraced changed the title [wip] fixed block_header_utxo_loop [r2r] fixed block_header_utxo_loop Oct 27, 2022
Copy link

@sergeyboyko0791 sergeyboyko0791 left a comment

Choose a reason for hiding this comment

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

Great! Thank you for this fix!
One minor change please

shamardy
shamardy previously approved these changes Oct 27, 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.

LGTM! Thanks for the fix :)

@sergeyboyko0791
Copy link

@cipig could you please test this fix? There shouldn't be No headers available error in the log.

@cipig
Copy link
Member

cipig commented Oct 27, 2022

@cipig could you please test this fix? There shouldn't be No headers available error in the log.

Looks good, the error message is gone

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.

Re-approve

Copy link

@sergeyboyko0791 sergeyboyko0791 left a comment

Choose a reason for hiding this comment

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

Re-approve

@sergeyboyko0791 sergeyboyko0791 merged commit 20462d9 into dev Oct 27, 2022
@sergeyboyko0791 sergeyboyko0791 deleted the block_header_utxo_loop_fix branch October 27, 2022 13:52
@borngraced borngraced mentioned this pull request Feb 17, 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.

4 participants