git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 026b99c4df17c82be9f9255083a7271d8d3437b6

implements blockHash in the interface

wanderer authored on 8/16/2016, 9:06:09 PM
Alex Beregszaszi committed on 8/17/2016, 2:15:27 AM
Parent: ffe3b1001d995030b9b814805b54e159d5d388eb

Files changed

interface.jschanged
interface.jsView
@@ -186,9 +186,9 @@
186186 */
187187 extCodeCopy (addressOffset, offset, codeOffset, length) {
188188 const address = new Address(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES))
189189 let code = this.environment.getCode(address)
190- code = new Uint8Array(code, codeOffset, length)
190+ code = new Uint8Array(code, codeOffset, length)
191191 this.setMemory(offset, length, code)
192192 }
193193
194194 /**
@@ -204,9 +204,16 @@
204204 * @param {integer} number which block to load
205205 * @param {integer} offset the offset to load the hash into
206206 */
207207 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+ }
209216 this.setMemory(offset, 32, hash)
210217 }
211218
212219 /**

Built with git-ssb-web