-
Notifications
You must be signed in to change notification settings - Fork 28
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 opts.persistentKey (to avoid writing key to disk) #43
base: main
Are you sure you want to change the base?
Conversation
C'mon Windows! I know you can do it |
@@ -90,7 +91,7 @@ module.exports = class Corestore extends EventEmitter { | |||
if (err && err.code !== 'ENOENT') return reject(err) | |||
if (err || st.size < 32 || this._overwrite) { | |||
const key = this.primaryKey || crypto.randomBytes(32) | |||
return this._keyStorage.write(0, key, err => { | |||
return this._keyStorage.write(0, this.persistentKey ? key : b4a.alloc(0), err => { |
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 write anything if you are not persisting. just return before instead and resolve
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.
Right, the issue is that we still need to lock from the storage
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.
Although I don't remember if without writing then the file exists anyway, maybe it does, will check later!
@@ -25,6 +25,7 @@ module.exports = class Corestore extends EventEmitter { | |||
this.cores = root ? root.cores : new Map() | |||
this.cache = !!opts.cache | |||
this.primaryKey = opts.primaryKey || null | |||
this.persistentKey = opts.persistentKey !== false |
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.
could use a better name i think.
No description provided.