Mercurial > hg > Database > Christie
comparison src/main/java/christie/blockchain/BlockHeader.java @ 139:694ea96a557a
refactor blockchain
author | akahori |
---|---|
date | Tue, 01 Jan 2019 15:07:22 +0900 |
parents | eab161e557bd |
children | 0ef25958ac04 |
comparison
equal
deleted
inserted
replaced
134:f172c4540461 | 139:694ea96a557a |
---|---|
11 | 11 |
12 private byte[] presentHash; | 12 private byte[] presentHash; |
13 | 13 |
14 private byte[] parentHash; | 14 private byte[] parentHash; |
15 | 15 |
16 private long difficulty; | |
17 | |
18 private long number; | |
19 | |
16 private long timestamp; | 20 private long timestamp; |
17 | 21 |
18 private long nonce; | 22 private long nonce; |
19 | 23 |
20 HashUtil hashUtil = new HashUtil(); | 24 HashUtil hashUtil = new HashUtil(); |
21 | 25 |
22 public BlockHeader(byte[] parentHash, long timestamp) { | 26 public BlockHeader(byte[] parentHash, long difficulty, long number, long timestamp) { |
23 this.parentHash = parentHash; | 27 this.parentHash = parentHash; |
28 this.difficulty = difficulty; | |
29 this.number = number; | |
24 this.timestamp = timestamp; | 30 this.timestamp = timestamp; |
25 } | 31 } |
26 | 32 |
27 public byte[] getHash(boolean withNonce){ | 33 public byte[] getHash(boolean withNonce){ |
28 | 34 |
60 | 66 |
61 public byte[] getPresentHashWithoutNonce(){ | 67 public byte[] getPresentHashWithoutNonce(){ |
62 return getHash(false); | 68 return getHash(false); |
63 } | 69 } |
64 | 70 |
71 public void setTimestamp(long timestamp) { | |
72 this.timestamp = timestamp; | |
73 } | |
74 | |
65 public long getTimestamp() { | 75 public long getTimestamp() { |
66 return timestamp; | 76 return timestamp; |
67 } | 77 } |
68 | 78 |
69 public void setTimestamp(long timestamp) { | 79 public void setNonce(long nonce) { |
70 this.timestamp = timestamp; | 80 this.nonce = nonce; |
71 } | 81 } |
72 | |
73 public void setNonce(long nonce) { this.nonce = nonce; } | |
74 | 82 |
75 public long getNonce(){ | 83 public long getNonce(){ |
76 return this.nonce; | 84 return this.nonce; |
77 } | 85 } |
78 | 86 |
87 public void setNumber(long number) { | |
88 this.number = number; | |
89 } | |
90 | |
91 public long getNumber() { | |
92 return number; | |
93 } | |
94 | |
95 public void setDifficulty(long difficulty) { | |
96 this.difficulty = difficulty; | |
97 } | |
98 | |
99 public long getDifficulty() { | |
100 return difficulty; | |
101 } | |
79 } | 102 } |