Closed JeremyPansier closed 1 year ago
The verification done when adding a transaction should be done for each transaction just before creating the new block:
if len(blocks) > 2 {
if transaction.Timestamp() < blocks[len(blocks)-2].Timestamp {
err = errors.New("the transaction timestamp is invalid")
return
}
for i := len(blocks) - 2; i < len(blocks); i++ {
for _, validatedTransaction := range blocks[i].Transactions {
if transaction.Equals(validatedTransaction) {
err = errors.New("the transaction is already in the blockchain")
return
}
}
}
}
To Reproduce Steps to reproduce the behavior:
Expected behavior The new block doesn't contain the transaction.
Actual behavior The new block contains the transaction.