-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add event system to blockstore #4131
Conversation
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
366dcee
to
1aecf6f
Compare
Benchmark results: BenchmarkEventFireSingle-12 1000000 24.1 ns/op BenchmarkEventFireMultiple-12 1000000 4.37 ns/op and zero allocations (to wide to fit). License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
Results of benchmark:
and zero allocations (to wide to fit). |
The codelimate is dubious, for some reason it is old status but the codecov side is green. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other than that one small nitpick LGTM
filestore/filestore.go
Outdated
@@ -10,9 +10,10 @@ package filestore | |||
import ( | |||
"context" | |||
|
|||
"gx/ipfs/QmVA4mafxbfH5aEvNz8fyoxC6J1xhAtw88B4GerPznSZBg/go-block-format" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be below
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
So, put/delete events make a lot of sense, IMO. However...
I'm weary of event based systems like this. I used to implement everything this way but ended up deeply regretting it years down the road because it makes it very difficult to determine what happens at any given point in time and what's responsible for what. Personally, I'd prefer some kind of dispatching, pluggable, multi-level blockservice. |
This would also allow later to build an API to give locality update (block added/removed). This is very useful when you build an app on top of IPFS. |
(no longer applies) |
This is a small stub of something I hope we shift our blockstore in future.
With additional events like EventGet, EventHas we would be able to:
This stub is to allow me to start working on tri-colour GC for go-ipfs which would replace the stop world GC we currently have.
Later I would also like to swich the current Has caches to base onto the event system.
It is quite possible that in future we will have to implement priority to the events but this can be solved.