git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit a4de660ae609d19d9547c07d2c507253598aa2bf

Merge pull request #21 from ewasm/blockhash

implemented blockHash stub
wanderer authored on 8/18/2016, 2:05:56 AM
GitHub committed on 8/18/2016, 2:05:56 AM
Parent: 1258de512d97564568307c5b1f4041dd7a10820f
Parent: 5eb51da3f2ba58b98e6d220d7c90faccdb75b6b6

Files changed

environment.jschanged
package.jsonchanged
fakeBlockChain.jsadded
environment.jsView
@@ -1,11 +1,18 @@
11 const constants = require('./constants.js')
22 const U256 = require('./u256.js')
33 const Address = require('./address.js')
4+const ethUtils = require('ethereumjs-util')
5+const Block = require('ethereumjs-block')
6+const blockChain = require('./fakeBlockChain.js')
47
58 module.exports = class Environment {
69 constructor (data) {
10+ const block = new Block()
11+
712 const defaults = {
13+ block: block,
14+ number: ethUtils.bufferToInt(block.header.number),
815 // gas tank
916 gasPrice: 0,
1017 gasLimit: 1000000, // The gas limit for the block
1118 gasRefund: 0,
@@ -39,9 +46,9 @@
3946 return this.state.get(address.toString()).code
4047 }
4148
4249 getBlockHash (height) {
43- // STUB
50+ return blockChain.getBlock(height).hash()
4451 }
4552
4653 // kernal
4754 create (code, value) {
package.jsonView
@@ -36,8 +36,9 @@
3636 ]
3737 },
3838 "dependencies": {
3939 "bn.js": "^4.11.6",
40+ "ethereumjs-block": "^1.2.2",
4041 "ethereumjs-tx": "^1.1.2",
4142 "ethereumjs-util": "^4.5.0"
4243 }
4344 }
fakeBlockChain.jsView
@@ -1,0 +1,13 @@
1+const utils = require('ethereumjs-util')
2+
3+module.exports = {
4+ getBlock: (n) => {
5+ const hash = utils.sha3(new Buffer(utils.bufferToInt(n).toString()))
6+ const block = {
7+ hash: () => {
8+ return hash
9+ }
10+ }
11+ return block
12+ }
13+}

Built with git-ssb-web