Fixed inconsistencies

This commit is contained in:
obscuren
2014-10-02 17:03:15 +02:00
parent a34a971b50
commit 82be305496
7 changed files with 37 additions and 25 deletions
+3 -3
View File
@@ -233,16 +233,16 @@ func (self *JSPipe) Transact(key, toStr, valueStr, gasStr, gasPriceStr, codeStr
self.obj.TxPool().QueueTransaction(tx)
if contractCreation {
logger.Infof("Contract addr %x", tx.CreationAddress())
logger.Infof("Contract addr %x", tx.CreationAddress(self.World().State()))
}
return NewJSReciept(contractCreation, tx.CreationAddress(), tx.Hash(), keyPair.Address()), nil
return NewJSReciept(contractCreation, tx.CreationAddress(self.World().State()), tx.Hash(), keyPair.Address()), nil
}
func (self *JSPipe) PushTx(txStr string) (*JSReceipt, error) {
tx := ethchain.NewTransactionFromBytes(ethutil.Hex2Bytes(txStr))
self.obj.TxPool().QueueTransaction(tx)
return NewJSReciept(tx.CreatesContract(), tx.CreationAddress(), tx.Hash(), tx.Sender()), nil
return NewJSReciept(tx.CreatesContract(), tx.CreationAddress(self.World().State()), tx.Hash(), tx.Sender()), nil
}
func (self *JSPipe) CompileMutan(code string) string {
+4 -4
View File
@@ -35,7 +35,7 @@ func NewJSBlock(block *ethchain.Block) *JSBlock {
var ptxs []JSTransaction
for _, tx := range block.Transactions() {
ptxs = append(ptxs, *NewJSTx(tx))
ptxs = append(ptxs, *NewJSTx(tx, block.State()))
}
list := ethutil.NewList(ptxs)
@@ -64,7 +64,7 @@ func (self *JSBlock) GetTransaction(hash string) *JSTransaction {
return nil
}
return NewJSTx(tx)
return NewJSTx(tx, self.ref.State())
}
type JSTransaction struct {
@@ -83,11 +83,11 @@ type JSTransaction struct {
Confirmations int `json:"confirmations"`
}
func NewJSTx(tx *ethchain.Transaction) *JSTransaction {
func NewJSTx(tx *ethchain.Transaction, state *ethstate.State) *JSTransaction {
hash := ethutil.Bytes2Hex(tx.Hash())
receiver := ethutil.Bytes2Hex(tx.Recipient)
if receiver == "0000000000000000000000000000000000000000" {
receiver = ethutil.Bytes2Hex(tx.CreationAddress())
receiver = ethutil.Bytes2Hex(tx.CreationAddress(state))
}
sender := ethutil.Bytes2Hex(tx.Sender())
createsContract := tx.CreatesContract()
+6 -4
View File
@@ -143,9 +143,10 @@ func (self *Pipe) Transact(key *ethcrypto.KeyPair, rec []byte, value, gas, price
self.obj.TxPool().QueueTransaction(tx)
if contractCreation {
logger.Infof("Contract addr %x", tx.CreationAddress())
addr := tx.CreationAddress(self.World().State())
logger.Infof("Contract addr %x\n", addr)
return tx.CreationAddress(), nil
return addr, nil
}
return tx.Hash(), nil
@@ -154,8 +155,9 @@ func (self *Pipe) Transact(key *ethcrypto.KeyPair, rec []byte, value, gas, price
func (self *Pipe) PushTx(tx *ethchain.Transaction) ([]byte, error) {
self.obj.TxPool().QueueTransaction(tx)
if tx.Recipient == nil {
logger.Infof("Contract addr %x", tx.CreationAddress())
return tx.CreationAddress(), nil
addr := tx.CreationAddress(self.World().State())
logger.Infof("Contract addr %x\n", addr)
return addr, nil
}
return tx.Hash(), nil
}