aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-18 22:33:22 +0800
committerobscuren <geffobscura@gmail.com>2014-12-18 22:33:22 +0800
commit5ad473d7581b92811c3a3e035274a82fc5568f57 (patch)
tree9d34ffc04b208a1923fa181938e7366bca2573d7 /core
parentdb494170dc819b1eb0d267b6e1ab36c6cfb63569 (diff)
downloaddexon-5ad473d7581b92811c3a3e035274a82fc5568f57.tar
dexon-5ad473d7581b92811c3a3e035274a82fc5568f57.tar.gz
dexon-5ad473d7581b92811c3a3e035274a82fc5568f57.tar.bz2
dexon-5ad473d7581b92811c3a3e035274a82fc5568f57.tar.lz
dexon-5ad473d7581b92811c3a3e035274a82fc5568f57.tar.xz
dexon-5ad473d7581b92811c3a3e035274a82fc5568f57.tar.zst
dexon-5ad473d7581b92811c3a3e035274a82fc5568f57.zip
Moved methods to messages
Diffstat (limited to 'core')
-rw-r--r--core/state_transition.go10
-rw-r--r--core/transaction_pool.go6
-rw-r--r--core/types/transaction.go23
3 files changed, 8 insertions, 31 deletions
diff --git a/core/state_transition.go b/core/state_transition.go
index a6b654842..61c9558e3 100644
--- a/core/state_transition.go
+++ b/core/state_transition.go
@@ -44,8 +44,6 @@ type StateTransition struct {
type Message interface {
Hash() []byte
- CreatesContract() bool
-
From() []byte
To() []byte
@@ -63,6 +61,10 @@ func AddressFromMessage(msg Message) []byte {
return crypto.Sha3(ethutil.NewValue([]interface{}{msg.From(), msg.Nonce()}).Encode())[12:]
}
+func MessageCreatesContract(msg Message) bool {
+ return len(msg.To()) == 0
+}
+
func NewStateTransition(coinbase *state.StateObject, msg Message, state *state.StateDB, block *types.Block) *StateTransition {
return &StateTransition{coinbase.Address(), msg.To(), msg, new(big.Int), new(big.Int).Set(msg.GasPrice()), msg.Value(), msg.Data(), state, block, coinbase, nil, nil, nil}
}
@@ -93,7 +95,7 @@ func (self *StateTransition) From() *state.StateObject {
return self.sen
}
func (self *StateTransition) To() *state.StateObject {
- if self.msg != nil && self.msg.CreatesContract() {
+ if self.msg != nil && MessageCreatesContract(self.msg) {
return nil
}
@@ -205,7 +207,7 @@ func (self *StateTransition) TransitionState() (err error) {
var ret []byte
vmenv := self.VmEnv()
var ref vm.ClosureRef
- if msg.CreatesContract() {
+ if MessageCreatesContract(msg) {
self.rec = MakeContract(msg, self.state)
ret, err, ref = vmenv.Create(sender, self.rec.Address(), self.msg.Data(), self.gas, self.gasPrice, self.value)
diff --git a/core/transaction_pool.go b/core/transaction_pool.go
index da91ec568..58c2255a4 100644
--- a/core/transaction_pool.go
+++ b/core/transaction_pool.go
@@ -131,12 +131,6 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
return fmt.Errorf("Insufficient amount in sender's (%x) account", tx.From())
}
- if tx.IsContract() {
- if tx.GasPrice().Cmp(big.NewInt(minGasPrice)) < 0 {
- return fmt.Errorf("Gasprice too low, %s given should be at least %d.", tx.GasPrice, minGasPrice)
- }
- }
-
// Increment the nonce making each tx valid only once to prevent replay
// attacks
diff --git a/core/types/transaction.go b/core/types/transaction.go
index 4b75d3abd..21d455f2e 100644
--- a/core/types/transaction.go
+++ b/core/types/transaction.go
@@ -9,11 +9,8 @@ import (
"github.com/obscuren/secp256k1-go"
)
-var ContractAddr = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
-
func IsContractAddr(addr []byte) bool {
return len(addr) == 0
- //return bytes.Compare(addr, ContractAddr) == 0
}
type Transaction struct {
@@ -25,17 +22,14 @@ type Transaction struct {
data []byte
v byte
r, s []byte
-
- // Indicates whether this tx is a contract creation transaction
- contractCreation bool
}
func NewContractCreationTx(value, gas, gasPrice *big.Int, script []byte) *Transaction {
- return &Transaction{recipient: nil, value: value, gas: gas, gasPrice: gasPrice, data: script, contractCreation: true}
+ return &Transaction{recipient: nil, value: value, gas: gas, gasPrice: gasPrice, data: script}
}
func NewTransactionMessage(to []byte, value, gas, gasPrice *big.Int, data []byte) *Transaction {
- return &Transaction{recipient: to, value: value, gasPrice: gasPrice, gas: gas, data: data, contractCreation: IsContractAddr(to)}
+ return &Transaction{recipient: to, value: value, gasPrice: gasPrice, gas: gas, data: data}
}
func NewTransactionFromBytes(data []byte) *Transaction {
@@ -99,15 +93,6 @@ func (self *Transaction) To() []byte {
return self.recipient
}
-func (tx *Transaction) CreatesContract() bool {
- return tx.contractCreation
-}
-
-/* Deprecated */
-func (tx *Transaction) IsContract() bool {
- return tx.CreatesContract()
-}
-
func (tx *Transaction) Curve() (v byte, r []byte, s []byte) {
v = tx.v
r = ethutil.LeftPadBytes(tx.r, 32)
@@ -192,10 +177,6 @@ func (tx *Transaction) RlpValueDecode(decoder *ethutil.Value) {
tx.r = decoder.Get(7).Bytes()
tx.s = decoder.Get(8).Bytes()
-
- if IsContractAddr(tx.recipient) {
- tx.contractCreation = true
- }
}
func (tx *Transaction) String() string {