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

Require tangles.group.previous to be at least size 1 #11

Closed
Powersource opened this issue Oct 12, 2022 · 2 comments
Closed

Require tangles.group.previous to be at least size 1 #11

Powersource opened this issue Oct 12, 2022 · 2 comments

Comments

@Powersource
Copy link
Collaborator

Powersource commented Oct 12, 2022

In the current tanglePrune code from tribes1 it is able to prune until the previous array is empty. Is that a good idea or likely to break tangle logic?

while (
content.tangles[tangle].previous.length &&
getLength(content) > maxSize
) {
content.tangles[tangle].previous.pop()
}

@mixmix
Copy link
Member

mixmix commented Oct 12, 2022

Nice catch. I think it should prune down to one at lowest

@Powersource Powersource changed the title Should we require tangles.group.previous to be at least size 1? Require tangles.group.previous to be at least size 1 Oct 13, 2022
@Powersource
Copy link
Collaborator Author

The new logic has fixed this

module.exports = function prunePublish(ssb, content, keys, cb) {
const group = content.tangles.group
ssb.db.create({ keys, content, encryptionFormat: 'box2' }, (err, msg) => {
if (err) {
if (group.previous.length > 1) {
const halfLength = Math.ceil(group.previous.length / 2)
group.previous = group.previous.slice(0, halfLength)
return prunePublish(ssb, content, keys, cb)
} else {
return cb(err)
}
}
cb(null, msg)
})
}

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

No branches or pull requests

2 participants