make genesis block configurable. fixes #41

This commit is contained in:
Joris Bontje 2015-07-29 15:49:02 +02:00
parent 2bd14e5c6c
commit f1a02711bd
12 changed files with 55 additions and 10 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
node_modules
TODO
.node-xmlhttprequest-sync-*

View File

@ -3,6 +3,7 @@ development:
rpc_port: 8101
rpc_whitelist: "*"
minerthreads: 1
genesis_block: config/genesis.json
datadir: /tmp/embark
mine_when_needed: true
gas_limit: 500000

View File

@ -0,0 +1,12 @@
{
"nonce": "0x0000000000000042",
"difficulty": "0x40000",
"alloc": {
},
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x",
"gasLimit": "0x4c4b40"
}

View File

@ -3,6 +3,7 @@ development:
rpc_port: 8101
rpc_whitelist: "*"
minerthreads: 1
genesis_block: config/genesis.json
datadir: /tmp/embark
mine_when_needed: true
gas_limit: 500000

12
demo/config/genesis.json Normal file
View File

@ -0,0 +1,12 @@
{
"nonce": "0x0000000000000042",
"difficulty": "0x40000",
"alloc": {
},
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x",
"gasLimit": "0x4c4b40"
}

View File

@ -3,6 +3,7 @@ development:
rpc_port: 8101
rpc_whitelist: "*"
minerthreads: 1
genesis_block: config/genesis.json
datadir: /tmp/embark
mine_when_needed: true
gas_limit: 500000

View File

@ -0,0 +1,12 @@
{
"nonce": "0x0000000000000042",
"difficulty": "0x40000",
"alloc": {
},
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x",
"gasLimit": "0x4c4b40"
}

View File

@ -25,6 +25,9 @@ Blockchain.prototype.generate_basic_command = function() {
}
cmd += "--mine ";
if (config.genesisBlock !== void 0) {
cmd += "--genesis=\"" + config.genesisBlock + "\" ";
}
//TODO: this should be configurable
cmd += "--maxpeers 0 ";
@ -96,4 +99,3 @@ Blockchain.prototype.startChain = function(use_tmp) {
}
module.exports = Blockchain

View File

@ -38,6 +38,7 @@ BlockchainConfig.prototype.config = function(env) {
gasPrice: config.gas_price || 10000000000000,
rpcWhitelist: config.rpc_whitelist,
minerthreads: config.minerthreads,
genesisBlock: config.genesis_block,
datadir: config.datadir,
networkId: networkId,
port: config.port || "30303",
@ -50,4 +51,3 @@ BlockchainConfig.prototype.config = function(env) {
};
module.exports = BlockchainConfig;

View File

@ -10,7 +10,7 @@ describe('embark.blockchain', function() {
var blockchain = new Blockchain(blockchainConfig);
it('should return correct cmd', function() {
assert.strictEqual(blockchain.generate_basic_command(), "geth --datadir=\"/tmp/embark\" --logfile=\"/tmp/embark.log\" --port 30303 --rpc --rpcport 8101 --networkid "+blockchainConfig.networkId+" --rpccorsdomain \"*\" --minerthreads \"1\" --mine --maxpeers 0 --password config/password ");
assert.strictEqual(blockchain.generate_basic_command(), "geth --datadir=\"/tmp/embark\" --logfile=\"/tmp/embark.log\" --port 30303 --rpc --rpcport 8101 --networkid "+blockchainConfig.networkId+" --rpccorsdomain \"*\" --minerthreads \"1\" --mine --genesis=\"config/genesis.json\" --maxpeers 0 --password config/password ");
});
});

View File

@ -41,6 +41,7 @@ describe('embark.config.blockchain', function() {
rpc_whitelist: "*",
network_id: 0,
minerthreads: 1,
genesis_block: 'config/genesis.json',
datadir: '/tmp/embark',
mine_when_needed: true,
gas_limit: 123,
@ -63,6 +64,7 @@ describe('embark.config.blockchain', function() {
gasPrice: 100,
rpcWhitelist: "*",
minerthreads: 1,
genesisBlock: 'config/genesis.json',
datadir: '/tmp/embark',
networkId: 0,
port: "30303",
@ -103,6 +105,7 @@ describe('embark.config.blockchain', function() {
gasPrice: 10000000000000,
rpcWhitelist: "*",
minerthreads: 1,
genesisBlock: undefined,
datadir: '/tmp/embark',
networkId: 0,
port: "30303",
@ -122,4 +125,3 @@ describe('embark.config.blockchain', function() {
});
});

View File

@ -3,6 +3,7 @@ development:
rpc_port: 8101
rpc_whitelist: "*"
minerthreads: 1
genesis_block: config/genesis.json
datadir: /tmp/embark
mine_when_needed: true
gas_limit: 500000