Skip to content

Commit e86cf0c

Browse files
committed
Change array style lookup for map to find
Also add not found set fees to zero.
1 parent 041ceba commit e86cf0c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/gridcoin/mrc.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,12 @@ CAmount MRC::ComputeMRCFee() const
112112
const int64_t last_reward_time = account.LastRewardTime();
113113

114114
// Get the block index of the head of the chain at the time the MRC was filled out.
115-
CBlockIndex* prev_block_pindex = mapBlockIndex[m_last_block_hash];
115+
auto block_index_element = mapBlockIndex.find(m_last_block_hash);
116+
117+
// If the mrc last block hash is not in the block index map, just return zero.
118+
if (block_index_element == mapBlockIndex.end()) return fee;
119+
120+
CBlockIndex* prev_block_pindex = block_index_element->second;
116121

117122
int64_t payment_time = prev_block_pindex->nTime;
118123

0 commit comments

Comments
 (0)