You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 24, 2022. It is now read-only.
light.js is used when pubsub on state is not available (e.g. on a light client). In that case, we need to find the minimal viable calls to track the relevant portion of the state we're interested in. (track == be notified when it changes).
Some examples:
To track the balance of an ETH account, we subscribe to new heads, and on each new head, we make a JSONRPC call api.eth.getBalance(...)
To track the balance of an account in a ERC20 contract, we subscribe to the events, and make a balanceOf call on events that are relevant to the tracked account.
An immediate remark that comes up is that there's a lot of "on each ..., do ...". And the best data structure to express "on each ..., do ..." is a dependency graph. Luckily, it also fits perfectly well with reactive programming, see for example reactive-graph.
We could refactor light.js into a graph structure for RxJS, similar to reactive-graph, where:
nodes are Observables
edges are pipes
So:
We start by manually defining some source nodes (STARTUP, NEW_HEAD, EVERY_SECOND), they don't have incoming edges.
Define all other nodes (balanceOf$, syncing$...) by combing source nodes (or other nodes), with the correct pipes.
The text was updated successfully, but these errors were encountered:
light.js is used when pubsub on state is not available (e.g. on a light client). In that case, we need to find the minimal viable calls to track the relevant portion of the state we're interested in. (track == be notified when it changes).
Some examples:
api.eth.getBalance(...)
balanceOf
call on events that are relevant to the tracked account.An immediate remark that comes up is that there's a lot of "on each ..., do ...". And the best data structure to express "on each ..., do ..." is a dependency graph. Luckily, it also fits perfectly well with reactive programming, see for example
reactive-graph
.We could refactor light.js into a graph structure for RxJS, similar to reactive-graph, where:
So:
balanceOf$
,syncing$
...) by combing source nodes (or other nodes), with the correct pipes.The text was updated successfully, but these errors were encountered: