-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
reduce garbage in blockstore #4406
Conversation
These can't possibly be valid messages, so we should just drop the block.
Instead of using an in-memory datastore and dealing with the overhead of computing datastore keys, creating new blocks, etc, use an in-memory blockstore.
This blockstore lets us write to a temporary scratch location where blocks older than the specified cache time are automatically cleared.
If they end up validating, we'll write them back to the underlying blockstore. Otherwise, there's no reason to keep them.
// We use a temporary bstore here to avoid writing intermediate pieces | ||
// into the blockstore. | ||
blockstore := bstore.NewTemporary() | ||
cst := cbor.NewCborStore(blockstore) |
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.
Can the comments on 326-328 be removed? I believe this addresses them.
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.
I think they're still valid? That is, at this point we know we have a "sane" block, but it may not be otherwise valid.
But I don't know the original intention of that comment.
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.
Nice catch, should hopefully reduce the chainstore growth a bit
Avoid writing messages/blocks that may not be useful to the blockstore until we've validated them.