From 31fbb4423ee34bbb68c3868031ef77b04593a8ee Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Mon, 28 Nov 2016 13:08:27 +0800 Subject: [PATCH] fix: dont throw exception when linking to next block at the top of blockchain --- src/page.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/page.h b/src/page.h index d19dabf..1d2434a 100644 --- a/src/page.h +++ b/src/page.h @@ -752,7 +752,12 @@ public: crypto::hash blk_hash = core_storage->get_block_id_by_height(_blk_height); crypto::hash prev_hash = blk.prev_id; - crypto::hash next_hash = core_storage->get_block_id_by_height(_blk_height + 1); + crypto::hash next_hash = null_hash; + + if (_blk_height + 1 <= current_blockchain_height) + { + next_hash = core_storage->get_block_id_by_height(_blk_height + 1); + } bool have_next_hash = (next_hash == null_hash ? false : true); bool have_prev_hash = (prev_hash == null_hash ? false : true);