Commit 026b99c4df17c82be9f9255083a7271d8d3437b6
implements blockHash in the interface
wanderer authored on 8/16/2016, 9:06:09 PMAlex Beregszaszi committed on 8/17/2016, 2:15:27 AM
Parent: ffe3b1001d995030b9b814805b54e159d5d388eb
Files changed
interface.js | changed |
interface.js | ||
---|---|---|
@@ -186,9 +186,9 @@ | ||
186 | 186 | */ |
187 | 187 | extCodeCopy (addressOffset, offset, codeOffset, length) { |
188 | 188 | const address = new Address(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES)) |
189 | 189 | let code = this.environment.getCode(address) |
190 | - code = new Uint8Array(code, codeOffset, length) | |
190 | + code = new Uint8Array(code, codeOffset, length) | |
191 | 191 | this.setMemory(offset, length, code) |
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -204,9 +204,16 @@ | ||
204 | 204 | * @param {integer} number which block to load |
205 | 205 | * @param {integer} offset the offset to load the hash into |
206 | 206 | */ |
207 | 207 | blockHash (number, offset) { |
208 | - const hash = this.environment.getBlockHash(number) | |
208 | + const diff = this.environment.number - number | |
209 | + let hash | |
210 | + | |
211 | + if (diff > 256 || diff <= 0) { | |
212 | + hash = new Uint8Array(32) | |
213 | + } else { | |
214 | + hash = this.environment.getBlockHash(number).reverse() | |
215 | + } | |
209 | 216 | this.setMemory(offset, 32, hash) |
210 | 217 | } |
211 | 218 | |
212 | 219 | /** |
Built with git-ssb-web