質問編集履歴
1
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -67,3 +67,41 @@
|
|
67
67
|
|
68
68
|
|
69
69
|
```
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
※追記:
|
76
|
+
|
77
|
+
validChainの書き方間違えてました。質問の本質ではないですが、修正内容載せておきます
|
78
|
+
|
79
|
+
```
|
80
|
+
|
81
|
+
validChain(chain) {
|
82
|
+
|
83
|
+
let _previousHash = this.hash(GENESIS_ADDRESS);
|
84
|
+
|
85
|
+
return chain.every((block) => {
|
86
|
+
|
87
|
+
if(block.previousHash !== _previousHash) {
|
88
|
+
|
89
|
+
return false;
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
if(!this.validProof(block.transactions, _previousHash, block.nonce)) {
|
94
|
+
|
95
|
+
return false;
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
_previousHash = this.hash(block);
|
100
|
+
|
101
|
+
return true;
|
102
|
+
|
103
|
+
});
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
```
|