I have the following contract that handles address arrays:
contract C {
address[] goodAddr;
address[] badAddr;
function initAddr() constant {
if(goodAddr.length == 0) {
goodAddr.push(0x029ddf2082bc96d321c9769ec8e27e10b3cb16ee);
}
if(badAddr.length == 0) {
badAddr.push(0x115744603fedb255e5ab4765cc1dc6c832639fd5);
}
if(goodAddr.length == 1 && badAddr.length == 1) {
return;
}
for(uint256 i = 0; i < goodAddr.length; i++) {
if(goodAddr[i] == 0x029ddf2082bc96d321c9769ec8e27e10b3cb16ee)
return;
}
for(i = 0; i < badAddr.length; i++) {
if(badAddr[i] == 0x115744603fedb255e5ab4765cc1dc6c832639fd5)
return;
}
goodAddr.push(0x029ddf2082bc96d321c9769ec8e27e10b3cb16ee);
badAddr.push(0x115744603fedb255e5ab4765cc1dc6c832639fd5);
}
function getGoodAddr(uint256 i) constant returns (address) {
if(i < 0 || i >= goodAddr.length) {
return 0x0000000000000000000000000000000000000000;
} else {
return goodAddr[i];
}
}
function getBadAddr(uint256 i) constant returns (address) {
if(i < 0 || i >= badAddr.length) {
return 0x0000000000000000000000000000000000000000;
} else {
return badAddr[i];
}
}
}
The code runs fine on browser solidity but fails to initialize the address arrays when run locally (on a private test net):
> eth.accounts
["0x029ddf2082bc96d321c9769ec8e27e10b3cb16ee", "0x115744603fedb255e5ab4765cc1dc6c832639fd5"]
> checkAllBalances();
eth.accounts[0]: 0x029ddf2082bc96d321c9769ec8e27e10b3cb16ee balance: 55922.95 ether
eth.accounts[1]: 0x115744603fedb255e5ab4765cc1dc6c832639fd5 balance: 1337 ether
undefined
> var c = cContract.new(
.. {
...... from: web3.eth.accounts[0],
...... {0600101610568565b5090565b5b5050509190906000526020600020900160005b73115744603fedb255e5ab4765cc1dc6c832639fd5909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff02191690830217905550505b5056',
...... gas: 4700000
...... }, function (e, contract){
...... console.log(e, contract);
...... if (typeof contract.address !== 'undefined') {
.......... console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
.......... }
...... });
Unlock account 029ddf2082bc96d321c9769ec8e27e10b3cb16ee
Passphrase:
null [object Object]
undefined
> null [object Object]
Contract mined! address: 0xb43c8d6c6ee366358f170553602f2a0fc8ebe1d6 transactionHash: 0x8741c2ccae448a1cc647bdc03883e9136dadcec7adf942832f46bdcbe02e2eae
> c
{
address: "0xb43c8d6c6ee366358f170553602f2a0fc8ebe1d6",
transactionHash: "0x8741c2ccae448a1cc647bdc03883e9136dadcec7adf942832f46bdcbe02e2eae",
allEvents: function(),
getBadAddr: function(),
getGoodAddr: function(),
initAddr: function()
}
> c.initAddr.call();
[]
> c.getBadAddr(0);
"0x0000000000000000000000000000000000000000"
> c.getGoodAddr(0);
"0x0000000000000000000000000000000000000000"
>
Is this a bug in geth? I'm using version 1.3.5.
I've updated to version 1.4 but now all command line arguments are not valid. When I run the following instance:
geth --datadir "./datadir" --networkid 13 --rpcapi eth,web3,personal --rpc --maxpeers 0 init "gen.json" --etherbase "0x0000000000000000000000000000000000000000" --mine --minerthreads 2
I get the error:
Incorrect Usage.
init [arguments...]
The init command initialises a new genesis block and definition for the network.
This is a destructive action and changes the network in which you will be
participating.
flag provided but not defined: -etherbase
Edit:
Any particular reason for the downvote?