Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f67abea43a |
@@ -5,7 +5,6 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
-module(aeser_api_encoder).
|
-module(aeser_api_encoder).
|
||||||
-vsn("0.1.2").
|
|
||||||
|
|
||||||
-export([encode/2,
|
-export([encode/2,
|
||||||
decode/1,
|
decode/1,
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
-module(aeser_chain_objects).
|
-module(aeser_chain_objects).
|
||||||
-vsn("0.1.2").
|
|
||||||
|
|
||||||
-export([ serialize/4
|
-export([ serialize/4
|
||||||
, deserialize/4
|
, deserialize/4
|
||||||
@@ -105,6 +104,7 @@ tag(ac_create_tx) -> 93;
|
|||||||
tag(ac_deposit_tx) -> 94;
|
tag(ac_deposit_tx) -> 94;
|
||||||
tag(ac_update_cops_tx) -> 95;
|
tag(ac_update_cops_tx) -> 95;
|
||||||
tag(ac_rollup_tx) -> 96;
|
tag(ac_rollup_tx) -> 96;
|
||||||
|
tag(ac_proposal_tx) -> 97;
|
||||||
tag(key_block) -> 100;
|
tag(key_block) -> 100;
|
||||||
tag(micro_block) -> 101;
|
tag(micro_block) -> 101;
|
||||||
tag(light_micro_block) -> 102;
|
tag(light_micro_block) -> 102;
|
||||||
@@ -190,6 +190,7 @@ rev_tag(93) -> ac_create_tx;
|
|||||||
rev_tag(94) -> ac_deposit_tx;
|
rev_tag(94) -> ac_deposit_tx;
|
||||||
rev_tag(95) -> ac_update_cops_tx;
|
rev_tag(95) -> ac_update_cops_tx;
|
||||||
rev_tag(96) -> ac_rollup_tx;
|
rev_tag(96) -> ac_rollup_tx;
|
||||||
|
rev_tag(97) -> ac_proposal_tx;
|
||||||
rev_tag(100) -> key_block;
|
rev_tag(100) -> key_block;
|
||||||
rev_tag(101) -> micro_block;
|
rev_tag(101) -> micro_block;
|
||||||
rev_tag(102) -> light_micro_block;
|
rev_tag(102) -> light_micro_block;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
-module(aeser_contract_code).
|
-module(aeser_contract_code).
|
||||||
-vsn("0.1.2").
|
|
||||||
|
|
||||||
-include("aeser_contract_code.hrl").
|
-include("aeser_contract_code.hrl").
|
||||||
|
|
||||||
@@ -17,15 +16,14 @@
|
|||||||
serialize(CodeMap) ->
|
serialize(CodeMap) ->
|
||||||
serialize(CodeMap, ?SOPHIA_CONTRACT_VSN_3).
|
serialize(CodeMap, ?SOPHIA_CONTRACT_VSN_3).
|
||||||
|
|
||||||
|
|
||||||
-spec serialize(map(), non_neg_integer()) -> binary().
|
-spec serialize(map(), non_neg_integer()) -> binary().
|
||||||
serialize(CodeMap = #{ byte_code := ByteCode
|
serialize(CodeMap = #{ byte_code := ByteCode
|
||||||
, type_info := TypeInfo }, SophiaContractVersion) ->
|
, type_info := TypeInfo }, SophiaContractVersion) ->
|
||||||
%% Source hash
|
%% Source hash
|
||||||
SourceHash =
|
SourceHash = case CodeMap of
|
||||||
case CodeMap of
|
|
||||||
#{ source_hash := SHash } -> SHash;
|
#{ source_hash := SHash } -> SHash;
|
||||||
#{ contract_source := SrcStr } -> blake2(32, list_to_binary(SrcStr))
|
#{ contract_source := SrcStr } ->
|
||||||
|
enacl:generichash(32, list_to_binary(SrcStr))
|
||||||
end,
|
end,
|
||||||
|
|
||||||
%% Compiler version
|
%% Compiler version
|
||||||
@@ -49,21 +47,6 @@ serialize(CodeMap = #{ byte_code := ByteCode
|
|||||||
serialization_template(SophiaContractVersion),
|
serialization_template(SophiaContractVersion),
|
||||||
Fields).
|
Fields).
|
||||||
|
|
||||||
% NOTE:
|
|
||||||
% This form significantly favors the presence of enacl and slows fallback
|
|
||||||
% invokation of eblake2. `try' is really fast; the error throwing machinery
|
|
||||||
% is comparatively slow. The assumption here is that in cases where you want
|
|
||||||
% eblake2 performance isn't the problem you're solving (you're probably not
|
|
||||||
% syncing a new node, for example).
|
|
||||||
blake2(Size, Bin) ->
|
|
||||||
try
|
|
||||||
enacl:generichash(Size, Bin)
|
|
||||||
catch error:undef ->
|
|
||||||
{ok, Hash} = eblake2:blake2b(Size, Bin),
|
|
||||||
Hash
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
-spec deserialize(binary()) -> map().
|
-spec deserialize(binary()) -> map().
|
||||||
deserialize(Binary) ->
|
deserialize(Binary) ->
|
||||||
case aeser_chain_objects:deserialize_type_and_vsn(Binary) of
|
case aeser_chain_objects:deserialize_type_and_vsn(Binary) of
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
-module(aeser_delegation).
|
-module(aeser_delegation).
|
||||||
-vsn("0.1.2").
|
|
||||||
|
|
||||||
-export([ aens_preclaim_sig/3
|
-export([ aens_preclaim_sig/3
|
||||||
, aens_name_sig/4
|
, aens_name_sig/4
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
-module(aeser_id).
|
-module(aeser_id).
|
||||||
-vsn("0.1.2").
|
|
||||||
|
|
||||||
-export([ create/2
|
-export([ create/2
|
||||||
, specialize/1
|
, specialize/1
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
-module(aeser_rlp).
|
-module(aeser_rlp).
|
||||||
-vsn("0.1.2").
|
|
||||||
-export([ decode/1
|
-export([ decode/1
|
||||||
, decode_one/1
|
, decode_one/1
|
||||||
, encode/1
|
, encode/1
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
-module(aeserialization).
|
-module(aeserialization).
|
||||||
-vsn("0.1.2").
|
|
||||||
|
|
||||||
-export([ decode_fields/2
|
-export([ decode_fields/2
|
||||||
, deserialize/5
|
, deserialize/5
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
{name,"Gajumaru Serialization"}.
|
|
||||||
{type,lib}.
|
|
||||||
{modules,[]}.
|
|
||||||
{prefix,none}.
|
|
||||||
{author,"Hans Svensson"}.
|
|
||||||
{desc,"Serialization helpers for the Gajumaru."}.
|
|
||||||
{package_id,{"otpr","gmserialization",{0,1,2}}}.
|
|
||||||
{deps,[{"otpr","base58",{0,1,1}},{"otpr","eblake2",{1,0,0}}]}.
|
|
||||||
{key_name,none}.
|
|
||||||
{a_email,[]}.
|
|
||||||
{c_email,[]}.
|
|
||||||
{copyright,"Hans Svensson"}.
|
|
||||||
{file_exts,[]}.
|
|
||||||
{license,skip}.
|
|
||||||
{repo_url,"https://git.qpq.swiss/QPQ-AG/gmserialization"}.
|
|
||||||
{tags,["blockchain","crypto","gm", "gajumaru"]}.
|
|
||||||
{ws_url,[]}.
|
|
||||||
Reference in New Issue
Block a user