Skip to content

Commit

Permalink
add gasprice param
Browse files Browse the repository at this point in the history
  • Loading branch information
tranvictor committed May 8, 2017
1 parent 25d97e6 commit bf2ed8b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/kovan/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func Run(c *cli.Context) error {
gethContractClient, err = geth.NewGethContractClient(
common.HexToAddress(input.ContractAddress()), kovanRPC,
common.HexToAddress(input.MinerAddress()),
input.RPCEndpoint(), input.KeystorePath(), passphrase,
input.RPCEndpoint(), input.KeystorePath(), passphrase, 0,
)
if gethContractClient != nil {
break
Expand Down
7 changes: 7 additions & 0 deletions cmd/ropsten/ropsten.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func Run(c *cli.Context) error {
fmt.Printf("Gateway address %s is invalid.\n", c.String("gateway"))
return nil
}
gasprice := c.Uint("gasprice")
smartpool.Output = &smartpool.StdOut{}
ethereumWorkPool := &ethereum.WorkPool{}
go ethereumWorkPool.Cleanning()
Expand Down Expand Up @@ -133,6 +134,7 @@ func Run(c *cli.Context) error {
common.HexToAddress(input.ContractAddress()), gethRPC,
common.HexToAddress(input.MinerAddress()),
input.RPCEndpoint(), input.KeystorePath(), passphrase,
uint64(gasprice),
)
if gethContractClient != nil {
break
Expand Down Expand Up @@ -211,6 +213,11 @@ func BuildAppCommandLine() *cli.App {
Value: 1000000,
Usage: "Difficulty of a share.",
},
cli.UintFlag{
Name: "gasprice",
Value: 5,
Usage: "Gas price in gwei to use in communication with the contract. Specify 0 if you let your Ethereum Client decide on gas price.",
},
cli.StringFlag{
Name: "spcontract",
Value: "0xf7d93BCB8e4372F46383ecee82f9adF1aA397BA9",
Expand Down
7 changes: 5 additions & 2 deletions ethereum/geth/geth_contract_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func getClient(rpc string) (*ethclient.Client, error) {

func NewGethContractClient(
contractAddr common.Address, node ethereum.RPCClient, miner common.Address,
ipc, keystorePath, passphrase string) (*GethContractClient, error) {
ipc, keystorePath, passphrase string, gasprice uint64) (*GethContractClient, error) {
client, err := getClient(ipc)
if err != nil {
smartpool.Output.Printf("Couldn't connect to Geth via IPC file. Error: %s\n", err)
Expand Down Expand Up @@ -238,7 +238,10 @@ func NewGethContractClient(
return nil, err
}
// TODO: make gas price one command line flag
auth.GasPrice = big.NewInt(10000000000)
if gasprice != 0 {
auth.GasPrice = big.NewInt(int64(gasprice * 1000000000))
smartpool.Output.Printf("Gas price is set to: %s wei.\n", auth.GasPrice.Text(10))
}
smartpool.Output.Printf("Done.\n")
return &GethContractClient{pool, auth, node, miner}, nil
}

1 comment on commit bf2ed8b

@tranvictor
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suppose to fix #23

Please sign in to comment.