cs-codex-dist-tests/ProjectPlugins/CodexContractsPlugin/ChainMonitor/ChainEvents.cs

74 lines
2.4 KiB
C#
Raw Normal View History

2024-05-31 08:16:57 +00:00
using CodexContractsPlugin.Marketplace;
using Utils;
namespace CodexContractsPlugin.ChainMonitor
{
public class ChainEvents
{
2024-05-31 08:16:57 +00:00
private ChainEvents(
BlockInterval blockInterval,
Request[] requests,
RequestFulfilledEventDTO[] fulfilled,
RequestCancelledEventDTO[] cancelled,
2024-08-21 11:59:54 +00:00
RequestFailedEventDTO[] failed,
2024-05-31 08:16:57 +00:00
SlotFilledEventDTO[] slotFilled,
SlotFreedEventDTO[] slotFreed
)
{
BlockInterval = blockInterval;
Requests = requests;
Fulfilled = fulfilled;
Cancelled = cancelled;
2024-08-21 11:59:54 +00:00
Failed = failed;
2024-05-31 08:16:57 +00:00
SlotFilled = slotFilled;
SlotFreed = slotFreed;
}
public BlockInterval BlockInterval { get; }
public Request[] Requests { get; }
public RequestFulfilledEventDTO[] Fulfilled { get; }
public RequestCancelledEventDTO[] Cancelled { get; }
2024-08-21 11:59:54 +00:00
public RequestFailedEventDTO[] Failed { get; }
2024-05-31 08:16:57 +00:00
public SlotFilledEventDTO[] SlotFilled { get; }
public SlotFreedEventDTO[] SlotFreed { get; }
public IHasBlock[] All
{
get
{
var all = new List<IHasBlock>();
all.AddRange(Requests);
all.AddRange(Fulfilled);
all.AddRange(Cancelled);
2024-08-21 11:59:54 +00:00
all.AddRange(Failed);
all.AddRange(SlotFilled);
all.AddRange(SlotFreed);
return all.ToArray();
}
}
2024-05-31 08:16:57 +00:00
public static ChainEvents FromBlockInterval(ICodexContracts contracts, BlockInterval blockInterval)
{
return FromContractEvents(contracts.GetEvents(blockInterval));
}
public static ChainEvents FromTimeRange(ICodexContracts contracts, TimeRange timeRange)
{
return FromContractEvents(contracts.GetEvents(timeRange));
}
2024-05-31 08:16:57 +00:00
public static ChainEvents FromContractEvents(ICodexContractsEvents events)
{
return new ChainEvents(
events.BlockInterval,
events.GetStorageRequests(),
events.GetRequestFulfilledEvents(),
events.GetRequestCancelledEvents(),
2024-08-21 11:59:54 +00:00
events.GetRequestFailedEvents(),
2024-05-31 08:16:57 +00:00
events.GetSlotFilledEvents(),
events.GetSlotFreedEvents()
);
}
}
}