aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-04-24 20:42:31 +0800
committerobscuren <geffobscura@gmail.com>2014-04-24 20:42:31 +0800
commitc535d0d24623caafcab084546f85f1f70cb2ac67 (patch)
tree6a746c068be190a6737d88675e72a9af03dc197a
parentbb72347acf8a82d1c20e8aae25c84e5dc75903dd (diff)
downloadgo-tangerine-c535d0d24623caafcab084546f85f1f70cb2ac67.tar
go-tangerine-c535d0d24623caafcab084546f85f1f70cb2ac67.tar.gz
go-tangerine-c535d0d24623caafcab084546f85f1f70cb2ac67.tar.bz2
go-tangerine-c535d0d24623caafcab084546f85f1f70cb2ac67.tar.lz
go-tangerine-c535d0d24623caafcab084546f85f1f70cb2ac67.tar.xz
go-tangerine-c535d0d24623caafcab084546f85f1f70cb2ac67.tar.zst
go-tangerine-c535d0d24623caafcab084546f85f1f70cb2ac67.zip
Added new block sub for webapp
-rw-r--r--ethereal/ui/ui_lib.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/ethereal/ui/ui_lib.go b/ethereal/ui/ui_lib.go
index 9191e5ea9..08e2267a7 100644
--- a/ethereal/ui/ui_lib.go
+++ b/ethereal/ui/ui_lib.go
@@ -70,8 +70,34 @@ func (ui *UiLib) OpenHtml(path string) {
win.Set("url", path)
go func() {
+ blockChan := make(chan ethutil.React, 1)
+ quitChan := make(chan bool)
+
+ go func() {
+ out:
+ for {
+ select {
+ case <-quitChan:
+ ui.eth.Reactor().Unsubscribe("newBlock", blockChan)
+ break out
+ case block := <-blockChan:
+ if block, ok := block.Resource.(*ethchain.Block); ok {
+ b := &Block{Number: int(block.BlockInfo().Number), Hash: ethutil.Hex(block.Hash())}
+ win.ObjectByName("webView").Call("onNewBlockCb", b)
+ }
+ }
+ }
+
+ // Clean up
+ close(blockChan)
+ close(quitChan)
+ }()
+ ui.eth.Reactor().Subscribe("newBlock", blockChan)
+
win.Show()
win.Wait()
+
+ quitChan <- true
}()
}