diff options
author | obscuren <geffobscura@gmail.com> | 2014-08-01 16:30:19 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-08-01 16:30:19 +0800 |
commit | 2e7cf835222274a311302c33498cf83bb2593b7a (patch) | |
tree | 6689e7017a14d2198771fbe5148bb8ad13e9e8a1 /ethreact/README.md | |
parent | 5ede1224e48fd82961bd4a0b2ec1a3eda0b6d99b (diff) | |
parent | 8bed47a2d4377b7a49f34350ae5c5ea50464b95d (diff) | |
download | dexon-2e7cf835222274a311302c33498cf83bb2593b7a.tar.gz dexon-2e7cf835222274a311302c33498cf83bb2593b7a.tar.zst dexon-2e7cf835222274a311302c33498cf83bb2593b7a.zip |
Merge branch 'ethersphere-feature/ethutil-refactor' into develop
Diffstat (limited to 'ethreact/README.md')
-rw-r--r-- | ethreact/README.md | 28 |
1 files changed, 28 insertions, 0 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 |