Add methods for bloom filter compression#458
Merged
quantumagi merged 1 commit intostratisproject:masterfrom Mar 15, 2021
Merged
Add methods for bloom filter compression#458quantumagi merged 1 commit intostratisproject:masterfrom
quantumagi merged 1 commit intostratisproject:masterfrom
Conversation
Contributor
|
@quantumagi can you detail what the requirement here is for the compression? |
Contributor
Author
|
@fassadlr , Done. |
zeptin
approved these changes
Mar 15, 2021
Contributor
|
@quantumagi merge this to #450 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The purpose of this PR is to reduce the serialized size of the bloom filter used by the
PosBlockHeader. Since the bloom filter is basically a bit map of 2048 bits contained in 256 bytes it is quite possible that many of those bytes may be0. This compression scheme reduces the number of0bytes by storing the number of0bytes instead of the bytes themselves. As an example 2560bytes would be encoded as1 255 0- where 1 is the total compressed length - 1, followed by 255 zeros and finally one more zero. The general pattern is<compressed length - 1> [<number of zeros> <explicit byte>] x n where n > 0. The last explicit byte is added only if required. If the compressed length exceeds 255 then the bloom filter is not compressed when serialized, which is flagged by255in the first byte. A0in the first byte is not possible and is reserved for future use.This is a backwards compatible change required by system contract and does not affect legacy bloom filters.
This PR is being split off from PR #450 to reduce the size of that PR.