@waku/enr
Version:
ENR (EIP-778) for Waku
36 lines • 794 B
JavaScript
export function encodeWaku2(protocols) {
let byte = 0;
if (protocols.lightPush)
byte += 1;
byte = byte << 1;
if (protocols.filter)
byte += 1;
byte = byte << 1;
if (protocols.store)
byte += 1;
byte = byte << 1;
if (protocols.relay)
byte += 1;
return byte;
}
export function decodeWaku2(byte) {
const waku2 = {
relay: false,
store: false,
filter: false,
lightPush: false
};
if (byte % 2)
waku2.relay = true;
byte = byte >> 1;
if (byte % 2)
waku2.store = true;
byte = byte >> 1;
if (byte % 2)
waku2.filter = true;
byte = byte >> 1;
if (byte % 2)
waku2.lightPush = true;
return waku2;
}
//# sourceMappingURL=waku2_codec.js.map