Development resources at your finger tips
Build with the coolest Web3 projects
Recurring funding for Open Source
Ethical ads to power Open Source
Learn about Web3 & earn rewards
Show appreciation for each other
Meet fellow developers, designers, futurists and more. Collaborate and BUIDL awesome projects together.
Discover great web3 organizations, work on meaningful projects and build relationships with like minded people. Browse Tribes
Meet the top hunters and contributors from our community.
KERNEL is an 8-week, invite-only program for top tech talent looking to build relationships, products, and companies in blockchain and Web 3. 100 tal…
Heyo Gitcoiners! With an entire city of hackers, coders and blockchain innovators relocated on our platform, the atmosphere is just buzzing with crea…
Type in [[ 2- term.length]] more characters to get results
[[ result.title ]]
[[ result.description | truncate(70) ]]
No matches found
Gitcoin is GDPR complaint. Learn more in
Gitcoin's Terms & Conditions.
Check out the Issue Explorer
Looking to fund some work? You can submit a new Funded Issue here.
There is an implementation of a Boolean Bitfield here:
It (kinda) does the job for now, but it really needs some work done. If you spend some time looking at it I think you'll soon find out what I mean. As an example;
- There is a possibility of overflows: we return the number of bits as a `usize`, however there can theoretically be `usize` number of bytes meaning we can have `8 * usize` bits.
- It keeps track of the number of true bits as you flip bits on and off. I don't think this is ideal as most cases where we want to know the number of true bits, we'll be receiving some serialized bytes from somewhere else (e.g., p2p nodes) and will need to calculate it manually.
On top of these two points, there's likely many chances for optimization.
# Required Functionality
get(n: usize) -> Result
Get value at index `n`.
Error if bit out-of-bounds (OOB) of underlying bytes.
set(n: usize, val: bool) -> Result
Set bit at index `n`. Returns the previous value if successful.
Error if bit is OOB of underlying bytes.
## Highest Set Bit
highest_set_bit() -> Option
Returns the index of the highest set bit. `Some(n)` if a bit set set, `None` otherwise.
_Note: this is useful because we need to reject messages if an unnecessary bit is set (e.g. if there are 10 voters and the 11th bit is set_
## Number of Underlying Bytes
num_bytes() -> usize
Returns the length of the underlying bytes.
_Note: useful to reject bitfields that are larger than required (e.g., if there are eight voters and two bytes -- only one byte is necessary). _
## Number of Set Bits
num_set_bits() -> usize
Returns the total number of set bits (i.e., how many peeps voted).
_Note: I'm not 100% sure we'll use this but I suspect we will._