internal static BlockEvent DeserializeBlockEvent(JsonElement element) { long sequence = default; BlockIdentifier blockIdentifier = default; BlockEventType type = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sequence")) { sequence = property.Value.GetInt64(); continue; } if (property.NameEquals("block_identifier")) { blockIdentifier = BlockIdentifier.DeserializeBlockIdentifier(property.Value); continue; } if (property.NameEquals("type")) { type = new BlockEventType(property.Value.GetString()); continue; } } return(new BlockEvent(sequence, blockIdentifier, type)); }
internal BlockEvent(long sequence, BlockIdentifier blockIdentifier, BlockEventType type) { if (blockIdentifier == null) { throw new ArgumentNullException(nameof(blockIdentifier)); } Sequence = sequence; BlockIdentifier = blockIdentifier; Type = type; }