aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/state/statedb.go5
-rw-r--r--core/transaction_pool.go5
-rw-r--r--core/transaction_pool_test.go2
-rw-r--r--core/types/transaction.go9
-rw-r--r--crypto/ecies/asn1.go10
-rw-r--r--crypto/ecies/ecies_test.go5
-rw-r--r--rpc/api/args_test.go6
-rw-r--r--rpc/api/eth.go20
-rw-r--r--rpc/api/eth_args.go12
-rw-r--r--rpc/api/utils.go17
-rw-r--r--xeth/xeth.go17
11 files changed, 59 insertions, 49 deletions
diff --git a/core/state/statedb.go b/core/state/statedb.go
index f481c8ab3..45bdfc084 100644
--- a/core/state/statedb.go
+++ b/core/state/statedb.go
@@ -44,6 +44,7 @@ type StateDB struct {
thash, bhash common.Hash
txIndex int
logs map[common.Hash]Logs
+ logSize uint
}
// Create a new state from a given trie
@@ -66,7 +67,9 @@ func (self *StateDB) AddLog(log *Log) {
log.TxHash = self.thash
log.BlockHash = self.bhash
log.TxIndex = uint(self.txIndex)
+ log.Index = self.logSize
self.logs[self.thash] = append(self.logs[self.thash], log)
+ self.logSize++
}
func (self *StateDB) GetLogs(hash common.Hash) Logs {
@@ -288,6 +291,7 @@ func (self *StateDB) Copy() *StateDB {
state.logs[hash] = make(Logs, len(logs))
copy(state.logs[hash], logs)
}
+ state.logSize = self.logSize
return state
}
@@ -298,6 +302,7 @@ func (self *StateDB) Set(state *StateDB) {
self.refund = state.refund
self.logs = state.logs
+ self.logSize = state.logSize
}
func (s *StateDB) Root() common.Hash {
diff --git a/core/transaction_pool.go b/core/transaction_pool.go
index 13f14f995..42e26b3b3 100644
--- a/core/transaction_pool.go
+++ b/core/transaction_pool.go
@@ -356,11 +356,12 @@ func (self *TxPool) RemoveTransactions(txs types.Transactions) {
self.mu.Lock()
defer self.mu.Unlock()
for _, tx := range txs {
- self.removeTx(tx.Hash())
+ self.RemoveTx(tx.Hash())
}
}
-func (pool *TxPool) removeTx(hash common.Hash) {
+// RemoveTx removes the transaction with the given hash from the pool.
+func (pool *TxPool) RemoveTx(hash common.Hash) {
// delete from pending pool
delete(pool.pending, hash)
// delete from queue
diff --git a/core/transaction_pool_test.go b/core/transaction_pool_test.go
index 26af4fc16..7d0984740 100644
--- a/core/transaction_pool_test.go
+++ b/core/transaction_pool_test.go
@@ -130,7 +130,7 @@ func TestRemoveTx(t *testing.T) {
t.Error("expected txs to be 1, got", len(pool.pending))
}
- pool.removeTx(tx.Hash())
+ pool.RemoveTx(tx.Hash())
if len(pool.queue) > 0 {
t.Error("expected queue to be 0, got", len(pool.queue))
diff --git a/core/types/transaction.go b/core/types/transaction.go
index cc1793112..85b4c6119 100644
--- a/core/types/transaction.go
+++ b/core/types/transaction.go
@@ -97,15 +97,6 @@ func NewTransaction(nonce uint64, to common.Address, amount, gasLimit, gasPrice
return &Transaction{data: d}
}
-func NewTransactionFromBytes(data []byte) *Transaction {
- // TODO: remove this function if possible. callers would
- // much better off decoding into transaction directly.
- // it's not that hard.
- tx := new(Transaction)
- rlp.DecodeBytes(data, tx)
- return tx
-}
-
func (tx *Transaction) EncodeRLP(w io.Writer) error {
return rlp.Encode(w, &tx.data)
}
diff --git a/crypto/ecies/asn1.go b/crypto/ecies/asn1.go
index 0a478e435..6eaf3d2ca 100644
--- a/crypto/ecies/asn1.go
+++ b/crypto/ecies/asn1.go
@@ -81,11 +81,9 @@ func doScheme(base, v []int) asn1.ObjectIdentifier {
type secgNamedCurve asn1.ObjectIdentifier
var (
- secgNamedCurveP224 = secgNamedCurve{1, 3, 132, 0, 33}
secgNamedCurveP256 = secgNamedCurve{1, 2, 840, 10045, 3, 1, 7}
secgNamedCurveP384 = secgNamedCurve{1, 3, 132, 0, 34}
secgNamedCurveP521 = secgNamedCurve{1, 3, 132, 0, 35}
- rawCurveP224 = []byte{6, 5, 4, 3, 1, 2, 9, 4, 0, 3, 3}
rawCurveP256 = []byte{6, 8, 4, 2, 1, 3, 4, 7, 2, 2, 0, 6, 6, 1, 3, 1, 7}
rawCurveP384 = []byte{6, 5, 4, 3, 1, 2, 9, 4, 0, 3, 4}
rawCurveP521 = []byte{6, 5, 4, 3, 1, 2, 9, 4, 0, 3, 5}
@@ -93,8 +91,6 @@ var (
func rawCurve(curve elliptic.Curve) []byte {
switch curve {
- case elliptic.P224():
- return rawCurveP224
case elliptic.P256():
return rawCurveP256
case elliptic.P384():
@@ -120,8 +116,6 @@ func (curve secgNamedCurve) Equal(curve2 secgNamedCurve) bool {
func namedCurveFromOID(curve secgNamedCurve) elliptic.Curve {
switch {
- case curve.Equal(secgNamedCurveP224):
- return elliptic.P224()
case curve.Equal(secgNamedCurveP256):
return elliptic.P256()
case curve.Equal(secgNamedCurveP384):
@@ -134,8 +128,6 @@ func namedCurveFromOID(curve secgNamedCurve) elliptic.Curve {
func oidFromNamedCurve(curve elliptic.Curve) (secgNamedCurve, bool) {
switch curve {
- case elliptic.P224():
- return secgNamedCurveP224, true
case elliptic.P256():
return secgNamedCurveP256, true
case elliptic.P384():
@@ -248,7 +240,7 @@ var idEcPublicKeySupplemented = doScheme(idPublicKeyType, []int{0})
func curveToRaw(curve elliptic.Curve) (rv asn1.RawValue, ok bool) {
switch curve {
- case elliptic.P224(), elliptic.P256(), elliptic.P384(), elliptic.P521():
+ case elliptic.P256(), elliptic.P384(), elliptic.P521():
raw := rawCurve(curve)
return asn1.RawValue{
Tag: 30,
diff --git a/crypto/ecies/ecies_test.go b/crypto/ecies/ecies_test.go
index 762124954..1c391f938 100644
--- a/crypto/ecies/ecies_test.go
+++ b/crypto/ecies/ecies_test.go
@@ -408,11 +408,6 @@ type testCase struct {
var testCases = []testCase{
testCase{
- Curve: elliptic.P224(),
- Name: "P224",
- Expected: false,
- },
- testCase{
Curve: elliptic.P256(),
Name: "P256",
Expected: true,
diff --git a/rpc/api/args_test.go b/rpc/api/args_test.go
index bb279718b..23ae2930d 100644
--- a/rpc/api/args_test.go
+++ b/rpc/api/args_test.go
@@ -935,9 +935,9 @@ func TestCallArgsNotStrings(t *testing.T) {
func TestCallArgsToEmpty(t *testing.T) {
input := `[{"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155"}]`
args := new(CallArgs)
- str := ExpectValidationError(json.Unmarshal([]byte(input), &args))
- if len(str) > 0 {
- t.Error(str)
+ err := json.Unmarshal([]byte(input), &args)
+ if err != nil {
+ t.Error("Did not expect error. Got", err)
}
}
diff --git a/rpc/api/eth.go b/rpc/api/eth.go
index ed636004c..4041811f0 100644
--- a/rpc/api/eth.go
+++ b/rpc/api/eth.go
@@ -21,8 +21,9 @@ import (
"encoding/json"
"math/big"
+ "fmt"
+
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/shared"
@@ -322,7 +323,7 @@ func (self *ethApi) EstimateGas(req *shared.Request) (interface{}, error) {
if len(gas) == 0 {
return newHexNum(0), nil
} else {
- return newHexNum(gas), nil
+ return newHexNum(common.String2Big(gas)), err
}
}
@@ -578,14 +579,17 @@ func (self *ethApi) Resend(req *shared.Request) (interface{}, error) {
return nil, shared.NewDecodeParamError(err.Error())
}
- ret, err := self.xeth.Transact(args.Tx.From, args.Tx.To, args.Tx.Nonce, args.Tx.Value, args.GasLimit, args.GasPrice, args.Tx.Data)
- if err != nil {
- return nil, err
- }
+ from := common.HexToAddress(args.Tx.From)
- self.ethereum.TxPool().RemoveTransactions(types.Transactions{args.Tx.tx})
+ pending := self.ethereum.TxPool().GetTransactions()
+ for _, p := range pending {
+ if pFrom, err := p.From(); err == nil && pFrom == from && p.SigHash() == args.Tx.tx.SigHash() {
+ self.ethereum.TxPool().RemoveTx(common.HexToHash(args.Tx.Hash))
+ return self.xeth.Transact(args.Tx.From, args.Tx.To, args.Tx.Nonce, args.Tx.Value, args.GasLimit, args.GasPrice, args.Tx.Data)
+ }
+ }
- return ret, nil
+ return nil, fmt.Errorf("Transaction %s not found", args.Tx.Hash)
}
func (self *ethApi) PendingTransactions(req *shared.Request) (interface{}, error) {
diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go
index ae394e7ec..1218bd625 100644
--- a/rpc/api/eth_args.go
+++ b/rpc/api/eth_args.go
@@ -469,10 +469,6 @@ func (args *CallArgs) UnmarshalJSON(b []byte) (err error) {
}
args.From = ext.From
-
- if len(ext.To) == 0 {
- return shared.NewValidationError("to", "is required")
- }
args.To = ext.To
var num *big.Int
@@ -888,6 +884,7 @@ type tx struct {
Data string
GasLimit string
GasPrice string
+ Hash string
}
func newTx(t *types.Transaction) *tx {
@@ -906,6 +903,7 @@ func newTx(t *types.Transaction) *tx {
Data: "0x" + common.Bytes2Hex(t.Data()),
GasLimit: t.Gas().String(),
GasPrice: t.GasPrice().String(),
+ Hash: t.Hash().Hex(),
}
}
@@ -931,6 +929,12 @@ func (tx *tx) UnmarshalJSON(b []byte) (err error) {
contractCreation = true
)
+ if val, found := fields["Hash"]; found {
+ if hashVal, ok := val.(string); ok {
+ tx.Hash = hashVal
+ }
+ }
+
if val, found := fields["To"]; found {
if strVal, ok := val.(string); ok && len(strVal) > 0 {
tx.To = strVal
diff --git a/rpc/api/utils.go b/rpc/api/utils.go
index a791dcd65..50c607d16 100644
--- a/rpc/api/utils.go
+++ b/rpc/api/utils.go
@@ -32,16 +32,22 @@ var (
AutoCompletion = map[string][]string{
"admin": []string{
"addPeer",
- "peers",
- "nodeInfo",
+ "chainSyncStatus",
+ "datadir",
"exportChain",
+ "getContractInfo",
"importChain",
- "verbosity",
- "chainSyncStatus",
+ "nodeInfo",
+ "peers",
+ "register",
+ "registerUrl",
"setSolc",
- "datadir",
+ "sleepBlocks",
+ "startNatSpec",
"startRPC",
+ "stopNatSpec",
"stopRPC",
+ "verbosity",
},
"db": []string{
"getString",
@@ -97,6 +103,7 @@ var (
"miner": []string{
"hashrate",
"makeDAG",
+ "setEtherbase",
"setExtra",
"setGasPrice",
"startAutoDAG",
diff --git a/xeth/xeth.go b/xeth/xeth.go
index 63826a334..5d54c1f7e 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -310,7 +310,12 @@ func (self *XEth) EthTransactionByHash(hash string) (tx *types.Transaction, blha
// some chain, this probably needs to be refactored for more expressiveness
data, _ := self.backend.ExtraDb().Get(common.FromHex(hash))
if len(data) != 0 {
- tx = types.NewTransactionFromBytes(data)
+ dtx := new(types.Transaction)
+ if err := rlp.DecodeBytes(data, dtx); err != nil {
+ glog.V(logger.Error).Infoln(err)
+ return
+ }
+ tx = dtx
} else { // check pending transactions
tx = self.backend.TxPool().GetTransaction(common.HexToHash(hash))
}
@@ -773,8 +778,14 @@ func (self *XEth) FromNumber(str string) string {
}
func (self *XEth) PushTx(encodedTx string) (string, error) {
- tx := types.NewTransactionFromBytes(common.FromHex(encodedTx))
- err := self.backend.TxPool().Add(tx)
+ tx := new(types.Transaction)
+ err := rlp.DecodeBytes(common.FromHex(encodedTx), tx)
+ if err != nil {
+ glog.V(logger.Error).Infoln(err)
+ return "", err
+ }
+
+ err = self.backend.TxPool().Add(tx)
if err != nil {
return "", err
}