bolt1

Base Lightning protocol, per BOLT #1 (docs.ppad.tech/bolt1).
git clone git://git.ppad.tech/bolt1.git
Log | Files | Refs | README | LICENSE

IMPL2.md (948B)


      1 # IMPL2 - Replace ByteString Builders
      2 
      3 ## Goal
      4 
      5 Remove ByteString.Builder usage and replace with unsafe ByteString
      6 construction primitives, with careful bounds/length handling.
      7 
      8 ## Scope
      9 
     10 - Library code that currently uses `Data.ByteString.Builder` for encoding.
     11 - Update tests if they depend on builder behavior or output ordering.
     12 
     13 ## Plan
     14 
     15 1) Identify builder usage in `lib/` (e.g., `encodeU16/U32/U64`).
     16 2) Replace with unsafe ByteString creation primitives:
     17    - Use `BS.create` or `BS.unsafeCreate` with explicit writes.
     18    - Prefer `poke`/`pokeByteOff` for big-endian layout.
     19    - Ensure bounds correctness and totality.
     20 3) Remove `bytestring` builder imports and any now-unused deps.
     21 4) Add/adjust tests for encode functions to ensure exact bytes.
     22 5) Run tests to confirm no regressions.
     23 
     24 ## Notes
     25 
     26 - Keep new helpers small and INLINE.
     27 - Validate length fields before unsafe writes to avoid overflow.
     28 - Avoid introducing new dependencies.
     29