Alpha: Remove more dead code with in storage functor.
There are no instances of Carbonated values that have not a variable lenght. And I don't forsee this changing anythime soon.
This commit is contained in:
parent
ff428fe680
commit
233273dff8
@ -24,7 +24,8 @@ module Make_carbonated_value (V : VALUE) = struct
|
|||||||
include V
|
include V
|
||||||
let size =
|
let size =
|
||||||
match Data_encoding.classify V.encoding with
|
match Data_encoding.classify V.encoding with
|
||||||
| `Fixed size -> Fixed size
|
| `Fixed _size ->
|
||||||
|
assert false
|
||||||
| `Variable | `Dynamic -> Variable
|
| `Variable | `Dynamic -> Variable
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -328,40 +329,22 @@ module Make_indexed_carbonated_data_storage
|
|||||||
let consume_mem_gas c =
|
let consume_mem_gas c =
|
||||||
Lwt.return (C.consume_gas c (Gas_limit_repr.read_bytes_cost Z.zero))
|
Lwt.return (C.consume_gas c (Gas_limit_repr.read_bytes_cost Z.zero))
|
||||||
let existing_size c i =
|
let existing_size c i =
|
||||||
match V.size with
|
C.get_option c (len_name i) >>= function
|
||||||
| Fixed len ->
|
| None -> return 0
|
||||||
C.mem c (name i) >>= fun exists ->
|
| Some len -> decode_len_value (len_name i) len
|
||||||
if exists then return len else return 0
|
|
||||||
| Variable ->
|
|
||||||
C.get_option c (len_name i) >>= function
|
|
||||||
| None -> return 0
|
|
||||||
| Some len -> decode_len_value (len_name i) len
|
|
||||||
let consume_read_gas get c i =
|
let consume_read_gas get c i =
|
||||||
match V.size with
|
get c (len_name i) >>=? fun len ->
|
||||||
| Fixed len ->
|
decode_len_value (len_name i) len >>=? fun len ->
|
||||||
Lwt.return (C.consume_gas c (Gas_limit_repr.read_bytes_cost (Z.of_int len)))
|
Lwt.return (C.consume_gas c (Gas_limit_repr.read_bytes_cost (Z.of_int len)))
|
||||||
| Variable ->
|
|
||||||
get c (len_name i) >>=? fun len ->
|
|
||||||
decode_len_value (len_name i) len >>=? fun len ->
|
|
||||||
Lwt.return (C.consume_gas c (Gas_limit_repr.read_bytes_cost (Z.of_int len)))
|
|
||||||
let consume_write_gas set c i v =
|
let consume_write_gas set c i v =
|
||||||
match V.size with
|
let bytes = to_bytes v in
|
||||||
| Fixed s ->
|
let len = MBytes.length bytes in
|
||||||
Lwt.return (C.consume_gas c (Gas_limit_repr.write_bytes_cost (Z.of_int s))) >>=? fun c ->
|
Lwt.return (C.consume_gas c (Gas_limit_repr.write_bytes_cost (Z.of_int len))) >>=? fun c ->
|
||||||
return (c, to_bytes v)
|
set c (len_name i) (encode_len_value bytes) >>=? fun c ->
|
||||||
| Variable ->
|
return (c, bytes)
|
||||||
let bytes = to_bytes v in
|
|
||||||
let len = MBytes.length bytes in
|
|
||||||
Lwt.return (C.consume_gas c (Gas_limit_repr.write_bytes_cost (Z.of_int len))) >>=? fun c ->
|
|
||||||
set c (len_name i) (encode_len_value bytes) >>=? fun c ->
|
|
||||||
return (c, bytes)
|
|
||||||
let consume_remove_gas del c i =
|
let consume_remove_gas del c i =
|
||||||
match V.size with
|
Lwt.return (C.consume_gas c (Gas_limit_repr.write_bytes_cost Z.zero)) >>=? fun c ->
|
||||||
| Fixed _ ->
|
del c (len_name i)
|
||||||
Lwt.return (C.consume_gas c (Gas_limit_repr.write_bytes_cost Z.zero))
|
|
||||||
| Variable ->
|
|
||||||
Lwt.return (C.consume_gas c (Gas_limit_repr.write_bytes_cost Z.zero)) >>=? fun c ->
|
|
||||||
del c (len_name i)
|
|
||||||
let mem s i =
|
let mem s i =
|
||||||
consume_mem_gas s >>=? fun s ->
|
consume_mem_gas s >>=? fun s ->
|
||||||
C.mem s (name i) >>= fun exists ->
|
C.mem s (name i) >>= fun exists ->
|
||||||
@ -770,40 +753,22 @@ module Make_indexed_subcontext (C : Raw_context.T) (I : INDEX)
|
|||||||
let consume_mem_gas c =
|
let consume_mem_gas c =
|
||||||
Lwt.return (Raw_context.consume_gas c (Gas_limit_repr.read_bytes_cost Z.zero))
|
Lwt.return (Raw_context.consume_gas c (Gas_limit_repr.read_bytes_cost Z.zero))
|
||||||
let existing_size c =
|
let existing_size c =
|
||||||
match V.size with
|
Raw_context.get_option c len_name >>= function
|
||||||
| Fixed len ->
|
| None -> return 0
|
||||||
Raw_context.mem c data_name >>= fun exists ->
|
| Some len -> decode_len_value len_name len
|
||||||
if exists then return len else return 0
|
|
||||||
| Variable ->
|
|
||||||
Raw_context.get_option c len_name >>= function
|
|
||||||
| None -> return 0
|
|
||||||
| Some len -> decode_len_value len_name len
|
|
||||||
let consume_read_gas get c =
|
let consume_read_gas get c =
|
||||||
match V.size with
|
get c (len_name) >>=? fun len ->
|
||||||
| Fixed len ->
|
decode_len_value len_name len >>=? fun len ->
|
||||||
Lwt.return (Raw_context.consume_gas c (Gas_limit_repr.read_bytes_cost (Z.of_int len)))
|
Lwt.return (Raw_context.consume_gas c (Gas_limit_repr.read_bytes_cost (Z.of_int len)))
|
||||||
| Variable ->
|
|
||||||
get c (len_name) >>=? fun len ->
|
|
||||||
decode_len_value len_name len >>=? fun len ->
|
|
||||||
Lwt.return (Raw_context.consume_gas c (Gas_limit_repr.read_bytes_cost (Z.of_int len)))
|
|
||||||
let consume_write_gas set c v =
|
let consume_write_gas set c v =
|
||||||
match V.size with
|
let bytes = to_bytes v in
|
||||||
| Fixed s ->
|
let len = MBytes.length bytes in
|
||||||
Lwt.return (Raw_context.consume_gas c (Gas_limit_repr.write_bytes_cost (Z.of_int s))) >>=? fun c ->
|
Lwt.return (Raw_context.consume_gas c (Gas_limit_repr.write_bytes_cost (Z.of_int len))) >>=? fun c ->
|
||||||
return (c, to_bytes v)
|
set c len_name (encode_len_value bytes) >>=? fun c ->
|
||||||
| Variable ->
|
return (c, bytes)
|
||||||
let bytes = to_bytes v in
|
|
||||||
let len = MBytes.length bytes in
|
|
||||||
Lwt.return (Raw_context.consume_gas c (Gas_limit_repr.write_bytes_cost (Z.of_int len))) >>=? fun c ->
|
|
||||||
set c len_name (encode_len_value bytes) >>=? fun c ->
|
|
||||||
return (c, bytes)
|
|
||||||
let consume_remove_gas del c =
|
let consume_remove_gas del c =
|
||||||
match V.size with
|
Lwt.return (Raw_context.consume_gas c (Gas_limit_repr.write_bytes_cost Z.zero)) >>=? fun c ->
|
||||||
| Fixed _ ->
|
del c len_name
|
||||||
Lwt.return (Raw_context.consume_gas c (Gas_limit_repr.write_bytes_cost Z.zero))
|
|
||||||
| Variable ->
|
|
||||||
Lwt.return (Raw_context.consume_gas c (Gas_limit_repr.write_bytes_cost Z.zero)) >>=? fun c ->
|
|
||||||
del c len_name
|
|
||||||
let mem s i =
|
let mem s i =
|
||||||
consume_mem_gas (pack s i) >>=? fun c ->
|
consume_mem_gas (pack s i) >>=? fun c ->
|
||||||
Raw_context.mem c data_name >>= fun res ->
|
Raw_context.mem c data_name >>= fun res ->
|
||||||
|
Loading…
Reference in New Issue
Block a user