add content-addressed message id utility
This commit is contained in:
parent
ef666267bd
commit
857cc29d27
@ -1,4 +1,6 @@
|
|||||||
|
import base64
|
||||||
import functools
|
import functools
|
||||||
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
from typing import (
|
from typing import (
|
||||||
@ -52,6 +54,10 @@ def get_peer_and_seqno_msg_id(msg: rpc_pb2.Message) -> bytes:
|
|||||||
return msg.seqno + msg.from_id
|
return msg.seqno + msg.from_id
|
||||||
|
|
||||||
|
|
||||||
|
def get_content_addressed_msg_id(msg: rpc_pb2.Message) -> bytes:
|
||||||
|
return base64.b64encode(hashlib.sha256(msg.data).digest())
|
||||||
|
|
||||||
|
|
||||||
class TopicValidator(NamedTuple):
|
class TopicValidator(NamedTuple):
|
||||||
validator: ValidatorFn
|
validator: ValidatorFn
|
||||||
is_async: bool
|
is_async: bool
|
||||||
|
Loading…
x
Reference in New Issue
Block a user