mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-07 16:33:08 +00:00
chore: debug
This commit is contained in:
parent
07f5aee25f
commit
c26fe4bdc4
@ -27,9 +27,6 @@ proc inHex*(
|
||||
valueHex = "0" & valueHex
|
||||
return toLowerAscii(valueHex)
|
||||
|
||||
proc toUserMessageLimit*(v: UInt256): UserMessageLimit =
|
||||
return cast[UserMessageLimit](v)
|
||||
|
||||
proc encodeLengthPrefix*(input: openArray[byte]): seq[byte] =
|
||||
## returns length prefixed version of the input
|
||||
## with the following format [len<8>|input<var>]
|
||||
@ -148,3 +145,22 @@ func `+`*(a, b: Quantity): Quantity {.borrow.}
|
||||
|
||||
func u256*(n: Quantity): UInt256 {.inline.} =
|
||||
n.uint64.stuint(256)
|
||||
|
||||
proc uint64ToField*(n: uint64): array[32, byte] =
|
||||
## Converts uint64 to 32-byte little-endian array with zero padding
|
||||
var bytes = toBytes(n, Endianness.littleEndian)
|
||||
result[0 ..< bytes.len] = bytes
|
||||
|
||||
proc UInt256ToField*(v: UInt256): array[32, byte] =
|
||||
return cast[array[32, byte]](v)
|
||||
|
||||
proc seqToField*(s: seq[byte]): array[32, byte] =
|
||||
result = default(array[32, byte])
|
||||
let len = min(s.len, 32)
|
||||
for i in 0 ..< len:
|
||||
result[i] = s[i]
|
||||
|
||||
proc uint64ToIndex*(index: MembershipIndex, depth: int): seq[byte] =
|
||||
result = newSeq[byte](depth)
|
||||
for i in 0 ..< depth:
|
||||
result[i] = byte((index shr i) and 1) # LSB-first bit decomposition
|
||||
|
||||
@ -13,6 +13,7 @@ import
|
||||
std/[strutils, tables, algorithm],
|
||||
stew/[byteutils, arrayops],
|
||||
sequtils
|
||||
|
||||
import
|
||||
../../../waku_keystore,
|
||||
../../rln,
|
||||
@ -89,25 +90,6 @@ proc setMetadata*(
|
||||
return err("failed to persist rln metadata: " & getCurrentExceptionMsg())
|
||||
return ok()
|
||||
|
||||
proc uint64ToField*(n: uint64): array[32, byte] =
|
||||
## Converts uint64 to 32-byte little-endian array with zero padding
|
||||
var bytes = toBytes(n, Endianness.littleEndian)
|
||||
result[0 ..< bytes.len] = bytes
|
||||
|
||||
proc UInt256ToField*(v: UInt256): array[32, byte] =
|
||||
return cast[array[32, byte]](v)
|
||||
|
||||
proc seqToField*(s: seq[byte]): array[32, byte] =
|
||||
result = default(array[32, byte])
|
||||
let len = min(s.len, 32)
|
||||
for i in 0 ..< len:
|
||||
result[i] = s[i]
|
||||
|
||||
proc uint64ToIndex(index: MembershipIndex, depth: int): seq[byte] =
|
||||
result = newSeq[byte](depth)
|
||||
for i in 0 ..< depth:
|
||||
result[i] = byte((index shr i) and 1) # LSB-first bit decomposition
|
||||
|
||||
proc fetchMerkleProofElements*(
|
||||
g: OnchainGroupManager
|
||||
): Future[Result[seq[byte], string]] {.async.} =
|
||||
@ -204,10 +186,6 @@ proc trackRootChanges*(g: OnchainGroupManager) {.async.} =
|
||||
let memberCount = cast[int64](await wakuRlnContract.commitmentIndex().call())
|
||||
waku_rln_number_registered_memberships.set(float64(memberCount))
|
||||
|
||||
debug "--- RLN membership metrics ---",
|
||||
registered_members = memberCount,
|
||||
active_memberships = waku_rln_number_registered_memberships.value
|
||||
|
||||
await sleepAsync(rpcDelay)
|
||||
|
||||
method atomicBatch*(
|
||||
|
||||
@ -120,6 +120,6 @@ proc getRlnMetricsLogger*(): RLNMetricsLogger =
|
||||
info "Total proofs verified", count = freshProofsVerifiedCount
|
||||
info "Total proofs generated", count = freshProofsGeneratedCount
|
||||
info "Total proofs remaining", count = freshProofsRemainingCount
|
||||
info "Total registered member", count = freshRegisteredMemberCount
|
||||
info "Total registered members", count = freshRegisteredMemberCount
|
||||
|
||||
return logMetrics
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user