Skip to content

Commit

Permalink
Merge pull request #2 from soyjavi/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
soyjavi authored Aug 25, 2019
2 parents 554db7f + 47aa035 commit b608808
Show file tree
Hide file tree
Showing 7 changed files with 838 additions and 366 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ That is the reason why cryptocurrencies are based on blockchains. You don't want
We will start by defining the block structure. Only the most essential properties are included at the block at this point.

* `data`: Any data that is included in the block.
* `timestamp`: A timestamp using ISO format.
* `timestamp`: A UTC timestamp using numeric format.
* `nonce` : A number of attempts to generate the correct hash.
* `hash`: A sha256 hash taken from the content of the block.
* `previousHash`: A reference to the hash of the previous block.
Expand All @@ -47,7 +47,7 @@ The code for the block structure looks like the following:
```
class Block {
constructor({
data = {}, previousHash, timestamp = new Date().toISOString(),
data = {}, previousHash, timestamp = new Date().getTime(),
} = {}) {
this.data = data;
this.nonce = 0;
Expand Down
2 changes: 1 addition & 1 deletion dist/Block.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var Block = function Block() {
difficulty = _ref$difficulty === undefined ? 0 : _ref$difficulty,
previousHash = _ref.previousHash,
_ref$timestamp = _ref.timestamp,
timestamp = _ref$timestamp === undefined ? new Date().toISOString() : _ref$timestamp,
timestamp = _ref$timestamp === undefined ? new Date().getTime() : _ref$timestamp,
fork = _ref.fork;

var _ref2 = fork || {},
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vanillachain-core",
"version": "0.1.15",
"version": "0.1.16",
"description": "A distributed database that maintains a continuously growing list of ordered records.",
"keywords": [
"blockchain",
Expand All @@ -27,8 +27,8 @@
"babel-cli": "6.26.0",
"babel-preset-env": "1.7.0",
"eslint": "5.15.2",
"eslint-config-airbnb-base": "13.1.0",
"eslint-plugin-import": "2.16.0",
"eslint-config-airbnb-base": "14.0.0",
"eslint-plugin-import": "2.18.2",
"jest": "23.6.0"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/Block.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Block = ({
data = {},
difficulty = 0,
previousHash,
timestamp = new Date().toISOString(),
timestamp = new Date().getTime(),
fork,
} = {}) => {
let { nonce = 0, hash = '' } = fork || {};
Expand Down
3 changes: 3 additions & 0 deletions src/Block.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ describe('Block', () => {

expect(block.data).toEqual({});
expect(block.nonce).toEqual(0);
expect(typeof block.nonce).toEqual('number')
expect(block.previousHash).toEqual(undefined);
expect(block.timestamp).toBeDefined();
expect(typeof block.timestamp).toEqual('number')

});

it('when data', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/calculateHash.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import calculateHash from './calculateHash';

const previousHash = 'b894bd2ef4b59974e2704ec677524f3732bb1e9018c63b0d98df4224ca59dbca';
const timestamp = new Date(1980, 10, 4, 0, 0, 0);
const timestamp = new Date(1980, 10, 4, 0, 0, 0).getTime();
const data = { hello: 'world' };
const nonce = 32;

Expand Down
Loading

0 comments on commit b608808

Please sign in to comment.