Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert gas values to integers #373

Merged
merged 3 commits into from
Feb 24, 2015
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions rpc/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ import (
"github.com/ethereum/go-ethereum/xeth"
)

const (
defaultGasPrice = "10000000000000"
defaultGas = "10000"
)

type EthereumApi struct {
xeth *xeth.XEth
quit chan struct{}
Expand All @@ -45,17 +40,22 @@ type EthereumApi struct {
register map[string][]*NewTxArgs

db ethutil.Database

defaultGasPrice *big.Int
Copy link
Contributor

Choose a reason for hiding this comment

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

These should just be global variables

defaultGas *big.Int
}

func NewEthereumApi(eth *xeth.XEth) *EthereumApi {
db, _ := ethdb.NewLDBDatabase("dapps")
api := &EthereumApi{
xeth: eth,
quit: make(chan struct{}),
filterManager: filter.NewFilterManager(eth.Backend().EventMux()),
logs: make(map[int]*logFilter),
messages: make(map[int]*whisperFilter),
db: db,
xeth: eth,
quit: make(chan struct{}),
filterManager: filter.NewFilterManager(eth.Backend().EventMux()),
logs: make(map[int]*logFilter),
messages: make(map[int]*whisperFilter),
db: db,
defaultGasPrice: big.NewInt(10000000000000),
defaultGas: big.NewInt(10000),
}
go api.filterManager.Start()
go api.start()
Expand Down Expand Up @@ -192,11 +192,11 @@ func (p *EthereumApi) GetBlock(args *GetBlockArgs, reply *interface{}) error {

func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) error {
if len(args.Gas) == 0 {
args.Gas = defaultGas
args.Gas = p.defaultGas.String()
}

if len(args.GasPrice) == 0 {
args.GasPrice = defaultGasPrice
args.GasPrice = p.defaultGasPrice.String()
}

// TODO if no_private_key then
Expand Down Expand Up @@ -525,7 +525,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
}
return p.AllLogs(args, reply)
case "eth_gasPrice":
*reply = defaultGasPrice
*reply = toHex(p.defaultGasPrice.Bytes())
return nil
case "eth_register":
args, err := req.ToRegisterArgs()
Expand Down