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

cryptonote_core: skip block notify on blockchain switching rollback #6347

Merged
merged 1 commit into from
Apr 4, 2020

Conversation

xiphon
Copy link
Contributor

@xiphon xiphon commented Feb 19, 2020

No description provided.

@moneromooo-monero
Copy link
Collaborator

Presumably you already got notifications for the blocks in the alt chain that untimately failed, right ? If so, it seems to make more sense to not omit those notifications ?

@xiphon xiphon force-pushed the rollback-block-notify branch from e0e8475 to fcb06f7 Compare February 19, 2020 16:19
@xiphon
Copy link
Contributor Author

xiphon commented Feb 19, 2020

Updated.

  1. Failed to switch to alt chain - don't send any notification
  2. Successfully switched to alt chain - send 1) reorg notification and 2) block notification for each alt chain block

@@ -1044,6 +1044,11 @@ bool Blockchain::switch_to_alternative_blockchain(std::list<block_extended_info>
reorg_notify->notify("%s", std::to_string(split_height).c_str(), "%h", std::to_string(m_db->height()).c_str(),
"%n", std::to_string(m_db->height() - split_height).c_str(), "%d", std::to_string(discarded_blocks).c_str(), NULL);

std::shared_ptr<tools::Notify> block_notify = m_block_notify;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see any benefit to copying the std::shared_ptr in the original code. The copy is not atomic/thread-safe (with respect to assignment of the same std::shared_ptr object) unless the appropriate functions are used. Was std::atomic_store and std::atomic_load intended to be used here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry ping @moneromooo-monero

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I thought the pointer copy was atomic.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the risks of issue here is low due to the init process. But something to remember for sure.

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