From c3e932a92c0585786d758a39ace664c5b30d2096 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Fri, 23 Aug 2024 19:54:55 +0900 Subject: [PATCH 1/2] Changed BlockDemand to hold an IBlockExcerpt instead of BlockHeader --- src/Libplanet.Net/BlockDemand.cs | 17 ++++++++++------- src/Libplanet.Net/BlockDemandTable.cs | 2 +- src/Libplanet.Net/Swarm.BlockCandidate.cs | 8 ++++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Libplanet.Net/BlockDemand.cs b/src/Libplanet.Net/BlockDemand.cs index 4100598186b..1dda3aeccc2 100644 --- a/src/Libplanet.Net/BlockDemand.cs +++ b/src/Libplanet.Net/BlockDemand.cs @@ -9,9 +9,9 @@ namespace Libplanet.Net public readonly struct BlockDemand : IBlockExcerpt { /// - /// The of the block to request. + /// The of the block to request. /// - public readonly BlockHeader Header; + public readonly IBlockExcerpt BlockExcerpt; /// /// The to request block hash from. @@ -24,17 +24,20 @@ namespace Libplanet.Net /// public readonly DateTimeOffset Timestamp; - public BlockDemand(BlockHeader header, BoundPeer peer, DateTimeOffset timestamp) + public BlockDemand(IBlockExcerpt blockExcerpt, BoundPeer peer, DateTimeOffset timestamp) { - Header = header; + BlockExcerpt = blockExcerpt; Peer = peer; Timestamp = timestamp; } - public int ProtocolVersion => Header.ProtocolVersion; + /// + public int ProtocolVersion => BlockExcerpt.ProtocolVersion; - public long Index => Header.Index; + /// + public long Index => BlockExcerpt.Index; - public BlockHash Hash => ((IBlockExcerpt)Header).Hash; + /// + public BlockHash Hash => BlockExcerpt.Hash; } } diff --git a/src/Libplanet.Net/BlockDemandTable.cs b/src/Libplanet.Net/BlockDemandTable.cs index 1c0976e68cc..14f8cdbbfe2 100644 --- a/src/Libplanet.Net/BlockDemandTable.cs +++ b/src/Libplanet.Net/BlockDemandTable.cs @@ -33,7 +33,7 @@ public void Add( { _blockDemands[demand.Peer] = demand; Log.Debug( - "BlockDemand #{Index} {BlockHash} from peer {Peer} added", + "BlockDemand #{Index} {BlockHash} from peer {Peer} updated", demand.Index, demand.Hash, demand.Peer); diff --git a/src/Libplanet.Net/Swarm.BlockCandidate.cs b/src/Libplanet.Net/Swarm.BlockCandidate.cs index 92247d38efe..ec766ac92a5 100644 --- a/src/Libplanet.Net/Swarm.BlockCandidate.cs +++ b/src/Libplanet.Net/Swarm.BlockCandidate.cs @@ -365,8 +365,8 @@ private async Task ProcessBlockDemandAsync( "to fetch the block #{BlockIndex} {BlockHash} at {MethodName}()", sessionId, peer, - demand.Header.Index, - demand.Header.Hash, + demand.Index, + demand.Hash, nameof(ProcessBlockDemandAsync)); try @@ -375,7 +375,7 @@ private async Task ProcessBlockDemandAsync( var result = await BlockCandidateDownload( peer: peer, blockChain: BlockChain, - stop: demand.Header, + stop: demand.BlockExcerpt, logSessionId: sessionId, cancellationToken: cancellationToken); @@ -431,7 +431,7 @@ private async Task ProcessBlockDemandAsync( private async Task BlockCandidateDownload( BoundPeer peer, BlockChain blockChain, - BlockHeader stop, + IBlockExcerpt stop, int logSessionId, CancellationToken cancellationToken) { From 8385be74872f2ed49eb89d75d01c70e6051a7ffb Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Fri, 23 Aug 2024 20:01:01 +0900 Subject: [PATCH 2/2] Changelog --- CHANGES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index a6d8f0d5947..438b463ea20 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,6 +19,8 @@ To be released. [[#3913]] - (Libplanet.Store) Removed unused `HashNode.Serialize()` method. [[#3922], [#3924]] + - (Libplanet.Net) Removed `Header` property and added `BlockExcerpt` property + to `BlockDemand`. [[#3934]] ### Backward-incompatible network protocol changes @@ -44,6 +46,7 @@ To be released. [#3922]: https://github.com/planetarium/libplanet/issues/3922 [#3924]: https://github.com/planetarium/libplanet/pull/3924 [#3926]: https://github.com/planetarium/libplanet/pull/3926 +[#3934]: https://github.com/planetarium/libplanet/pull/3934 Version 5.2.2