-
Notifications
You must be signed in to change notification settings - Fork 13
BIP 158: Update filter construction #6
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
Conversation
gcs/builder/builder.go
Outdated
return gcs.BuildGCSFilter(b.p, b.key, b.data) | ||
dataSlice := make([][]byte, 0, len(b.data)) | ||
for encoded := range b.data { | ||
item, err := base64.StdEncoding.DecodeString(encoded) |
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 we can actually just do string(encoded)
here. We don't need the encoding outside this function at all (doesn't need to be human readable), and IIRC there're fast paths in the compiler for things like map[string(kek)] = 9
.
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.
Done.
gcs/gcs.go
Outdated
@@ -98,7 +102,7 @@ func BuildGCSFilter(P uint8, key [KeySize]byte, data [][]byte) (*Filter, error) | |||
if len(data) == 0 { | |||
return nil, ErrNoData | |||
} | |||
if len(data) > math.MaxInt32 { | |||
if len(data) > math.MaxUint32 { |
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.
IIRC we changed this as we had issues on 32-bit arm. I'll check to see if this compiles properly on my pi.
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.
You might be right -- I'll rewrite this line to be safe.
|
||
// Count the 1s until we reach a 0. | ||
c, err := b.ReadBit() | ||
if err != nil { | ||
return 0, err | ||
} | ||
for c { | ||
v++ | ||
quotient++ |
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.
👍
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.
LGTM 🎉
Won't merge this quite yet until I update neutrino to support the new p2p modifications. As otherwise, people will fetch my fork and find that it doesn't actually work with their node...
Various things to update implementation to match latest revision of BIP 158.