Skip to content

Conversation

@UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Mar 26, 2019

No description provided.

@UdjinM6 UdjinM6 added this to the 14.0 milestone Mar 26, 2019
{
AssertLockHeld(cs_main);
BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
if (mi != mapBlockIndex.end() && mi->second != nullptr) {

Choose a reason for hiding this comment

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

Why would mi->second be nullptr?

Copy link
Author

Choose a reason for hiding this comment

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

Just a regular safety belt. We still have quite a few places with mapBlockIndex[somehash] which can potentially insert an entry if we screw some checks up somewhere (should really get rid of these [] some day). Won't hurt to double-check imo.

Choose a reason for hiding this comment

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

Ah ok, was already worried that I misunderstood mapBlockIndex when I used it in various places. An easy way to get rid of the [] is to use .at() as a replacement as it throws an exception when you try to access a non-existent item, instead of creating an new item as with []. Better to crash early in such cases.

Copy link

@codablock codablock left a comment

Choose a reason for hiding this comment

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

utACK

@UdjinM6 UdjinM6 merged commit 39ba45f into dashpay:develop Mar 27, 2019
@UdjinM6 UdjinM6 deleted the chainlockui branch November 26, 2020 11:36
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.

2 participants