Skip to content

Instantly share code, notes, and snippets.

@critesjosh
Created September 6, 2017 10:50
Show Gist options
  • Save critesjosh/2dc2142b810f7e9e5251d245a6244cee to your computer and use it in GitHub Desktop.
Save critesjosh/2dc2142b810f7e9e5251d245a6244cee to your computer and use it in GitHub Desktop.
geth attach ipc:/home/josh/.ethereum/net42/geth.ipc
{
"config": {
"chainId": 42,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash":"0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0
},
"nonce": "0x0000000000000042",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x00",
"gasLimit": "0x4c4b40",
"difficulty": "0x0400",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
}
}
#!/bin/bash
# Run this once, but it does not hurt to run it every time
geth --datadir ~/.ethereum/net42 init ~/Documents/genesis42.json
# Run this every time you start your Geth "42", and add flags here as you need
geth --datadir ~/.ethereum/net42 --nodiscover --networkid 42 --maxpeers 0 --rpc --rpcport 8545 --rpcaddr 0.0.0.0 --rpccorsdomain "*" --rpcapi "eth,net,web3,personal,debug" js ~/Documents/conditional_mining.js
/usr/local/bin/mist --rpc ~/.ethereum/net42/geth.ipc
geth --datadir=~/.ethereum/net42 --networkid 42 init 42-genesis.json
web3.eth.filter("pending").watch(function() {
if (eth.mining) return;
console.log(new Date() + "-- Transactions detected, so starting mining.");
miner.start(1);
});
web3.eth.filter('latest', function(error, result) {
if (txpool.status.pending || !eth.mining) return;
console.log(new Date() + "-- No pending transactions, so stopping mining.");
miner.stop();
});
if (txpool.status.pending) {
console.log(new Date() + "-- Pending transactions on startup, so starting mining.");
miner.start(1);
}
console.log(new Date() + "-- Started on-demand mining. Watching txpool for pending Txs..");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment