File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -22,3 +22,4 @@ once_cell = "1.16"
2222jsonwebtoken = " 8.1"
2323k256 = { version = " 0.13" , optional = true }
2424sha3 = { version = " 0.10" , optional = true }
25+ sha2 = { version = " 0.10.6" }
Original file line number Diff line number Diff line change 1111 std:: { fmt:: Debug , sync:: Arc } ,
1212} ;
1313
14+ pub mod msg_id;
1415#[ cfg( test) ]
1516mod tests;
1617pub mod watch;
Original file line number Diff line number Diff line change 1+ use {
2+ crate :: rpc,
3+ sha2:: { Digest , Sha256 } ,
4+ } ;
5+
6+ pub trait MsgId {
7+ fn msg_id ( & self ) -> String ;
8+ }
9+
10+ impl MsgId for rpc:: Publish {
11+ fn msg_id ( & self ) -> String {
12+ let msg_id = Sha256 :: new ( )
13+ . chain_update ( self . message . as_ref ( ) . as_bytes ( ) )
14+ . finalize ( ) ;
15+ format ! ( "{msg_id:x}" )
16+ }
17+ }
18+
19+ impl MsgId for rpc:: Subscription {
20+ fn msg_id ( & self ) -> String {
21+ let msg_id = Sha256 :: new ( )
22+ . chain_update ( self . data . message . as_ref ( ) . as_bytes ( ) )
23+ . finalize ( ) ;
24+ format ! ( "{msg_id:x}" )
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments