aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd/geth/js.go7
-rw-r--r--eth/backend.go7
-rw-r--r--eth/gasprice.go23
-rw-r--r--jsre/jsre.go1
-rw-r--r--jsre/pretty.go23
-rw-r--r--rpc/api/eth_args.go16
-rw-r--r--rpc/xeth.go18
-rw-r--r--xeth/xeth.go22
8 files changed, 70 insertions, 47 deletions
diff --git a/cmd/geth/js.go b/cmd/geth/js.go
index 04b44d6a9..c31deefdd 100644
--- a/cmd/geth/js.go
+++ b/cmd/geth/js.go
@@ -228,15 +228,10 @@ func (self *jsre) loadAutoCompletion() {
}
func (self *jsre) batch(statement string) {
- val, err := self.re.Run(statement)
+ err := self.re.EvalAndPrettyPrint(statement)
if err != nil {
fmt.Printf("error: %v", err)
- } else if val.IsDefined() && val.IsObject() {
- obj, _ := self.re.Get("ret_result")
- fmt.Printf("%v", obj)
- } else if val.IsDefined() {
- fmt.Printf("%v", val)
}
if self.atexit != nil {
diff --git a/eth/backend.go b/eth/backend.go
index 953a150ad..2b21a7c96 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -61,10 +61,11 @@ var (
defaultBootNodes = []*discover.Node{
// ETH/DEV Go Bootnodes
- discover.MustParseNode("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303"),
- discover.MustParseNode("enode://de471bccee3d042261d52e9bff31458daecc406142b401d4cd848f677479f73104b9fdeb090af9583d3391b7f10cb2ba9e26865dd5fca4fcdc0fb1e3b723c786@54.94.239.50:30303"),
+ discover.MustParseNode("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303"), // IE
+ discover.MustParseNode("enode://de471bccee3d042261d52e9bff31458daecc406142b401d4cd848f677479f73104b9fdeb090af9583d3391b7f10cb2ba9e26865dd5fca4fcdc0fb1e3b723c786@54.94.239.50:30303"), // BR
+ discover.MustParseNode("enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303"), // SG
// ETH/DEV cpp-ethereum (poc-9.ethdev.com)
- discover.MustParseNode("enode://487611428e6c99a11a9795a6abe7b529e81315ca6aad66e2a2fc76e3adf263faba0d35466c2f8f68d561dbefa8878d4df5f1f2ddb1fbeab7f42ffb8cd328bd4a@5.1.83.226:30303"),
+ discover.MustParseNode("enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303"),
}
staticNodes = "static-nodes.json" // Path within <datadir> to search for the static node list
diff --git a/eth/gasprice.go b/eth/gasprice.go
index 031098e9a..3caad73c6 100644
--- a/eth/gasprice.go
+++ b/eth/gasprice.go
@@ -37,12 +37,11 @@ type blockPriceInfo struct {
type GasPriceOracle struct {
eth *Ethereum
chain *core.ChainManager
- pool *core.TxPool
events event.Subscription
blocks map[uint64]*blockPriceInfo
firstProcessed, lastProcessed uint64
lastBaseMutex sync.Mutex
- lastBase *big.Int
+ lastBase, minBase *big.Int
}
func NewGasPriceOracle(eth *Ethereum) (self *GasPriceOracle) {
@@ -50,13 +49,15 @@ func NewGasPriceOracle(eth *Ethereum) (self *GasPriceOracle) {
self.blocks = make(map[uint64]*blockPriceInfo)
self.eth = eth
self.chain = eth.chainManager
- self.pool = eth.txPool
self.events = eth.EventMux().Subscribe(
core.ChainEvent{},
core.ChainSplitEvent{},
- core.TxPreEvent{},
- core.TxPostEvent{},
)
+
+ minbase := new(big.Int).Mul(self.eth.GpoMinGasPrice, big.NewInt(100))
+ minbase = minbase.Div(minbase, big.NewInt(int64(self.eth.GpobaseCorrectionFactor)))
+ self.minBase = minbase
+
self.processPastBlocks()
go self.listenLoop()
return
@@ -93,8 +94,6 @@ func (self *GasPriceOracle) listenLoop() {
self.processBlock(ev.Block)
case core.ChainSplitEvent:
self.processBlock(ev.Block)
- case core.TxPreEvent:
- case core.TxPostEvent:
}
}
self.events.Unsubscribe()
@@ -131,6 +130,10 @@ func (self *GasPriceOracle) processBlock(block *types.Block) {
newBase := new(big.Int).Mul(lastBase, big.NewInt(1000000+crand))
newBase.Div(newBase, big.NewInt(1000000))
+ if newBase.Cmp(self.minBase) < 0 {
+ newBase = self.minBase
+ }
+
bpi := self.blocks[i]
if bpi == nil {
bpi = &blockPriceInfo{}
@@ -146,7 +149,7 @@ func (self *GasPriceOracle) processBlock(block *types.Block) {
// returns the lowers possible price with which a tx was or could have been included
func (self *GasPriceOracle) lowestPrice(block *types.Block) *big.Int {
- gasUsed := new(big.Int)
+ gasUsed := big.NewInt(0)
receipts := self.eth.BlockProcessor().GetBlockReceipts(block.Hash())
if len(receipts) > 0 {
@@ -158,12 +161,12 @@ func (self *GasPriceOracle) lowestPrice(block *types.Block) *big.Int {
if new(big.Int).Mul(gasUsed, big.NewInt(100)).Cmp(new(big.Int).Mul(block.GasLimit(),
big.NewInt(int64(self.eth.GpoFullBlockRatio)))) < 0 {
// block is not full, could have posted a tx with MinGasPrice
- return self.eth.GpoMinGasPrice
+ return big.NewInt(0)
}
txs := block.Transactions()
if len(txs) == 0 {
- return self.eth.GpoMinGasPrice
+ return big.NewInt(0)
}
// block is full, find smallest gasPrice
minPrice := txs[0].GasPrice()
diff --git a/jsre/jsre.go b/jsre/jsre.go
index bb0cc71ed..0db9e33fc 100644
--- a/jsre/jsre.go
+++ b/jsre/jsre.go
@@ -66,6 +66,7 @@ func New(assetPath string) *JSRE {
re.loopWg.Add(1)
go re.runEventLoop()
re.Set("loadScript", re.loadScript)
+ re.Set("inspect", prettyPrintJS)
return re
}
diff --git a/jsre/pretty.go b/jsre/pretty.go
index cf04deec6..99aa9b33e 100644
--- a/jsre/pretty.go
+++ b/jsre/pretty.go
@@ -51,7 +51,15 @@ var boringKeys = map[string]bool{
// prettyPrint writes value to standard output.
func prettyPrint(vm *otto.Otto, value otto.Value) {
- ppctx{vm}.printValue(value, 0)
+ ppctx{vm}.printValue(value, 0, false)
+}
+
+func prettyPrintJS(call otto.FunctionCall) otto.Value {
+ for _, v := range call.ArgumentList {
+ prettyPrint(call.Otto, v)
+ fmt.Println()
+ }
+ return otto.UndefinedValue()
}
type ppctx struct{ vm *otto.Otto }
@@ -60,10 +68,10 @@ func (ctx ppctx) indent(level int) string {
return strings.Repeat(indentString, level)
}
-func (ctx ppctx) printValue(v otto.Value, level int) {
+func (ctx ppctx) printValue(v otto.Value, level int, inArray bool) {
switch {
case v.IsObject():
- ctx.printObject(v.Object(), level)
+ ctx.printObject(v.Object(), level, inArray)
case v.IsNull():
specialColor.Print("null")
case v.IsUndefined():
@@ -84,7 +92,7 @@ func (ctx ppctx) printValue(v otto.Value, level int) {
}
}
-func (ctx ppctx) printObject(obj *otto.Object, level int) {
+func (ctx ppctx) printObject(obj *otto.Object, level int, inArray bool) {
switch obj.Class() {
case "Array":
lv, _ := obj.Get("length")
@@ -101,7 +109,7 @@ func (ctx ppctx) printObject(obj *otto.Object, level int) {
for i := int64(0); i < len; i++ {
el, err := obj.Get(strconv.FormatInt(i, 10))
if err == nil {
- ctx.printValue(el, level+1)
+ ctx.printValue(el, level+1, true)
}
if i < len-1 {
fmt.Printf(", ")
@@ -129,12 +137,15 @@ func (ctx ppctx) printObject(obj *otto.Object, level int) {
for i, k := range keys {
v, _ := obj.Get(k)
fmt.Printf("%s%s: ", ctx.indent(level+1), k)
- ctx.printValue(v, level+1)
+ ctx.printValue(v, level+1, false)
if i < len(keys)-1 {
fmt.Printf(",")
}
fmt.Println()
}
+ if inArray {
+ level--
+ }
fmt.Printf("%s}", ctx.indent(level))
case "Function":
diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go
index 5a1841cbe..8bd077e20 100644
--- a/rpc/api/eth_args.go
+++ b/rpc/api/eth_args.go
@@ -908,14 +908,14 @@ func (args *SubmitWorkArgs) UnmarshalJSON(b []byte) (err error) {
type tx struct {
tx *types.Transaction
- To string
- From string
- Nonce string
- Value string
- Data string
- GasLimit string
- GasPrice string
- Hash string
+ To string `json:"to"`
+ From string `json:"from"`
+ Nonce string `json:"nonce"`
+ Value string `json:"value"`
+ Data string `json:"data"`
+ GasLimit string `json:"gas"`
+ GasPrice string `json:"gasPrice"`
+ Hash string `json:"hash"`
}
func newTx(t *types.Transaction) *tx {
diff --git a/rpc/xeth.go b/rpc/xeth.go
index 65a1edeb8..9527a96c0 100644
--- a/rpc/xeth.go
+++ b/rpc/xeth.go
@@ -53,7 +53,7 @@ func (self *Xeth) Call(method string, params []interface{}) (map[string]interfac
Method: method,
Params: data,
}
- // Send the request over and process the response
+ // Send the request over and retrieve the response
if err := self.client.Send(req); err != nil {
return nil, err
}
@@ -61,9 +61,17 @@ func (self *Xeth) Call(method string, params []interface{}) (map[string]interfac
if err != nil {
return nil, err
}
- value, ok := res.(map[string]interface{})
- if !ok {
- return nil, fmt.Errorf("Invalid response type: have %v, want %v", reflect.TypeOf(res), reflect.TypeOf(make(map[string]interface{})))
+ // Ensure the response is valid, and extract the results
+ success, isSuccessResponse := res.(*shared.SuccessResponse)
+ failure, isFailureResponse := res.(*shared.ErrorResponse)
+ switch {
+ case isFailureResponse:
+ return nil, fmt.Errorf("Method invocation failed: %v", failure.Error)
+
+ case isSuccessResponse:
+ return success.Result.(map[string]interface{}), nil
+
+ default:
+ return nil, fmt.Errorf("Invalid response type: %v", reflect.TypeOf(res))
}
- return value, nil
}
diff --git a/xeth/xeth.go b/xeth/xeth.go
index 5a57608bc..8bd45998f 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -89,8 +89,7 @@ type XEth struct {
messagesMu sync.RWMutex
messages map[int]*whisperFilter
- // regmut sync.Mutex
- // register map[string][]*interface{} // TODO improve return type
+ transactMu sync.Mutex
agent *miner.RemoteAgent
@@ -823,18 +822,22 @@ func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr st
}
from.SetBalance(common.MaxBig)
- from.SetGasLimit(self.backend.ChainManager().GasLimit())
+ from.SetGasLimit(common.MaxBig)
+
msg := callmsg{
from: from,
- to: common.HexToAddress(toStr),
gas: common.Big(gasStr),
gasPrice: common.Big(gasPriceStr),
value: common.Big(valueStr),
data: common.FromHex(dataStr),
}
+ if len(toStr) > 0 {
+ addr := common.HexToAddress(toStr)
+ msg.to = &addr
+ }
if msg.gas.Cmp(big.NewInt(0)) == 0 {
- msg.gas = DefaultGas()
+ msg.gas = big.NewInt(50000000)
}
if msg.gasPrice.Cmp(big.NewInt(0)) == 0 {
@@ -952,8 +955,9 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
}
*/
- // TODO: align default values to have the same type, e.g. not depend on
- // common.Value conversions later on
+ self.transactMu.Lock()
+ defer self.transactMu.Unlock()
+
var nonce uint64
if len(nonceStr) != 0 {
nonce = common.Big(nonceStr).Uint64()
@@ -998,7 +1002,7 @@ func (self *XEth) sign(tx *types.Transaction, from common.Address, didUnlock boo
// callmsg is the message type used for call transations.
type callmsg struct {
from *state.StateObject
- to common.Address
+ to *common.Address
gas, gasPrice *big.Int
value *big.Int
data []byte
@@ -1007,7 +1011,7 @@ type callmsg struct {
// accessor boilerplate to implement core.Message
func (m callmsg) From() (common.Address, error) { return m.from.Address(), nil }
func (m callmsg) Nonce() uint64 { return m.from.Nonce() }
-func (m callmsg) To() *common.Address { return &m.to }
+func (m callmsg) To() *common.Address { return m.to }
func (m callmsg) GasPrice() *big.Int { return m.gasPrice }
func (m callmsg) Gas() *big.Int { return m.gas }
func (m callmsg) Value() *big.Int { return m.value }