Skip to content

Commit 14f1495

Browse files
committed
Allows seeing duplicate new-request events
1 parent 21629da commit 14f1495

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

ProjectPlugins/CodexContractsPlugin/ChainMonitor/ChainState.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using BlockchainUtils;
22
using CodexContractsPlugin.Marketplace;
33
using Logging;
4+
using Nethereum.Hex.HexConvertors.Extensions;
45
using Newtonsoft.Json;
56
using System.Numerics;
67
using Utils;
@@ -120,18 +121,14 @@ private void ApplyEvent(Request request)
120121
{
121122
if (requests.Any(r => Equal(r.Request.RequestId, request.RequestId)))
122123
{
123-
var msg = "Received NewRequest event for id that already exists. ";
124-
msg += "Received: " + JsonConvert.SerializeObject(request);
125124
var r = FindRequest(request);
126-
if (r != null)
127-
{
128-
msg += " Already have: " + JsonConvert.SerializeObject(r);
129-
}
130-
else
131-
{
132-
msg += " Already have: Not found!";
133-
}
134-
throw new Exception(msg);
125+
if (r == null) throw new Exception("ChainState is inconsistent. Received already-known requestId that's not known.");
126+
127+
if (request.Block.BlockNumber != r.Request.Block.BlockNumber) throw new Exception("Same request found in different blocks.");
128+
if (request.Client != r.Request.Client) throw new Exception("Same request belongs to different clients.");
129+
if (request.Content.Cid.ToHex() != r.Request.Content.Cid.ToHex()) throw new Exception("Same request has different CIDs.");
130+
131+
log.Log("Received the same request-creation event multiple times.");
135132
}
136133

137134
var newRequest = new ChainStateRequest(log, request, RequestState.New);

0 commit comments

Comments
 (0)