From e97ef84dd680f6facac8972dc2ca8f3e19c32f8a Mon Sep 17 00:00:00 2001 From: Lee Dogeon Date: Fri, 30 Aug 2024 17:07:19 +0900 Subject: [PATCH] Introduce `filtered` argument at `.nodeStatus.stagedTxIds[Count]` --- .../GraphTypes/NodeStatus.cs | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/NineChronicles.Headless/GraphTypes/NodeStatus.cs b/NineChronicles.Headless/GraphTypes/NodeStatus.cs index ab93095cf..2afa95afb 100644 --- a/NineChronicles.Headless/GraphTypes/NodeStatus.cs +++ b/NineChronicles.Headless/GraphTypes/NodeStatus.cs @@ -95,6 +95,12 @@ public NodeStatusType(StandaloneContext context) { Name = "address", Description = "Target address to query" + }, + new QueryArgument + { + Name = "filtered", + Description = "Whether to filter masked staged Transactions or not.", + DefaultValue = true, } ), description: "Ids of staged transactions from the current node.", @@ -104,17 +110,18 @@ public NodeStatusType(StandaloneContext context) { throw new InvalidOperationException($"{nameof(context.BlockChain)} is null."); } - + + var filtered = fieldContext.GetArgument("filtered"); if (!fieldContext.HasArgument("address")) { - return context.BlockChain.StagePolicy.Iterate(context.BlockChain).Select(tx => tx.Id) + return context.BlockChain.StagePolicy.Iterate(context.BlockChain, filtered).Select(tx => tx.Id) .ToImmutableHashSet(); } else { Address address = fieldContext.GetArgument
("address"); - return context.BlockChain.StagePolicy.Iterate(context.BlockChain) + return context.BlockChain.StagePolicy.Iterate(context.BlockChain, filtered) .Where(tx => tx.Signer.Equals(address)).Select(tx => tx.Id).ToImmutableHashSet(); } } @@ -122,6 +129,14 @@ public NodeStatusType(StandaloneContext context) Field( name: "stagedTxIdsCount", description: "The number of ids of staged transactions from the current node.", + arguments: new QueryArguments( + new QueryArgument + { + Name = "filtered", + Description = "Whether to filter masked staged Transactions or not.", + DefaultValue = true, + } + ), resolve: fieldContext => { if (context.BlockChain is null) @@ -129,7 +144,8 @@ public NodeStatusType(StandaloneContext context) throw new InvalidOperationException($"{nameof(context.BlockChain)} is null."); } - return context.BlockChain.StagePolicy.Iterate(context.BlockChain).ToImmutableHashSet().Count; + var filtered = fieldContext.GetArgument("filtered"); + return context.BlockChain.StagePolicy.Iterate(context.BlockChain, filtered).ToImmutableHashSet().Count; } ); Field>(