Add two new api endpoints using server sent events with axum sse. SSE are basically lightweight websockets using HTTP/2. This means it's trivial for the server to handle a lot of these connections.
Subscribe Contracts
Add the api /subscribe-contracts that takes:
Optional{ start: u64 }. This is the time to start from listing contracts. It is inclusive of the start.
Optional{ page: u64 }. This is the page number to list contracts from. The default is 0.
The api will act exactly like /list-contracts except that it will list all the contracts from a given start point and continue listing new contracts as they are deployed.
Subscribe Blocks
Add the api /subscribe-blocks that takes:
Optional{ start: u64 }. This is the time to start from listing blocks. It is inclusive of the start.
Optional{ page: u64 }. This is the page number to list blocks from. The default is 0.
The api will act exactly like /list-winning-blocks except that it will list all the blocks from a given start point and continue listing new blocks as they are created.
Implementation
In the rqlite-storage and memory-storage we will need to add either a notify or watch. Care must be taken to ensure that when the subscribe_* methods are called that any changes after the initial list_* are not skipped. This might make Notify unsuitable as notify_waiters does not awaken Notifys that are not yet awaiting notified.
The subsribe_ will have to track which was the last sent data and which page they were up to to avoid sending duplicate data.
Add two new api endpoints using server sent events with axum sse. SSE are basically lightweight websockets using HTTP/2. This means it's trivial for the server to handle a lot of these connections.
Subscribe Contracts
Add the api
/subscribe-contracts
that takes:{ start: u64 }
. This is the time to start from listing contracts. It is inclusive of the start.{ page: u64 }
. This is the page number to list contracts from. The default is 0. The api will act exactly like/list-contracts
except that it will list all the contracts from a given start point and continue listing new contracts as they are deployed.Subscribe Blocks
Add the api
/subscribe-blocks
that takes:{ start: u64 }
. This is the time to start from listing blocks. It is inclusive of the start.{ page: u64 }
. This is the page number to list blocks from. The default is 0. The api will act exactly like/list-winning-blocks
except that it will list all the blocks from a given start point and continue listing new blocks as they are created.Implementation
In the
rqlite-storage
andmemory-storage
we will need to add either a notify or watch. Care must be taken to ensure that when thesubscribe_*
methods are called that any changes after the initiallist_*
are not skipped. This might makeNotify
unsuitable as notify_waiters does not awakenNotify
s that are not yet awaitingnotified
.The
subsribe_
will have to track which was the last sent data and which page they were up to to avoid sending duplicate data.