aboutsummaryrefslogtreecommitdiffstats
path: root/xeth/xeth.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-02-20 05:33:22 +0800
committerobscuren <geffobscura@gmail.com>2015-02-20 05:33:22 +0800
commitfa4cbad315609e41d88c59ecbce7c6c6169fc57a (patch)
tree5af4a3cfd497e682e41898059571b75f6f8e4cf9 /xeth/xeth.go
parentc14071df9da4ab3f5b372293e87184af9b91c09e (diff)
downloadgo-tangerine-fa4cbad315609e41d88c59ecbce7c6c6169fc57a.tar
go-tangerine-fa4cbad315609e41d88c59ecbce7c6c6169fc57a.tar.gz
go-tangerine-fa4cbad315609e41d88c59ecbce7c6c6169fc57a.tar.bz2
go-tangerine-fa4cbad315609e41d88c59ecbce7c6c6169fc57a.tar.lz
go-tangerine-fa4cbad315609e41d88c59ecbce7c6c6169fc57a.tar.xz
go-tangerine-fa4cbad315609e41d88c59ecbce7c6c6169fc57a.tar.zst
go-tangerine-fa4cbad315609e41d88c59ecbce7c6c6169fc57a.zip
Optimisations and fixed a couple of DDOS issues in the miner
Diffstat (limited to 'xeth/xeth.go')
-rw-r--r--xeth/xeth.go29
1 files changed, 16 insertions, 13 deletions
diff --git a/xeth/xeth.go b/xeth/xeth.go
index f005105bb..d578c03c9 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -7,6 +7,7 @@ package xeth
import (
"bytes"
"encoding/json"
+ "fmt"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
@@ -241,7 +242,6 @@ func (self *XEth) Call(toStr, valueStr, gasStr, gasPriceStr, dataStr string) (st
}
func (self *XEth) Transact(toStr, valueStr, gasStr, gasPriceStr, codeStr string) (string, error) {
-
var (
to []byte
value = ethutil.NewValue(valueStr)
@@ -265,29 +265,32 @@ func (self *XEth) Transact(toStr, valueStr, gasStr, gasPriceStr, codeStr string)
tx = types.NewTransactionMessage(to, value.BigInt(), gas.BigInt(), price.BigInt(), data)
}
- state := self.chainManager.TransState()
+ var err error
+ state := self.eth.ChainManager().TransState()
+ if balance := state.GetBalance(key.Address()); balance.Cmp(tx.Value()) < 0 {
+ return "", fmt.Errorf("insufficient balance. balance=%v tx=%v", balance, tx.Value())
+ }
nonce := state.GetNonce(key.Address())
tx.SetNonce(nonce)
tx.Sign(key.PrivateKey)
- // Do some pre processing for our "pre" events and hooks
- block := self.chainManager.NewBlock(key.Address())
- coinbase := state.GetOrNewStateObject(key.Address())
- coinbase.SetGasPool(block.GasLimit())
- self.blockProcessor.ApplyTransactions(coinbase, state, block, types.Transactions{tx}, true)
+ //fmt.Printf("create tx: %x %v\n", tx.Hash()[:4], tx.Nonce())
- err := self.eth.TxPool().Add(tx)
+ /*
+ // Do some pre processing for our "pre" events and hooks
+ block := self.chainManager.NewBlock(key.Address())
+ coinbase := state.GetOrNewStateObject(key.Address())
+ coinbase.SetGasPool(block.GasLimit())
+ self.blockProcessor.ApplyTransactions(coinbase, state, block, types.Transactions{tx}, true)
+ */
+
+ err = self.eth.TxPool().Add(tx)
if err != nil {
return "", err
}
state.SetNonce(key.Address(), nonce+1)
- if contractCreation {
- addr := core.AddressFromMessage(tx)
- pipelogger.Infof("Contract addr %x\n", addr)
- }
-
if types.IsContractAddr(to) {
return toHex(core.AddressFromMessage(tx)), nil
}