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

blockchain: Remove unneeded unspentness size check. #665

Merged
merged 1 commit into from
Apr 14, 2016

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Apr 13, 2016

The current code is needlessly checking the number of bytes needed to serialize the unspentness bitmap in the utxo against a maximum value that could never be returned because the function takes a uint32 output index which is treated as a bit offset, and converts it bytes, which will necessarily be less than a max uint32.

This check also causes a compile error on arm where native integers are 32 bits.

This simply removes the unneeded check.

Fixes #664.


This change is Reviewable

The current code is needlessly checking the number of bytes needed to
serialize the unspentness bitmap in the utxo against a maximum value
that could never be returned because the function takes a uint32 output
index which is treated as a bit offset, and converts it bytes, which
will necessarily be less than a max uint32.

This check also causes a compile error on arm where native integers are
32 bits.

This simply removes the unneeded check.
@dajohi
Copy link
Member

dajohi commented Apr 13, 2016

OK

@davecgh
Copy link
Member Author

davecgh commented Apr 13, 2016

@T909 Would you confirm this resolves your issue as well?

@ghost
Copy link

ghost commented Apr 14, 2016

Yup, compiles now, thanks!

(also... getting a crash now when running it on arm, but that's a different issue; atomic.AddUint64(&s.bytesSent, bytesSent) on line 1982 of server.go. Weird. It's actually /usr/local/go/src/sync/atomic/64bit_arm.go:31 that crashes it, which may indicate a compiler problem on my end; will look into it.)

@davecgh davecgh merged commit 5a1e77b into btcsuite:master Apr 14, 2016
@davecgh davecgh deleted the blockchain_remove_unneeded_check branch April 14, 2016 02:43
@davecgh
Copy link
Member Author

davecgh commented Apr 14, 2016

Thanks for testing.

cjepson pushed a commit to cjepson/btcd that referenced this pull request Sep 21, 2016
The current code is needlessly checking the number of bytes needed to
serialize the unspentness bitmap in the utxo against a maximum value
that could never be returned because the function takes a uint32 output
index which is treated as a bit offset, and converts it bytes, which
will necessarily be less than a max uint32.

This check also causes a compile error on arm where native integers are
32 bits.

This simply removes the unneeded check.
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