Filter and mutex locks added
This commit is contained in:
parent
815ead7107
commit
567428fb34
@ -80,11 +80,6 @@
|
|||||||
refresh();
|
refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
var ev = contract.SingleTransact({})
|
|
||||||
ev.watch(function(log) {
|
|
||||||
someElement.innerHTML += "tnaheousnthaoeu";
|
|
||||||
});
|
|
||||||
|
|
||||||
eth.watch('chain').changed(function() {
|
eth.watch('chain').changed(function() {
|
||||||
refresh();
|
refresh();
|
||||||
});
|
});
|
||||||
|
@ -394,7 +394,6 @@ func (gui *Gui) update() {
|
|||||||
miningLabel := gui.getObjectByName("miningLabel")
|
miningLabel := gui.getObjectByName("miningLabel")
|
||||||
|
|
||||||
events := gui.eth.EventMux().Subscribe(
|
events := gui.eth.EventMux().Subscribe(
|
||||||
//eth.PeerListEvent{},
|
|
||||||
core.NewBlockEvent{},
|
core.NewBlockEvent{},
|
||||||
core.TxPreEvent{},
|
core.TxPreEvent{},
|
||||||
core.TxPostEvent{},
|
core.TxPostEvent{},
|
||||||
@ -410,7 +409,6 @@ func (gui *Gui) update() {
|
|||||||
switch ev := ev.(type) {
|
switch ev := ev.(type) {
|
||||||
case core.NewBlockEvent:
|
case core.NewBlockEvent:
|
||||||
gui.processBlock(ev.Block, false)
|
gui.processBlock(ev.Block, false)
|
||||||
//gui.setWalletValue(gui.eth.ChainManager().State().GetBalance(gui.address()), nil)
|
|
||||||
balance := ethutil.CurrencyToString(gui.eth.ChainManager().State().GetBalance(gui.address()))
|
balance := ethutil.CurrencyToString(gui.eth.ChainManager().State().GetBalance(gui.address()))
|
||||||
gui.getObjectByName("balanceLabel").Set("text", fmt.Sprintf("%v", balance))
|
gui.getObjectByName("balanceLabel").Set("text", fmt.Sprintf("%v", balance))
|
||||||
|
|
||||||
|
@ -79,6 +79,7 @@ type ChainManager struct {
|
|||||||
genesisBlock *types.Block
|
genesisBlock *types.Block
|
||||||
// Last known total difficulty
|
// Last known total difficulty
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
|
tsmu sync.RWMutex
|
||||||
td *big.Int
|
td *big.Int
|
||||||
currentBlock *types.Block
|
currentBlock *types.Block
|
||||||
lastBlockHash []byte
|
lastBlockHash []byte
|
||||||
@ -131,9 +132,19 @@ func (self *ChainManager) State() *state.StateDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *ChainManager) TransState() *state.StateDB {
|
func (self *ChainManager) TransState() *state.StateDB {
|
||||||
|
self.tsmu.RLock()
|
||||||
|
defer self.tsmu.RUnlock()
|
||||||
|
//tmp := self.transState
|
||||||
|
|
||||||
return self.transState
|
return self.transState
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *ChainManager) setTransState(statedb *state.StateDB) {
|
||||||
|
self.tsmu.Lock()
|
||||||
|
defer self.tsmu.Unlock()
|
||||||
|
self.transState = statedb
|
||||||
|
}
|
||||||
|
|
||||||
func (bc *ChainManager) setLastBlock() {
|
func (bc *ChainManager) setLastBlock() {
|
||||||
data, _ := bc.db.Get([]byte("LastBlock"))
|
data, _ := bc.db.Get([]byte("LastBlock"))
|
||||||
if len(data) != 0 {
|
if len(data) != 0 {
|
||||||
@ -376,7 +387,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
|
|||||||
|
|
||||||
self.setTotalDifficulty(td)
|
self.setTotalDifficulty(td)
|
||||||
self.insert(block)
|
self.insert(block)
|
||||||
self.transState = state.New(cblock.Root(), self.db)
|
self.setTransState(state.New(cblock.Root(), self.db))
|
||||||
|
|
||||||
self.eventMux.Post(ChainEvent{block, td})
|
self.eventMux.Post(ChainEvent{block, td})
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ type FilterOptions struct {
|
|||||||
Earliest int64
|
Earliest int64
|
||||||
Latest int64
|
Latest int64
|
||||||
|
|
||||||
Address []byte
|
Address [][]byte
|
||||||
Topics [][]byte
|
Topics [][]byte
|
||||||
|
|
||||||
Skip int
|
Skip int
|
||||||
@ -29,7 +29,7 @@ type Filter struct {
|
|||||||
earliest int64
|
earliest int64
|
||||||
latest int64
|
latest int64
|
||||||
skip int
|
skip int
|
||||||
address []byte
|
address [][]byte
|
||||||
max int
|
max int
|
||||||
topics [][]byte
|
topics [][]byte
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ func (self *Filter) SetLatestBlock(latest int64) {
|
|||||||
self.latest = latest
|
self.latest = latest
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Filter) SetAddress(addr []byte) {
|
func (self *Filter) SetAddress(addr [][]byte) {
|
||||||
self.address = addr
|
self.address = addr
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +145,8 @@ func (self *Filter) FilterLogs(logs state.Logs) state.Logs {
|
|||||||
// Filter the logs for interesting stuff
|
// Filter the logs for interesting stuff
|
||||||
Logs:
|
Logs:
|
||||||
for _, log := range logs {
|
for _, log := range logs {
|
||||||
if !bytes.Equal(self.address, log.Address()) {
|
if !includes(self.address, log.Address()) {
|
||||||
|
//if !bytes.Equal(self.address, log.Address()) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,8 +164,18 @@ Logs:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *Filter) bloomFilter(block *types.Block) bool {
|
func (self *Filter) bloomFilter(block *types.Block) bool {
|
||||||
if len(self.address) > 0 && !types.BloomLookup(block.Bloom(), self.address) {
|
if len(self.address) > 0 {
|
||||||
return false
|
var included bool
|
||||||
|
for _, addr := range self.address {
|
||||||
|
if types.BloomLookup(block.Bloom(), addr) {
|
||||||
|
included = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !included {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, topic := range self.topics {
|
for _, topic := range self.topics {
|
||||||
|
@ -26,6 +26,7 @@ var (
|
|||||||
|
|
||||||
defaultBootNodes = []*discover.Node{
|
defaultBootNodes = []*discover.Node{
|
||||||
discover.MustParseNode("enode://6cdd090303f394a1cac34ecc9f7cda18127eafa2a3a06de39f6d920b0e583e062a7362097c7c65ee490a758b442acd5c80c6fce4b148c6a391e946b45131365b@54.169.166.226:30303"),
|
discover.MustParseNode("enode://6cdd090303f394a1cac34ecc9f7cda18127eafa2a3a06de39f6d920b0e583e062a7362097c7c65ee490a758b442acd5c80c6fce4b148c6a391e946b45131365b@54.169.166.226:30303"),
|
||||||
|
discover.MustParseNode("enode://d1760a33c2f25c3b419ee4f6787fb0ea148828f5e678f0450d4be978fef908b42fc47a4c0fbf19832754f17881d381e50364fa93be42f31801d60ac64933f0a5@127.0.0.1:30303"),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ type EasyPow struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func New() *EasyPow {
|
func New() *EasyPow {
|
||||||
return &EasyPow{turbo: false}
|
return &EasyPow{turbo: true}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pow *EasyPow) GetHashrate() int64 {
|
func (pow *EasyPow) GetHashrate() int64 {
|
||||||
|
@ -29,8 +29,8 @@ func NewFilterFromMap(object map[string]interface{}, eth core.Backend) *core.Fil
|
|||||||
}
|
}
|
||||||
|
|
||||||
if object["address"] != nil {
|
if object["address"] != nil {
|
||||||
val := ethutil.NewValue(object["address"])
|
//val := ethutil.NewValue(object["address"])
|
||||||
filter.SetAddress(fromHex(val.Str()))
|
//filter.SetAddress(fromHex(val.Str()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if object["max"] != nil {
|
if object["max"] != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user