From 927d7fd18a372556a07c5e9423455666cef5655f Mon Sep 17 00:00:00 2001 From: Neylix Date: Mon, 17 Apr 2023 12:48:03 +0200 Subject: [PATCH] Remove summary version 2 --- lib/archethic/beacon_chain/summary.ex | 85 ++------------------------- 1 file changed, 6 insertions(+), 79 deletions(-) diff --git a/lib/archethic/beacon_chain/summary.ex b/lib/archethic/beacon_chain/summary.ex index b78a751cd..67520ac43 100644 --- a/lib/archethic/beacon_chain/summary.ex +++ b/lib/archethic/beacon_chain/summary.ex @@ -31,7 +31,7 @@ defmodule Archethic.BeaconChain.Summary do node_average_availabilities: [], end_of_node_synchronizations: [], network_patches: [], - version: 2 + version: 1 ] @type t :: %__MODULE__{ @@ -379,7 +379,7 @@ defmodule Archethic.BeaconChain.Summary do ...> |> Summary.serialize() << # Version - 2, + 1, # Subset 0, # Summary time @@ -483,51 +483,8 @@ defmodule Archethic.BeaconChain.Summary do Deserialize an encoded Beacon Summary ## Examples - - iex> << 1, 0, 96, 7, 114, 128, 1, 1, 2, 1, 0, 0, 234, 233, 156, 155, 114, 241, 116, 246, 27, 130, 162, 205, 249, 65, 232, 166, - ...> 99, 207, 133, 252, 112, 223, 41, 12, 206, 162, 233, 28, 49, 204, 255, 12, 0, 0, 1, 114, 236, 9, 2, 168, - ...> 253, 0, 0, 0, 0, 0, 152, 150, 128, 1, 0, 17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66, - ...> 167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219, 1, 0, 64, - ...> 255, 120, 232, 52, 141, 15, 97, 213, 231, 93, 242, 160, 123, 25, 192, 3, 133, - ...> 170, 197, 102, 148, 208, 119, 130, 225, 102, 130, 96, 223, 61, 36, 76, 229, - ...> 210, 5, 142, 79, 249, 177, 51, 15, 45, 45, 141, 217, 85, 77, 146, 199, 126, - ...> 213, 205, 108, 164, 167, 112, 201, 194, 113, 133, 242, 104, 254, 253, 0, 2, 1::1, 1::1, 100, 100, 1, 1, - ...> 0, 1, 190, 20, 188, 141, 156, 135, 91, 37, 96, 187, 27, 24, 41, 130, 118, - ...> 93, 43, 240, 229, 97, 227, 194, 31, 97, 228, 78, 156, 194, 154, 74, 160, 104, 3, 132 >> - ...> |> Summary.deserialize() - { - %Summary{ - version: 1, - subset: <<0>>, - summary_time: ~U[2021-01-20 00:00:00Z], - availability_adding_time: 900, - transaction_attestations: [ - %ReplicationAttestation{ - transaction_summary: %TransactionSummary{ - address: <<0, 0, 234, 233, 156, 155, 114, 241, 116, 246, 27, 130, 162, 205, 249, 65, 232, 166, - 99, 207, 133, 252, 112, 223, 41, 12, 206, 162, 233, 28, 49, 204, 255, 12>>, - timestamp: ~U[2020-06-25 15:11:53.000Z], - type: :transfer, - movements_addresses: [], - fee: 10_000_000, - validation_stamp_checksum: <<17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66, - 167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219>> - }, - confirmations: [{0, <<255, 120, 232, 52, 141, 15, 97, 213, 231, 93, 242, 160, 123, 25, 192, 3, 133, - 170, 197, 102, 148, 208, 119, 130, 225, 102, 130, 96, 223, 61, 36, 76, 229, - 210, 5, 142, 79, 249, 177, 51, 15, 45, 45, 141, 217, 85, 77, 146, 199, 126, - 213, 205, 108, 164, 167, 112, 201, 194, 113, 133, 242, 104, 254, 253>>}] - } - ], - node_availabilities: <<1::1, 1::1>>, - node_average_availabilities: [1.0, 1.0], - end_of_node_synchronizations: [<<0, 1, 190, 20, 188, 141, 156, 135, 91, 37, 96, 187, 27, 24, 41, 130, 118, - 93, 43, 240, 229, 97, 227, 194, 31, 97, 228, 78, 156, 194, 154, 74, 160, 104>>] - }, - "" - } - iex> << 2, 0, 96, 7, 114, 128, 1, 1, 2, 1, 0, 0, 234, 233, 156, 155, 114, 241, 116, 246, 27, 130, 162, 205, 249, 65, 232, 166, + iex> << 1, 0, 96, 7, 114, 128, 1, 1, 2, 1, 0, 0, 234, 233, 156, 155, 114, 241, 116, 246, 27, 130, 162, 205, 249, 65, 232, 166, ...> 99, 207, 133, 252, 112, 223, 41, 12, 206, 162, 233, 28, 49, 204, 255, 12, 0, 0, 1, 114, 236, 9, 2, 168, ...> 253, 0, 0, 0, 0, 0, 152, 150, 128, 1, 0, 17, 8, 18, 246, 127, 161, 225, 240, 17, 127, 111, 61, 112, 36, 28, 26, 66, ...> 167, 176, 119, 17, 169, 60, 36, 119, 204, 81, 109, 144, 66, 249, 219, 1, 0, 64, @@ -540,7 +497,7 @@ defmodule Archethic.BeaconChain.Summary do ...> |> Summary.deserialize() { %Summary{ - version: 2, + version: 1, subset: <<0>>, summary_time: ~U[2021-01-20 00:00:00Z], availability_adding_time: 900, @@ -572,37 +529,7 @@ defmodule Archethic.BeaconChain.Summary do } """ @spec deserialize(bitstring()) :: {t(), bitstring()} - def deserialize(<<1::8, subset::8, summary_timestamp::32, rest::bitstring>>) do - {nb_transaction_attestations, rest} = rest |> VarInt.get_value() - - {transaction_attestations, rest} = - Utils.deserialize_transaction_attestations(rest, nb_transaction_attestations, []) - - <> = - rest - - <> = rest - - {nb_end_of_sync, rest} = rest |> VarInt.get_value() - - {end_of_node_synchronizations, <>} = - Utils.deserialize_public_key_list(rest, nb_end_of_sync, []) - - node_average_availabilities = for <>, do: avg / 100 - - {%__MODULE__{ - subset: <>, - summary_time: DateTime.from_unix!(summary_timestamp), - availability_adding_time: availability_adding_time, - transaction_attestations: transaction_attestations, - node_availabilities: availabilities, - node_average_availabilities: node_average_availabilities, - end_of_node_synchronizations: end_of_node_synchronizations, - version: 1 - }, rest} - end - - def deserialize(<<2::8, subset::8, summary_timestamp::32, rest::bitstring>>) do + def deserialize(<>) do {nb_transaction_attestations, rest} = rest |> VarInt.get_value() {transaction_attestations, rest} = @@ -637,7 +564,7 @@ defmodule Archethic.BeaconChain.Summary do node_average_availabilities: node_average_availabilities, end_of_node_synchronizations: end_of_node_synchronizations, network_patches: network_patches, - version: 2 + version: version }, rest} end end