@@ -504,8 +504,8 @@ define_methods! {
504
504
// These functions are a custom addition in smoldot. As of the writing of this comment, there
505
505
// is no plan to standardize them. See <https://github.com/paritytech/smoldot/issues/2245> and
506
506
// <https://github.com/paritytech/smoldot/issues/2456>.
507
- network_unstable_subscribeEvents ( ) -> Cow <' a, str >,
508
- network_unstable_unsubscribeEvents ( subscription: Cow <' a, str >) -> ( ) ,
507
+ sudo_network_unstable_watch ( ) -> Cow <' a, str >,
508
+ sudo_network_unstable_unwatch ( subscription: Cow <' a, str >) -> ( ) ,
509
509
chainHead_unstable_finalizedDatabase( #[ rename = "maxSizeBytes" ] max_size_bytes: Option <u64 >) -> Cow <' a, str >,
510
510
}
511
511
@@ -525,7 +525,7 @@ define_methods! {
525
525
526
526
// This function is a custom addition in smoldot. As of the writing of this comment, there is
527
527
// no plan to standardize it. See https://github.com/paritytech/smoldot/issues/2245.
528
- network_unstable_event ( subscription: Cow <' a, str >, result: NetworkEvent < ' a> ) -> ( ) ,
528
+ sudo_networkState_event ( subscription: Cow <' a, str >, result: NetworkEvent ) -> ( ) ,
529
529
}
530
530
531
531
#[ derive( Clone , PartialEq , Eq , Hash ) ]
@@ -849,90 +849,51 @@ pub struct TransactionWatchEventBlock {
849
849
/// See <https://github.com/paritytech/smoldot/issues/2245>.
850
850
#[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize ) ]
851
851
#[ serde( tag = "event" ) ]
852
- pub enum NetworkEvent < ' a > {
853
- #[ serde( rename = "startConnect" ) ]
854
- StartConnect {
855
- when : u64 ,
856
- #[ serde( rename = "connectionId" ) ]
857
- connection_id : u32 ,
858
- multiaddr : Cow < ' a , str > ,
859
- } ,
860
- #[ serde( rename = "connected" ) ]
861
- Connected {
862
- when : u64 ,
852
+ pub enum NetworkEvent {
853
+ #[ serde( rename = "connectionState" ) ]
854
+ ConnectionState {
863
855
#[ serde( rename = "connectionId" ) ]
864
856
connection_id : u32 ,
865
- } ,
866
- #[ serde( rename = "handshakeFinished" ) ]
867
- HandshakeFinished {
857
+ #[ serde( rename = "targetPeerId" , skip_serializing_if = "Option::is_none" ) ]
858
+ target_peer_id : Option < String > ,
859
+ #[ serde( rename = "targetMultiaddr" ) ]
860
+ target_multiaddr : String ,
861
+ status : NetworkEventStatus ,
862
+ direction : NetworkEventDirection ,
868
863
when : u64 ,
869
- #[ serde( rename = "connectionId" ) ]
870
- connection_id : u32 ,
871
- #[ serde( rename = "peerId" ) ]
872
- peer_id : Cow < ' a , str > ,
873
864
} ,
874
- #[ serde( rename = "stop" ) ]
875
- Stop {
876
- when : u64 ,
877
- #[ serde( rename = "connectionId" ) ]
878
- connection_id : u32 ,
879
- reason : Cow < ' a , str > ,
880
- } ,
881
- #[ serde( rename = "out-slot-assign" ) ]
882
- OutSlotAssign {
883
- when : u64 ,
884
- #[ serde( rename = "peerId" ) ]
885
- peer_id : Cow < ' a , str > ,
886
- } ,
887
- #[ serde( rename = "out-slot-unassign" ) ]
888
- OutSlotUnassign {
889
- when : u64 ,
890
- #[ serde( rename = "peerId" ) ]
891
- peer_id : Cow < ' a , str > ,
892
- } ,
893
- #[ serde( rename = "in-slot-assign" ) ]
894
- InSlotAssign {
895
- when : u64 ,
896
- #[ serde( rename = "peerId" ) ]
897
- peer_id : Cow < ' a , str > ,
898
- } ,
899
- #[ serde( rename = "in-slot-unassign" ) ]
900
- InSlotUnassign {
901
- when : u64 ,
902
- #[ serde( rename = "peerId" ) ]
903
- peer_id : Cow < ' a , str > ,
904
- } ,
905
- #[ serde( rename = "in-slot-to-out-slot" ) ]
906
- InSlotToOutSlot {
907
- when : u64 ,
908
- #[ serde( rename = "peerId" ) ]
909
- peer_id : Cow < ' a , str > ,
910
- } ,
911
- #[ serde( rename = "substream-out-open" ) ]
912
- SubstreamOutOpen {
913
- when : u64 ,
865
+ #[ serde( rename = "substreamState" ) ]
866
+ SubstreamState {
914
867
#[ serde( rename = "connectionId" ) ]
915
868
connection_id : u32 ,
916
869
#[ serde( rename = "substreamId" ) ]
917
870
substream_id : u32 ,
871
+ status : NetworkEventStatus ,
918
872
#[ serde( rename = "protocolName" ) ]
919
- protocol_name : Cow < ' a , str > ,
920
- } ,
921
- #[ serde( rename = "substream-out-accept" ) ]
922
- SubstreamOutAccept {
923
- when : u64 ,
924
- #[ serde( rename = "substreamId" ) ]
925
- substream_id : u32 ,
926
- } ,
927
- #[ serde( rename = "substream-out-stop" ) ]
928
- SubstreamOutStop {
873
+ protocol_name : String ,
874
+ direction : NetworkEventDirection ,
929
875
when : u64 ,
930
- #[ serde( rename = "substreamId" ) ]
931
- substream_id : u32 ,
932
- reason : Cow < ' a , str > ,
933
876
} ,
934
877
}
935
878
879
+ #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize ) ]
880
+ pub enum NetworkEventStatus {
881
+ #[ serde( rename = "connecting" ) ]
882
+ Connecting ,
883
+ #[ serde( rename = "open" ) ]
884
+ Open ,
885
+ #[ serde( rename = "closed" ) ]
886
+ Close ,
887
+ }
888
+
889
+ #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize ) ]
890
+ pub enum NetworkEventDirection {
891
+ #[ serde( rename = "in" ) ]
892
+ In ,
893
+ #[ serde( rename = "out" ) ]
894
+ Out ,
895
+ }
896
+
936
897
#[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize ) ]
937
898
pub struct Header {
938
899
#[ serde( rename = "parentHash" ) ]
0 commit comments