-
Notifications
You must be signed in to change notification settings - Fork 25
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
Expose maxCacheSize opt (for system db) #156
Conversation
Move the checkout to be an optional arg also so we dont have optional positionals |
Done (I don't think SystemView is part of the public API, so should be fine, but in theory this is a breaking change) |
lib/system.js
Outdated
@@ -68,7 +70,13 @@ module.exports = class SystemView extends ReadyResource { | |||
} | |||
|
|||
async checkout (length) { | |||
const checkout = new SystemView(this.core.session(), length) | |||
const checkout = new SystemView( |
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.
Note: this was added with the last commit (had missed this usage of new SystemView on my initial pass, so it wasn't yet passing through the maxCacheSize)
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.
what do you think about making the opt explicit here?
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.
checkout(length, { maxCacheSize = this.db.maxCacheSize } = {})
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.
Yeah, makes sense. See #156 (comment) though, we might be iterating on a method that's no longer relevant
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.
ok added it anyways
lib/system.js
Outdated
@@ -12,12 +12,14 @@ const DIGEST = subs.sub(b4a.from([0])) | |||
const MEMBERS = subs.sub(b4a.from([1])) | |||
|
|||
module.exports = class SystemView extends ReadyResource { | |||
constructor (core, checkout = 0) { | |||
constructor (core, opts = {}) { |
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.
{ checkout = 0, maxCacheSize = 0 } = {}
lib/system.js
Outdated
this.core.session(), | ||
{ | ||
checkout: length, | ||
maxCacheSize: this.maxCacheSize |
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.
dont think this prop is on the system, you should get it from the existing db
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.
You're right, well-spotted, I fixed it.
I think that method is never used though (from what I can see, it's never used in autobase itself, nor is it tested, and I don't think it makes sense to access it directly from outside autobase), so might make sense to just remove it in a follow-up PR, or perhaps add a test
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.
ahh I think checkout will stick around for a while, it's quite useful to have
03c23b4
to
01c69b8
Compare
Note: the current implementation is not ideal for maintaining, given that the
SystemView
is created in 5 different places and it needs to be explicitly passed themaxCacheSize
option every time. Might make sense to refactor to acreateSystemView(core, length)
method which is called in each of those 5 cases, wherecreateSystemView
is responsible for adding the opts (for now onlymaxCacheSize
).