stacks-network / stacks-network/stacks-core
Add inverse of `buff-to-*` functions
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.1k
- Forks
- 762
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 76
Description
Clarity provides functions to read byte buffers, but it should provide functions to write them too. It is currently possible, although awkward, to do this with to-consensus-buff?. For example, I wrote a function uint-to-buff-be:
(define-private (uint-to-buff-be (n uint))
(unwrap-panic (slice? (unwrap-panic (to-consensus-buff? n)) u1 u17)))
But it's inefficient and I'd rather not have the unwrap-panics in there, as this should be infallible code. It should just be part of the language like the buffer read functions
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing Clarity buff-to-* functions and the to-consensus-buff? implementation referenced in the issue. Determine the intended inverse functions and their behavior for the supported integer types, then add coverage for infallible big-endian buffer conversion without requiring unwrap-panic.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100