Skip to content
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

rocksdb: minor tweaks #613

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ class Hypercore extends EventEmitter {
}

_isWritable () {
if (this.draft) return true
return !this._readonly && !!(this.keyPair && this.keyPair.secretKey)
}

Expand Down
9 changes: 8 additions & 1 deletion lib/session-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,14 @@ module.exports = class SessionState {
await this.mutex.lock()

try {
await this._overwrite(state, length, treeLength, null)
const origLength = this.tree.length

const tree = await this._overwrite(state, length, treeLength, null)

const bitfield = { start: treeLength, length: tree.length - treeLength, drop: false }

if (treeLength < origLength) this.ontruncate(tree, treeLength, origLength)
if (treeLength < tree.length) this.onappend(tree, bitfield)

return {
length: this.tree.length,
Expand Down
Loading