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