Skip to main content

ResQ.Blockchain.MockNeoClient

MockNeoClient.RecordEventAsync(BlockchainEvent, CancellationToken) Method

Records a mock blockchain event in memory.
public System.Threading.Tasks.Task<ResQ.Blockchain.TransactionResult> RecordEventAsync(ResQ.Blockchain.BlockchainEvent evt, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters

evt BlockchainEvent The blockchain event to record. cancellationToken System.Threading.CancellationToken Cancellation token for the operation. Implements RecordEventAsync(BlockchainEvent, CancellationToken)

Returns

System.Threading.Tasks.Task<TransactionResult>
A TransactionResult with a generated transaction hash and confirmed status.

Example

var evt = new BlockchainEvent(
    EventId: "evt-001",
    EventType: "IncidentDetected",
    Payload: "{\"incident\":\"inc-001\"}",
    IpfsCid: null,
    Timestamp: DateTimeOffset.UtcNow
);

var result = await mockClient.RecordEventAsync(evt);
// Logs: "MOCK: Recorded event evt-001 of type IncidentDetected, TxHash: 0x..."

Remarks

This mock implementation:
  • Generates a random transaction hash using cryptographic random bytes
  • Increments the internal block height
  • Stores the event in memory, indexed by incident ID if present in payload
  • Logs the operation at Information level