aboutsummaryrefslogtreecommitdiffstats
path: root/ethreact
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2014-07-21 22:10:56 +0800
committerzelig <viktor.tron@gmail.com>2014-07-21 22:10:56 +0800
commit67528cf9709519458ab5500cb7cf54664dd20167 (patch)
tree8eff3d0a7c217926f1631a5eaec1b0e54749bc4b /ethreact
parent13cc220c0d7f9b31478b49a1109d44aeab66b372 (diff)
downloadgo-tangerine-67528cf9709519458ab5500cb7cf54664dd20167.tar
go-tangerine-67528cf9709519458ab5500cb7cf54664dd20167.tar.gz
go-tangerine-67528cf9709519458ab5500cb7cf54664dd20167.tar.bz2
go-tangerine-67528cf9709519458ab5500cb7cf54664dd20167.tar.lz
go-tangerine-67528cf9709519458ab5500cb7cf54664dd20167.tar.xz
go-tangerine-67528cf9709519458ab5500cb7cf54664dd20167.tar.zst
go-tangerine-67528cf9709519458ab5500cb7cf54664dd20167.zip
ethreact/README.md
Diffstat (limited to 'ethreact')
-rw-r--r--ethreact/README.md28
-rw-r--r--ethreact/reactor.go2
2 files changed, 29 insertions, 1 deletions
diff --git a/ethreact/README.md b/ethreact/README.md
new file mode 100644
index 000000000..61af8a572
--- /dev/null
+++ b/ethreact/README.md
@@ -0,0 +1,28 @@
+## Reactor
+
+Reactor is the internal broadcast engine that allows components to be notified of ethereum stack events such as finding new blocks or change in state.
+Event notification is handled via subscription:
+
+ var blockChan = make(chan ethreact.Event, 10)
+ reactor.Subscribe("newBlock", blockChan)
+
+ethreact.Event broadcast on the channel are
+
+ type Event struct {
+ Resource interface{}
+ Name string
+ }
+
+Resource is polimorphic depending on the event type and should be typecast before use, e.g:
+
+ b := <-blockChan:
+ block := b.Resource.(*ethchain.Block)
+
+Events are guaranteed to be broadcast in order but the broadcast never blocks or leaks which means while the subscribing event channel is blocked (e.g., full if buffered) further messages will be skipped.
+
+The engine allows arbitrary events to be posted and subscribed to.
+
+ ethereum.Reactor().Post("newBlock", newBlock)
+
+
+ \ No newline at end of file
diff --git a/ethreact/reactor.go b/ethreact/reactor.go
index a26f82a97..7fe2356db 100644
--- a/ethreact/reactor.go
+++ b/ethreact/reactor.go
@@ -58,7 +58,7 @@ func (e *EventHandler) Remove(ch chan Event) int {
return len(e.chans)
}
-// Basic reactor resource
+// Basic reactor event
type Event struct {
Resource interface{}
Name string