-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Incorrect batch unwrapping in JSON-RPC replay tool (#7279)
- Loading branch information
1 parent
f95fe4f
commit 3b36366
Showing
9 changed files
with
91 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tools/Nethermind.Tools.Kute/MessageProvider/UnwrapBatchJsonRpcMessageProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
namespace Nethermind.Tools.Kute.MessageProvider; | ||
|
||
public class UnwrapBatchJsonRpcMessageProvider : IMessageProvider<JsonRpc?> | ||
{ | ||
private readonly IMessageProvider<JsonRpc?> _provider; | ||
|
||
public UnwrapBatchJsonRpcMessageProvider(IMessageProvider<JsonRpc?> provider) | ||
{ | ||
_provider = provider; | ||
} | ||
|
||
public IAsyncEnumerable<JsonRpc?> Messages { get => MessagesImpl(); } | ||
|
||
private async IAsyncEnumerable<JsonRpc?> MessagesImpl() | ||
{ | ||
await foreach (var jsonRpc in _provider.Messages) | ||
{ | ||
switch (jsonRpc) | ||
{ | ||
case JsonRpc.SingleJsonRpc: | ||
yield return jsonRpc; | ||
break; | ||
case JsonRpc.BatchJsonRpc batch: | ||
foreach (JsonRpc.SingleJsonRpc? single in batch.Items()) | ||
{ | ||
yield return single; | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters