Replay network subscriptions on startup#33
Conversation
Codecov Report
|
ba60ae9 to
59fd786
Compare
woutslakhorst
left a comment
There was a problem hiding this comment.
We also need an issue or conversation to keep track of the architecture of dagDocument to VDR/VCR
| } | ||
|
|
||
| func (s *replayingDAGPublisher) PayloadWritten(_ interface{}) { | ||
| s.publish(hash.EmptyHash()) |
There was a problem hiding this comment.
Because when the node receives payload, we'd have to look up in the payload hash -> document index where we should resume (and check whether that's a resumation point) but that's not accessible from this type (it's an internal of the BBolt DAG implementation). So I chose to just resume from the resumation points regardless whether we can actually go forward with publishing to subscribers (it can only resume when the payload's there)
When we receive payload chances are pretty big that its from a resumation point, especially when your node is in sync with other nodes. We could optimize this later if it turns out to be a bottleneck.
I'll draw something up, made an issue just to be sure; |
woutslakhorst
left a comment
There was a problem hiding this comment.
Could you ignore/approve issues in codeclimate before merging?
59fd786 to
fb6a336
Compare
Since the current DIDStore is an in-memory implementation, the DID Documents stored in Nuts Network must be loaded into it (through the subscribers) every time the node is started. This actually makes things much simpler: subscriptions don't have to be persistent, meaning that we can replay the DAG every time a new subscription is added.
This PR alters the DAG subscription handling such that it uses an altered version of the Bread-First DAG walker, one which keeps track of which documents couldn't be processed at that point: e.g. when the payload is missing, meaning we can't call the subscribers for that particular document AND all subsequent documents on that branch. When we receive payload we can call the walker again, resuming at the documents we previously stopped.
Fixes #8