Description
Through my work with https://github.com/dashhive/DashJoin.js and https://github.com/dashhive/DashGov.js I believe I've discovered the minimal layer of abstraction that maximizes practical use of the P2P network without a strong dependency on a particular type of network proxy or protocol.
- create a state machine for byte stream
- states: 'header', 'payload', 'result', 'error'
- utility wrapper for websocket
- utility wrapper for node tcp
- option to automatically handle version / verack
- ption to automatically handle ping / pong
- option to automatically pool recent
inv
messages - promise-emit all messages that are not handled automatically
Since the general node and EventEmitter approach doesn't work well with async/await, I believe I'll be using a pattern of let message = await session.accept();
to more closely model the familiar pattern found in Go and other languages.
This will probably become a hard dependency of DashJoin.js, and future P2P development I DashGov.js (if any). It's almost as lightweight as https://github.com/dashhive/DashTx.js/pull/79/files#diff-dcba0694ad59e9893af33895826b399745c8e3ace322c260c2e9ab5244bb0427, but just not quite lightweight enough to justify inclusion.