|
| 1 | +using System.Text.Json.Serialization; |
| 2 | + |
| 3 | +namespace SolSharp.Rpc.Streaming; |
| 4 | + |
| 5 | +/// <summary> |
| 6 | +/// A slot-lifecycle notification payload from <c>slotsUpdatesSubscribe</c> - one update per stage a |
| 7 | +/// slot moves through (see <see cref="Type"/>). |
| 8 | +/// </summary> |
| 9 | +/// <seealso href="https://solana.com/docs/rpc/websocket/slotsupdatessubscribe">slotsUpdatesSubscribe</seealso> |
| 10 | +public sealed record SlotsUpdate |
| 11 | +{ |
| 12 | + /// <summary>The slot the update is about.</summary> |
| 13 | + [JsonPropertyName("slot")] |
| 14 | + public ulong Slot { get; init; } |
| 15 | + |
| 16 | + /// <summary> |
| 17 | + /// The update type: <c>firstShredReceived</c>, <c>completed</c>, <c>createdBank</c>, <c>frozen</c>, |
| 18 | + /// <c>dead</c>, <c>optimisticConfirmation</c>, or <c>root</c>. Kept as a string so new node-side |
| 19 | + /// stages do not break deserialization. |
| 20 | + /// </summary> |
| 21 | + [JsonPropertyName("type")] |
| 22 | + public string Type { get; init; } = string.Empty; |
| 23 | + |
| 24 | + /// <summary>The update's Unix timestamp in milliseconds.</summary> |
| 25 | + [JsonPropertyName("timestamp")] |
| 26 | + public long Timestamp { get; init; } |
| 27 | + |
| 28 | + /// <summary>The parent slot; only present on <c>createdBank</c> updates.</summary> |
| 29 | + [JsonPropertyName("parent")] |
| 30 | + public ulong? Parent { get; init; } |
| 31 | + |
| 32 | + /// <summary>Why the slot died; only present on <c>dead</c> updates.</summary> |
| 33 | + [JsonPropertyName("err")] |
| 34 | + public string? Error { get; init; } |
| 35 | + |
| 36 | + /// <summary>Transaction counts for the slot; only present on <c>frozen</c> updates.</summary> |
| 37 | + [JsonPropertyName("stats")] |
| 38 | + public SlotsUpdateStats? Stats { get; init; } |
| 39 | +} |
| 40 | + |
| 41 | +/// <summary>The per-slot transaction counts attached to a <c>frozen</c> <see cref="SlotsUpdate"/>.</summary> |
| 42 | +public sealed record SlotsUpdateStats |
| 43 | +{ |
| 44 | + /// <summary>The number of transaction entries in the slot.</summary> |
| 45 | + [JsonPropertyName("numTransactionEntries")] |
| 46 | + public ulong NumTransactionEntries { get; init; } |
| 47 | + |
| 48 | + /// <summary>The number of successful transactions in the slot.</summary> |
| 49 | + [JsonPropertyName("numSuccessfulTransactions")] |
| 50 | + public ulong NumSuccessfulTransactions { get; init; } |
| 51 | + |
| 52 | + /// <summary>The number of failed transactions in the slot.</summary> |
| 53 | + [JsonPropertyName("numFailedTransactions")] |
| 54 | + public ulong NumFailedTransactions { get; init; } |
| 55 | + |
| 56 | + /// <summary>The largest number of transactions in a single entry.</summary> |
| 57 | + [JsonPropertyName("maxTransactionsPerEntry")] |
| 58 | + public ulong MaxTransactionsPerEntry { get; init; } |
| 59 | +} |
0 commit comments