mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-22 02:07:56 +00:00
25 lines
1.1 KiB
TypeScript
25 lines
1.1 KiB
TypeScript
/**
|
|
* @description
|
|
* Encoding and decoding of parity-codec compact numbers. The codec is created
|
|
* to take up the least amount of space for a specific number. It performs the
|
|
* same function as Length, however differs in that it uses a variable number of
|
|
* bytes to do the actual encoding. From the Rust implementation for compact
|
|
* encoding:
|
|
*
|
|
* 0b00 00 00 00 / 00 00 00 00 / 00 00 00 00 / 00 00 00 00
|
|
* (0 ... 2**6 - 1) (u8)
|
|
* xx xx xx 00
|
|
* (2**6 ... 2**14 - 1) (u8, u16) low LH high
|
|
* yL yL yL 01 / yH yH yH yL
|
|
* (2**14 ... 2**30 - 1) (u16, u32) low LMMH high
|
|
* zL zL zL 10 / zM zM zM zL / zM zM zM zM / zH zH zH zM
|
|
* (2**30 ... 2**536 - 1) (u32, u64, u128, U256, U512, U520) straight LE-encoded
|
|
* nn nn nn 11 [ / zz zz zz zz ]{4 + n}
|
|
*
|
|
* Note: we use *LOW BITS* of the LSB in LE encoding to encode the 2 bit key.
|
|
*/
|
|
export { compactAddLength } from './addLength.js';
|
|
export { compactFromU8a, compactFromU8aLim } from './fromU8a.js';
|
|
export { compactStripLength } from './stripLength.js';
|
|
export { compactToU8a } from './toU8a.js';
|