mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 16:37:57 +00:00
client/*: Treat protocol name as str and not [u8] (#6967)
* client/*: Treat protocol name as str and not [u8] Notification protocol names are in practice always valid utf8 strings. Instead of treating them as such in the type system, thus far they were casted to a [u8] at creation time. With this commit protocol names are instead treated as valid utf8 strings throughout the codebase and passed as `Cow<'static, str>` instead of `Cow<'static, [u8]>`. Among other things this eliminates the need for string casting when logging. * client/network: Don't allocate when protocol name is borrowed
This commit is contained in:
@@ -131,14 +131,14 @@ fn build_nodes_one_proto()
|
||||
let listen_addr = config::build_multiaddr![Memory(rand::random::<u64>())];
|
||||
|
||||
let (node1, events_stream1) = build_test_full_node(config::NetworkConfiguration {
|
||||
notifications_protocols: vec![(ENGINE_ID, From::from(&b"/foo"[..]))],
|
||||
notifications_protocols: vec![(ENGINE_ID, From::from("/foo"))],
|
||||
listen_addresses: vec![listen_addr.clone()],
|
||||
transport: config::TransportConfig::MemoryOnly,
|
||||
.. config::NetworkConfiguration::new_local()
|
||||
});
|
||||
|
||||
let (node2, events_stream2) = build_test_full_node(config::NetworkConfiguration {
|
||||
notifications_protocols: vec![(ENGINE_ID, From::from(&b"/foo"[..]))],
|
||||
notifications_protocols: vec![(ENGINE_ID, From::from("/foo"))],
|
||||
listen_addresses: vec![],
|
||||
reserved_nodes: vec![config::MultiaddrWithPeerId {
|
||||
multiaddr: listen_addr,
|
||||
@@ -281,7 +281,7 @@ fn lots_of_incoming_peers_works() {
|
||||
let listen_addr = config::build_multiaddr![Memory(rand::random::<u64>())];
|
||||
|
||||
let (main_node, _) = build_test_full_node(config::NetworkConfiguration {
|
||||
notifications_protocols: vec![(ENGINE_ID, From::from(&b"/foo"[..]))],
|
||||
notifications_protocols: vec![(ENGINE_ID, From::from("/foo"))],
|
||||
listen_addresses: vec![listen_addr.clone()],
|
||||
in_peers: u32::max_value(),
|
||||
transport: config::TransportConfig::MemoryOnly,
|
||||
@@ -298,7 +298,7 @@ fn lots_of_incoming_peers_works() {
|
||||
let main_node_peer_id = main_node_peer_id.clone();
|
||||
|
||||
let (_dialing_node, event_stream) = build_test_full_node(config::NetworkConfiguration {
|
||||
notifications_protocols: vec![(ENGINE_ID, From::from(&b"/foo"[..]))],
|
||||
notifications_protocols: vec![(ENGINE_ID, From::from("/foo"))],
|
||||
listen_addresses: vec![],
|
||||
reserved_nodes: vec![config::MultiaddrWithPeerId {
|
||||
multiaddr: listen_addr.clone(),
|
||||
|
||||
Reference in New Issue
Block a user