From 517ad58670ed7e1c7c130ac5e9e0af7c68811eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Pansier?= Date: Fri, 25 Nov 2022 18:04:45 +0100 Subject: [PATCH] fix(protocol): timestamp verification is wrong (#155) --- src/node/protocol/blockchain.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/protocol/blockchain.go b/src/node/protocol/blockchain.go index 12fe7d7b..f86a41ca 100644 --- a/src/node/protocol/blockchain.go +++ b/src/node/protocol/blockchain.go @@ -200,7 +200,7 @@ func (blockchain *Blockchain) getValidBlocks(neighborBlocks []*neighborhood.Bloc if currentBlockTimestamp+blockchain.validationTimer.Nanoseconds() < transaction.Timestamp() { return nil, fmt.Errorf("a neighbor block transaction timestamp is too far in the future, transaction: %v", transaction) } - if transaction.Timestamp() < neighborBlocks[len(neighborBlocks)-2].Timestamp { + if i > 1 && transaction.Timestamp() < neighborBlocks[i-1].Timestamp { return nil, fmt.Errorf("a neighbor block transaction timestamp is too old, transaction: %v", transaction) } }