Somehow I can't connect peers to eachother..

boestinboestin Posts: 7Member
edited October 2016 in Projects
On 1 machine, I want to run 2 geth instances. 1 of the instance should be mining, the second to be a peer. As far as my knowledge reaches, I think there has to be at least 2 peers active in the network in order to create transactions. Also 1 miner to create the blocks. Is this assumption correct?

So... I want to build a project locally first on a private testnet.
Basically I want to set up an configure at least 2 geth instances that are on the same private testnet. One of the geth has to be mining and the other one acts as a node. Is this even possible on one machine?



1. First I am going to create a sample genesis.json:
{
"nonce": "0x0000000000000042",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x0",
"gasLimit": "0x8000000",
"difficulty": "0x400",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0xb7188bc683fc4c00965e470b38d89dcbdeaa39c4",
"alloc": {
}
}

2. Then on the first instance, I will generate the Genesis block by invoking the parameter init:
geth init "D:\ethereum\gethlatest\chain\CustomGenesis.json"

3. now I can execute the following command:
geth --identity Nemesis1 --networkid 2712197627121976 --datadir D:\ethereum\gethlatest\chain --ipcdisable --port 30301 --rpc --rpcport 8101 console


4. It looks good. Now I am creating the first address and start mining:
personal.newAccount("password")
miner.start()

5 After a couple of blocks I received some Ether (I checked it in Ethereum Wallet) I want to connect the 2nd instance (I have no peers, therefore I can't create new transactions)
geth --identity Nemesis2 --networkid 2712197627121976 --datadir D:\ethereum\gethlatest\chain2 --ipcdisable --rpc --port 30302 console


6. Now I want to connect this 2nd geth instance with the first instance, I want it to "hop on" that blockchain:

admin.addPeer("enode://641277e63fa1c1ad8de0e5e47f24d5e16fb9478a645fd68aa50fc3582810738e6822f97fa70db41c6f53ccfe4286e429f60765e8896dff8d9d5def0d276ba713@127.0.0.1:30301")
true

admin.peers:
[]


Any advice on how to handle this?

Best regards,
boestin



Comments

Sign In or Register to comment.