aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-29 21:20:42 +0800
committerobscuren <geffobscura@gmail.com>2014-10-29 21:20:42 +0800
commit9e2f071d26d5c4ed343d2a91e48fec4e7751b99d (patch)
treefdfde82ceb0c6736b82c08c7002055ee95cfef67 /ethchain
parentfb4113dab4df8480c77bdcb707fa6b5408755b79 (diff)
downloaddexon-9e2f071d26d5c4ed343d2a91e48fec4e7751b99d.tar
dexon-9e2f071d26d5c4ed343d2a91e48fec4e7751b99d.tar.gz
dexon-9e2f071d26d5c4ed343d2a91e48fec4e7751b99d.tar.bz2
dexon-9e2f071d26d5c4ed343d2a91e48fec4e7751b99d.tar.lz
dexon-9e2f071d26d5c4ed343d2a91e48fec4e7751b99d.tar.xz
dexon-9e2f071d26d5c4ed343d2a91e48fec4e7751b99d.tar.zst
dexon-9e2f071d26d5c4ed343d2a91e48fec4e7751b99d.zip
Removed events from the state manager
Diffstat (limited to 'ethchain')
-rw-r--r--ethchain/block.go34
-rw-r--r--ethchain/bloom9.go9
-rw-r--r--ethchain/chain_manager.go2
-rw-r--r--ethchain/filter.go6
-rw-r--r--ethchain/state_manager.go15
-rw-r--r--ethchain/state_transition.go2
6 files changed, 19 insertions, 49 deletions
diff --git a/ethchain/block.go b/ethchain/block.go
index e4a1aaf24..b31d68e4d 100644
--- a/ethchain/block.go
+++ b/ethchain/block.go
@@ -5,7 +5,6 @@ import (
"fmt"
"math/big"
"sort"
- _ "strconv"
"time"
"github.com/ethereum/go-ethereum/ethcrypto"
@@ -240,15 +239,19 @@ func (block *Block) SetUncles(uncles []*Block) {
block.UncleSha = ethcrypto.Sha3(ethutil.Encode(block.rlpUncles()))
}
-func (self *Block) SetReceipts(receipts []*Receipt, txs []*Transaction) {
+func (self *Block) SetReceipts(receipts Receipts) {
self.receipts = receipts
+ self.SetReceiptHash(receipts)
+}
+
+func (self *Block) SetTransactions(txs Transactions) {
self.setTransactions(txs)
+ self.SetTransactionHash(txs)
}
-func (block *Block) setTransactions(txs []*Transaction) {
+func (block *Block) setTransactions(txs Transactions) {
block.transactions = txs
-
- block.LogsBloom = CreateBloom(txs)
+ block.LogsBloom = CreateBloom(block)
}
func (self *Block) SetTransactionHash(transactions Transactions) {
@@ -424,22 +427,7 @@ func (self *Block) Size() ethutil.StorageSize {
return ethutil.StorageSize(len(self.RlpEncode()))
}
-/*
-func DeriveReceiptHash(receipts Receipts) (sha []byte) {
- trie := ethtrie.New(ethutil.Config.Db, "")
- for i, receipt := range receipts {
- trie.Update(string(ethutil.NewValue(i).Encode()), string(ethutil.NewValue(receipt.RlpData()).Encode()))
- }
-
- switch trie.Root.(type) {
- case string:
- sha = []byte(trie.Root.(string))
- case []byte:
- sha = trie.Root.([]byte)
- default:
- panic(fmt.Sprintf("invalid root type %T", trie.Root))
- }
-
- return sha
+// Implement RlpEncodable
+func (self *Block) RlpData() interface{} {
+ return self.Value().Val
}
-*/
diff --git a/ethchain/bloom9.go b/ethchain/bloom9.go
index 742610169..508644b62 100644
--- a/ethchain/bloom9.go
+++ b/ethchain/bloom9.go
@@ -6,9 +6,10 @@ import (
"github.com/ethereum/go-ethereum/vm"
)
-func CreateBloom(txs Transactions) []byte {
+func CreateBloom(block *Block) []byte {
bin := new(big.Int)
- for _, tx := range txs {
+ bin.Or(bin, bloom9(block.Coinbase))
+ for _, tx := range block.Transactions() {
bin.Or(bin, LogsBloom(tx.logs))
}
@@ -36,9 +37,7 @@ func bloom9(b []byte) *big.Int {
r := new(big.Int)
for _, i := range []int{0, 2, 4} {
t := big.NewInt(1)
-
- //r |= 1 << (uint64(b[i+1]) + 256*(uint64(b[i])&1))
- r.Or(r, t.Rsh(t, uint(b[i+1])+256*(uint(b[i])&1)))
+ r.Or(r, t.Lsh(t, uint(b[i+1])+256*(uint(b[i])&1)))
}
return r
diff --git a/ethchain/chain_manager.go b/ethchain/chain_manager.go
index 970b93ca3..46990bb22 100644
--- a/ethchain/chain_manager.go
+++ b/ethchain/chain_manager.go
@@ -87,8 +87,6 @@ func (bc *ChainManager) Reset() {
bc.genesisBlock.state.Trie.Sync()
// Prepare the genesis block
bc.Add(bc.genesisBlock)
- //fk := append([]byte("bloom"), bc.genesisBlock.Hash()...)
- //bc.Ethereum.Db().Put(fk, make([]byte, 255))
bc.CurrentBlock = bc.genesisBlock
bc.SetTotalDifficulty(ethutil.Big("0"))
diff --git a/ethchain/filter.go b/ethchain/filter.go
index cf31766c4..55d7072e2 100644
--- a/ethchain/filter.go
+++ b/ethchain/filter.go
@@ -170,12 +170,6 @@ func (self *Filter) FilterMessages(msgs []*ethstate.Message) []*ethstate.Message
}
func (self *Filter) bloomFilter(block *Block) bool {
- //fk := append([]byte("bloom"), block.Hash()...)
- //bin, err := self.eth.Db().Get(fk)
- //if err != nil {
- // fmt.Println(err)
- //}
-
// TODO update to the new bloom filter
bloom := NewBloomFilter(nil)
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go
index 774933e48..e45d44752 100644
--- a/ethchain/state_manager.go
+++ b/ethchain/state_manager.go
@@ -101,7 +101,7 @@ func (self *StateManager) Stop() {
func (self *StateManager) updateThread() {
for ev := range self.events.Chan() {
for _, block := range ev.(Blocks) {
- err := self.Process(block, false)
+ err := self.Process(block)
if err != nil {
statelogger.Infoln(err)
statelogger.Debugf("Block #%v failed (%x...)\n", block.Number, block.Hash()[0:4])
@@ -206,7 +206,7 @@ done:
return receipts, handled, unhandled, erroneous, err
}
-func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
+func (sm *StateManager) Process(block *Block) (err error) {
// Processing a blocks may never happen simultaneously
sm.mutex.Lock()
defer sm.mutex.Unlock()
@@ -281,18 +281,9 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
sm.transState = state.Copy()
- // Create a bloom bin for this block
- //filter := sm.createBloomFilter(state)
- // Persist the data
- //fk := append([]byte("bloom"), block.Hash()...)
- //sm.eth.Db().Put(fk, filter.Bin())
-
statelogger.Infof("Imported block #%d (%x...)\n", block.Number, block.Hash()[0:4])
- if dontReact == false {
- sm.eth.EventMux().Post(NewBlockEvent{block})
- state.Manifest().Reset()
- }
+ state.Manifest().Reset()
sm.eth.TxPool().RemoveSet(block.Transactions())
} else {
diff --git a/ethchain/state_transition.go b/ethchain/state_transition.go
index 4e95e55ba..809e5ad6a 100644
--- a/ethchain/state_transition.go
+++ b/ethchain/state_transition.go
@@ -231,7 +231,7 @@ func (self *StateTransition) TransitionState() (err error) {
msg.Output = ret
} else {
// Add default LOG. Default = big(sender.addr) + 1
- addr := ethutil.BigD(sender.Address())
+ addr := ethutil.BigD(receiver.Address())
tx.addLog(vm.Log{sender.Address(), [][]byte{addr.Add(addr, ethutil.Big1).Bytes()}, nil})
}
}