-
Notifications
You must be signed in to change notification settings - Fork 182
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
Use async hypercore-encryption
module
#676
Conversation
e5e6ba0
to
ee015b2
Compare
we need to publish https://github.com/holepunchto/hypercore-block-encryption once we're happy with it |
index.js
Outdated
@@ -1119,3 +1140,16 @@ function getEncryptionOption (opts) { | |||
if (!opts.encryption) return null | |||
return b4a.isBuffer(opts.encryption) ? { key: opts.encryption } : opts.encryption | |||
} | |||
|
|||
function isEncryptionProvider (e) { | |||
return !!(e && (e instanceof HypercoreEncryption || (e.encrypt && typeof e.encrypt === 'function'))) |
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 can just do the instanceof check
@@ -1046,14 +1077,14 @@ function toHex (buf) { | |||
return buf && b4a.toString(buf, 'hex') | |||
} | |||
|
|||
function preappend (blocks) { | |||
async function preappend (blocks) { | |||
const offset = this.state.length | |||
const fork = this.state.encryptionFork | |||
|
|||
if (this.encryption.compat !== this.core.compat) this._updateEncryption() | |||
|
|||
for (let i = 0; i < blocks.length; i++) { |
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.
Should this maybe be done in parallel using something like await Promise.all(blocks.map(encrypt))
? This seems like a major perf regression otherwise.
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.
same as today since sync right now, but we can adjust later. the async'ness is there for flexibility. for now lets keep it simple.
hypercore-block-encryption
modulehypercore-encryption
module
No description provided.