Avoid potential 'attempt to add with overflow' panic (#1213)

This commit is contained in:
yuntai 2018-07-11 06:23:15 +09:00 committed by Ignotus Peverell
parent 49cbab90f6
commit ad69dae9e5

View file

@ -98,7 +98,8 @@ pub fn pow_size(
}
// otherwise increment the nonce
bh.nonce += 1;
let (res, _) = bh.nonce.overflowing_add(1);
bh.nonce = res;
// and if we're back where we started, update the time (changes the hash as
// well)