Commit 90958f4d99b2d6238ce08db7e2d226b9f5bc5ea8
changed block difficultly to 256 -bits and adds callDataCopy256
wanderer authored on 8/22/2016, 7:11:01 PMAlex Beregszaszi committed on 8/23/2016, 12:19:29 AM
Parent: 7ac30606a95e63244d5792a232ae3d353b000054
Files changed
block.js | changed |
interface.js | changed |
block.js | ||
---|---|---|
@@ -5,8 +5,9 @@ | ||
5 | 5 | // |
6 | 6 | const Address = require('./address.js') |
7 | 7 | const ethUtil = require('ethereumjs-util') |
8 | 8 | const OldBlock = require('ethereumjs-block') |
9 | +const U256 = require('./u256.js') | |
9 | 10 | |
10 | 11 | module.exports = class Block extends OldBlock { |
11 | 12 | get number () { |
12 | 13 | return ethUtil.bufferToInt(this.header.number) |
@@ -16,9 +17,9 @@ | ||
16 | 17 | return ethUtil.bufferToInt(this.header.gasLimit) |
17 | 18 | } |
18 | 19 | |
19 | 20 | get difficulty () { |
20 | - return ethUtil.bufferToInt(this.header.difficulty) | |
21 | + return new U256(this.header.difficulty) | |
21 | 22 | } |
22 | 23 | |
23 | 24 | get timestamp () { |
24 | 25 | return ethUtil.bufferToInt(this.header.timestamp) |
interface.js | ||
---|---|---|
@@ -23,8 +23,9 @@ | ||
23 | 23 | 'getCaller', |
24 | 24 | 'getCallValue', |
25 | 25 | 'getCallDataSize', |
26 | 26 | 'callDataCopy', |
27 | + 'callDataCopy256', | |
27 | 28 | 'getCodeSize', |
28 | 29 | 'codeCopy', |
29 | 30 | 'getExternalCodeSize', |
30 | 31 | 'externalCodeCopy', |
@@ -163,8 +164,21 @@ | ||
163 | 164 | this.setMemory(offset, length, callData) |
164 | 165 | } |
165 | 166 | |
166 | 167 | /** |
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 | + /** | |
167 | 181 | * Gets the size of code running in current environment. |
168 | 182 | * @return {interger} |
169 | 183 | */ |
170 | 184 | getCodeSize () { |
@@ -277,12 +291,12 @@ | ||
277 | 291 | /** |
278 | 292 | * Get the block’s difficulty. |
279 | 293 | * @return {integer} |
280 | 294 | */ |
281 | - getBlockDifficulty () { | |
295 | + getBlockDifficulty (offset) { | |
282 | 296 | this.takeGas(2) |
283 | 297 | |
284 | - return this.environment.block.difficulty | |
298 | + this.setMemory(offset, 32, this.environment.block.difficulty.toBuffer()) | |
285 | 299 | } |
286 | 300 | |
287 | 301 | /** |
288 | 302 | * Get the block’s gas limit. |
Built with git-ssb-web