Add a generic 'bytearray' encoding - prefix 'ba' #18

Merged
zxq9 merged 1 commits from PT-165853843-encode_binary_json_content into master 2019-05-13 21:24:16 +09:00

View File

@ -37,7 +37,8 @@
| state | state
| poi | poi
| state_trees | state_trees
| call_state_tree. | call_state_tree
| bytearray.
-type extended_type() :: known_type() | block_hash | {id_hash, [known_type()]}. -type extended_type() :: known_type() | block_hash | {id_hash, [known_type()]}.
@ -197,7 +198,8 @@ type2enc(name) -> ?BASE58;
type2enc(state) -> ?BASE64; type2enc(state) -> ?BASE64;
type2enc(poi) -> ?BASE64; type2enc(poi) -> ?BASE64;
type2enc(state_trees) -> ?BASE64; type2enc(state_trees) -> ?BASE64;
type2enc(call_state_tree) -> ?BASE64. type2enc(call_state_tree) -> ?BASE64;
type2enc(bytearray) -> ?BASE64.
type2pfx(key_block_hash) -> <<"kh">>; type2pfx(key_block_hash) -> <<"kh">>;
@ -224,7 +226,8 @@ type2pfx(name) -> <<"nm">>;
type2pfx(state) -> <<"st">>; type2pfx(state) -> <<"st">>;
type2pfx(poi) -> <<"pi">>; type2pfx(poi) -> <<"pi">>;
type2pfx(state_trees) -> <<"ss">>; type2pfx(state_trees) -> <<"ss">>;
type2pfx(call_state_tree) -> <<"cs">>. type2pfx(call_state_tree) -> <<"cs">>;
type2pfx(bytearray) -> <<"ba">>.
pfx2type(<<"kh">>) -> key_block_hash; pfx2type(<<"kh">>) -> key_block_hash;
pfx2type(<<"mh">>) -> micro_block_hash; pfx2type(<<"mh">>) -> micro_block_hash;
@ -250,7 +253,8 @@ pfx2type(<<"nm">>) -> name;
pfx2type(<<"st">>) -> state; pfx2type(<<"st">>) -> state;
pfx2type(<<"pi">>) -> poi; pfx2type(<<"pi">>) -> poi;
pfx2type(<<"ss">>) -> state_trees; pfx2type(<<"ss">>) -> state_trees;
pfx2type(<<"cs">>) -> call_state_tree. pfx2type(<<"cs">>) -> call_state_tree;
pfx2type(<<"ba">>) -> bytearray.
-spec byte_size_for_type(known_type()) -> non_neg_integer() | not_applicable. -spec byte_size_for_type(known_type()) -> non_neg_integer() | not_applicable.
@ -278,7 +282,8 @@ byte_size_for_type(peer_pubkey) -> 32;
byte_size_for_type(state) -> 32; byte_size_for_type(state) -> 32;
byte_size_for_type(poi) -> not_applicable; byte_size_for_type(poi) -> not_applicable;
byte_size_for_type(state_trees) -> not_applicable; byte_size_for_type(state_trees) -> not_applicable;
byte_size_for_type(call_state_tree) -> not_applicable. byte_size_for_type(call_state_tree) -> not_applicable;
byte_size_for_type(bytearray) -> not_applicable.
%% TODO: Fix the base58 module so that it consistently uses binaries instead %% TODO: Fix the base58 module so that it consistently uses binaries instead