From 04f62c6f5364f165e60f853b40a215c7842677f4 Mon Sep 17 00:00:00 2001 From: Jake Craige Date: Fri, 15 Sep 2017 11:12:26 -0700 Subject: [PATCH] Round the timestamp value down Since in JavaScript timestamps are done in MS, this dividing by 1000 produces a number with a decimal. By flooring it, we produce a consistent number that matches how other langauges generate timestamps. --- lib/blockchain/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockchain/index.js b/lib/blockchain/index.js index 168fabf..9fb28dd 100644 --- a/lib/blockchain/index.js +++ b/lib/blockchain/index.js @@ -104,7 +104,7 @@ class Blockchain { generateNextBlock (blockData) { const previousBlock = this.latestBlock; const nextIndex = previousBlock.index + 1; - const nextTimestamp = new Date().getTime() / 1000 + const nextTimestamp = Math.floor(new Date().getTime() / 1000); let nonce = 0; let nextHash = ''; const randSpinner = spinner.getRandomSpinner();