From 5a07992905e03a7aca1937daa6081c0078c40ac6 Mon Sep 17 00:00:00 2001 From: Alexey Date: Tue, 15 Oct 2024 18:59:05 +0300 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Marc --- src/libp2p/Libp2p.Core/Discovery/PeerStore.cs | 2 +- src/libp2p/Libp2p.Protocols.MDns/MDnsDiscoveryProtocol.cs | 4 ++-- src/libp2p/Libp2p.Protocols.Pubsub/PubsubRouter.Topics.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libp2p/Libp2p.Core/Discovery/PeerStore.cs b/src/libp2p/Libp2p.Core/Discovery/PeerStore.cs index aa7d849a..88f8c5f6 100644 --- a/src/libp2p/Libp2p.Core/Discovery/PeerStore.cs +++ b/src/libp2p/Libp2p.Core/Discovery/PeerStore.cs @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited +// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited // SPDX-License-Identifier: MIT using Google.Protobuf; diff --git a/src/libp2p/Libp2p.Protocols.MDns/MDnsDiscoveryProtocol.cs b/src/libp2p/Libp2p.Protocols.MDns/MDnsDiscoveryProtocol.cs index 492b5c63..d84c5a71 100644 --- a/src/libp2p/Libp2p.Protocols.MDns/MDnsDiscoveryProtocol.cs +++ b/src/libp2p/Libp2p.Protocols.MDns/MDnsDiscoveryProtocol.cs @@ -18,9 +18,9 @@ public class MDnsDiscoveryProtocol(PeerStore peerStore, ILoggerFactory? loggerFa public static string Id => "mdns"; - private readonly string ServiceName = "_p2p._udp.local"; + private const string ServiceName = "_p2p._udp.local"; - private readonly string? ServiceNameOverride = "pubsub-chat-example"; + private const string? ServiceNameOverride = "pubsub-chat-example"; private string PeerName = null!; diff --git a/src/libp2p/Libp2p.Protocols.Pubsub/PubsubRouter.Topics.cs b/src/libp2p/Libp2p.Protocols.Pubsub/PubsubRouter.Topics.cs index a029a877..8fa5279d 100644 --- a/src/libp2p/Libp2p.Protocols.Pubsub/PubsubRouter.Topics.cs +++ b/src/libp2p/Libp2p.Protocols.Pubsub/PubsubRouter.Topics.cs @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited +// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited // SPDX-License-Identifier: MIT using Nethermind.Libp2p.Core; @@ -118,7 +118,7 @@ public void Publish(string topicId, byte[] message) topicState.GetOrAdd(topicId, (id) => new Topic(this, topicId)); ulong seqNo = this.seqNo++; - byte[] seqNoBytes = new byte[8]; + byte[] seqNoBytes = stackalloc byte[8]; BinaryPrimitives.WriteUInt64BigEndian(seqNoBytes, seqNo); Rpc rpc = new Rpc().WithMessages(topicId, seqNo, localPeer!.Address.GetPeerId()!.Bytes, message, localPeer.Identity);