git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 90958f4d99b2d6238ce08db7e2d226b9f5bc5ea8

changed block difficultly to 256 -bits and adds callDataCopy256

wanderer authored on 8/22/2016, 7:11:01 PM
Alex Beregszaszi committed on 8/23/2016, 12:19:29 AM
Parent: 7ac30606a95e63244d5792a232ae3d353b000054

Files changed

block.jschanged
interface.jschanged
block.jsView
@@ -5,8 +5,9 @@
55 //
66 const Address = require('./address.js')
77 const ethUtil = require('ethereumjs-util')
88 const OldBlock = require('ethereumjs-block')
9+const U256 = require('./u256.js')
910
1011 module.exports = class Block extends OldBlock {
1112 get number () {
1213 return ethUtil.bufferToInt(this.header.number)
@@ -16,9 +17,9 @@
1617 return ethUtil.bufferToInt(this.header.gasLimit)
1718 }
1819
1920 get difficulty () {
20- return ethUtil.bufferToInt(this.header.difficulty)
21+ return new U256(this.header.difficulty)
2122 }
2223
2324 get timestamp () {
2425 return ethUtil.bufferToInt(this.header.timestamp)
interface.jsView
@@ -23,8 +23,9 @@
2323 'getCaller',
2424 'getCallValue',
2525 'getCallDataSize',
2626 'callDataCopy',
27+ 'callDataCopy256',
2728 'getCodeSize',
2829 'codeCopy',
2930 'getExternalCodeSize',
3031 'externalCodeCopy',
@@ -163,8 +164,21 @@
163164 this.setMemory(offset, length, callData)
164165 }
165166
166167 /**
168+ * Copys the input data in current environment to memory. This pertains to
169+ * the input data passed with the message call instruction or transaction.
170+ * @param {integer} offset the offset in memory to load into
171+ * @param {integer} dataOffset the offset in the input data
172+ * @param {integer} length the length of data to copy
173+ */
174+ callDataCopy256 (offset, dataOffset) {
175+ this.takeGas(3)
176+ const callData = this.environment.callData.slice(dataOffset, dataOffset + 32)
177+ this.setMemory(offset, 32, callData)
178+ }
179+
180+ /**
167181 * Gets the size of code running in current environment.
168182 * @return {interger}
169183 */
170184 getCodeSize () {
@@ -277,12 +291,12 @@
277291 /**
278292 * Get the block’s difficulty.
279293 * @return {integer}
280294 */
281- getBlockDifficulty () {
295+ getBlockDifficulty (offset) {
282296 this.takeGas(2)
283297
284- return this.environment.block.difficulty
298+ this.setMemory(offset, 32, this.environment.block.difficulty.toBuffer())
285299 }
286300
287301 /**
288302 * Get the block’s gas limit.

Built with git-ssb-web