aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-02 23:03:15 +0800
committerobscuren <geffobscura@gmail.com>2014-10-02 23:03:15 +0800
commit82be3054961864dfd5bbeaec2ab961f593203dbf (patch)
treeefde516d8219f253f2bc87f26ad6d4169c2dc587 /ethchain
parenta34a971b508e1bc1fbeb3c2d02cbb8686d2491d8 (diff)
downloadgo-tangerine-82be3054961864dfd5bbeaec2ab961f593203dbf.tar
go-tangerine-82be3054961864dfd5bbeaec2ab961f593203dbf.tar.gz
go-tangerine-82be3054961864dfd5bbeaec2ab961f593203dbf.tar.bz2
go-tangerine-82be3054961864dfd5bbeaec2ab961f593203dbf.tar.lz
go-tangerine-82be3054961864dfd5bbeaec2ab961f593203dbf.tar.xz
go-tangerine-82be3054961864dfd5bbeaec2ab961f593203dbf.tar.zst
go-tangerine-82be3054961864dfd5bbeaec2ab961f593203dbf.zip
Fixed inconsistencies
Diffstat (limited to 'ethchain')
-rw-r--r--ethchain/state_manager.go17
-rw-r--r--ethchain/state_transition.go4
-rw-r--r--ethchain/transaction.go11
3 files changed, 21 insertions, 11 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go
index f38666572..93fd1ec58 100644
--- a/ethchain/state_manager.go
+++ b/ethchain/state_manager.go
@@ -104,18 +104,21 @@ func (self *StateManager) Stop() {
}
func (self *StateManager) updateThread() {
- blockChan := self.eth.Eventer().Register("block")
+ blockChan := self.eth.Eventer().Register("blocks")
out:
for {
select {
case event := <-blockChan:
- block := event.Data.(*Block)
- err := self.Process(block, false)
- if err != nil {
- statelogger.Infoln(err)
- statelogger.Debugf("Block #%v failed (%x...)\n", block.Number, block.Hash()[0:4])
- statelogger.Debugln(block)
+ blocks := event.Data.(Blocks)
+ for _, block := range blocks {
+ err := self.Process(block, false)
+ if err != nil {
+ statelogger.Infoln(err)
+ statelogger.Debugf("Block #%v failed (%x...)\n", block.Number, block.Hash()[0:4])
+ statelogger.Debugln(block)
+ break
+ }
}
case <-self.quit:
diff --git a/ethchain/state_transition.go b/ethchain/state_transition.go
index 096464963..fbb729950 100644
--- a/ethchain/state_transition.go
+++ b/ethchain/state_transition.go
@@ -292,9 +292,9 @@ func (self *StateTransition) Eval(msg *ethstate.Message, script []byte, context
func MakeContract(tx *Transaction, state *ethstate.State) *ethstate.StateObject {
// Create contract if there's no recipient
if tx.IsContract() {
- addr := tx.CreationAddress()
+ addr := tx.CreationAddress(state)
- contract := state.NewStateObject(addr)
+ contract := state.GetOrNewStateObject(addr)
contract.InitCode = tx.Data
contract.State = ethstate.New(ethtrie.New(ethutil.Config.Db, ""))
diff --git a/ethchain/transaction.go b/ethchain/transaction.go
index e7e8f3a9f..ae77ee58d 100644
--- a/ethchain/transaction.go
+++ b/ethchain/transaction.go
@@ -6,6 +6,7 @@ import (
"math/big"
"github.com/ethereum/eth-go/ethcrypto"
+ "github.com/ethereum/eth-go/ethstate"
"github.com/ethereum/eth-go/ethutil"
"github.com/obscuren/secp256k1-go"
)
@@ -77,8 +78,14 @@ func (tx *Transaction) IsContract() bool {
return tx.CreatesContract()
}
-func (tx *Transaction) CreationAddress() []byte {
- return ethcrypto.Sha3Bin(ethutil.NewValue([]interface{}{tx.Sender(), tx.Nonce}).Encode())[12:]
+func (tx *Transaction) CreationAddress(state *ethstate.State) []byte {
+ // Generate a new address
+ addr := ethcrypto.Sha3Bin(ethutil.NewValue([]interface{}{tx.Sender(), tx.Nonce}).Encode())[12:]
+ //for i := uint64(0); state.GetStateObject(addr) != nil; i++ {
+ // addr = ethcrypto.Sha3Bin(ethutil.NewValue([]interface{}{tx.Sender(), tx.Nonce + i}).Encode())[12:]
+ //}
+
+ return addr
}
func (tx *Transaction) Signature(key []byte) []byte {