Skip to content

Commit 1e919a5

Browse files
committed
Move amounts to global vars
1 parent 2a7ca69 commit 1e919a5

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

rpc/packages.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ import (
2525
"github.com/ethereum/go-ethereum/xeth"
2626
)
2727

28+
var (
29+
defaultGasPrice = big.NewInt(10000000000000)
30+
defaultGas = big.NewInt(10000)
31+
)
32+
2833
type EthereumApi struct {
2934
xeth *xeth.XEth
3035
quit chan struct{}
@@ -40,22 +45,17 @@ type EthereumApi struct {
4045
register map[string][]*NewTxArgs
4146

4247
db ethutil.Database
43-
44-
defaultGasPrice *big.Int
45-
defaultGas *big.Int
4648
}
4749

4850
func NewEthereumApi(eth *xeth.XEth) *EthereumApi {
4951
db, _ := ethdb.NewLDBDatabase("dapps")
5052
api := &EthereumApi{
51-
xeth: eth,
52-
quit: make(chan struct{}),
53-
filterManager: filter.NewFilterManager(eth.Backend().EventMux()),
54-
logs: make(map[int]*logFilter),
55-
messages: make(map[int]*whisperFilter),
56-
db: db,
57-
defaultGasPrice: big.NewInt(10000000000000),
58-
defaultGas: big.NewInt(10000),
53+
xeth: eth,
54+
quit: make(chan struct{}),
55+
filterManager: filter.NewFilterManager(eth.Backend().EventMux()),
56+
logs: make(map[int]*logFilter),
57+
messages: make(map[int]*whisperFilter),
58+
db: db,
5959
}
6060
go api.filterManager.Start()
6161
go api.start()
@@ -192,11 +192,11 @@ func (p *EthereumApi) GetBlock(args *GetBlockArgs, reply *interface{}) error {
192192

193193
func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) error {
194194
if len(args.Gas) == 0 {
195-
args.Gas = p.defaultGas.String()
195+
args.Gas = defaultGas.String()
196196
}
197197

198198
if len(args.GasPrice) == 0 {
199-
args.GasPrice = p.defaultGasPrice.String()
199+
args.GasPrice = defaultGasPrice.String()
200200
}
201201

202202
// TODO if no_private_key then
@@ -525,7 +525,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
525525
}
526526
return p.AllLogs(args, reply)
527527
case "eth_gasPrice":
528-
*reply = toHex(p.defaultGasPrice.Bytes())
528+
*reply = toHex(defaultGasPrice.Bytes())
529529
return nil
530530
case "eth_register":
531531
args, err := req.ToRegisterArgs()

0 commit comments

Comments
 (0)