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: commit overwrites full state #587

Merged
merged 31 commits into from
Nov 12, 2024

Conversation

chm-diederichs
Copy link
Contributor

No description provided.

@chm-diederichs chm-diederichs changed the base branch from main to rocksdb October 18, 2024 15:39
@chm-diederichs chm-diederichs force-pushed the rocksdb-commit-updates-dependency branch from 31cdf36 to d418634 Compare October 18, 2024 15:53
@chm-diederichs
Copy link
Contributor Author

depends on holepunchto/hypercore-storage#26

@chm-diederichs chm-diederichs changed the title rocksdb: drafts support truncations and reorgs rocksdb: commit overwrites full state Nov 12, 2024
let remove = 1

if (lower.start < lower.end) this.ranges.splice(i++, remove--, lower)
this.ranges.splice(i++, remove, { start, end, value })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ++ is sus to me, we use i again below but normally you'd i-- it as you are removing from the array

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only one of them removes from the array, but they all add to it, so it ends up being:

  arr = [0]
  arr.splice(i++, 1, 1)
  arr.splice(i++, 0, 2)
  arr.splice(i, 0, 3)

  // arr === [1, 2, 3]

const last = (page.index + 1) * (buf.byteLength << 3)
const offset = page.index * buf.byteLength << 3
const last = (pageIndex + 1) * (buf.byteLength << 3)
const offset = pageIndex * buf.byteLength << 3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add parens around the buf.. << 3 part

lib/core.js Outdated
const promises = []
if (this.verifier === null) {
throw INVALID_OPERATION('Cannot commit without manifest') // easier to assert than upsert
} else if (this.tree.length < length && !signature) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove else, just two ifs

@chm-diederichs chm-diederichs merged commit afe2a32 into rocksdb Nov 12, 2024
4 checks passed
@chm-diederichs chm-diederichs deleted the rocksdb-commit-updates-dependency branch November 12, 2024 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants