Data_encoding/Json: use strings for all int64

See Issue #190
This commit is contained in:
Raphaël Proust 2018-05-16 15:07:15 +08:00 committed by Benjamin Canou
parent 5d8c73dacb
commit 025187da2f
5 changed files with 17 additions and 23 deletions

View File

@ -7,10 +7,10 @@
],
"dictator_pubkey":
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2",
"time_between_blocks" : [ 1, 0 ],
"time_between_blocks" : [ "1", "0" ],
"blocks_per_roll_snapshot" : 4,
"blocks_per_cycle" : 8,
"preserved_cycles" : 2,
"first_free_baking_slot" : 4,
"proof_of_work_threshold": -1
"proof_of_work_threshold": "-1"
}

View File

@ -20,10 +20,10 @@
],
"dictator_pubkey":
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2",
"time_between_blocks" : [ 1, 0 ],
"time_between_blocks" : [ "1", "0" ],
"blocks_per_cycle" : 128,
"blocks_per_roll_snapshot" : 32,
"preserved_cycles" : 1,
"first_free_baking_slot" : 4,
"proof_of_work_threshold": -1
"proof_of_work_threshold": "-1"
}

View File

@ -37,7 +37,7 @@ init_sandboxed_client() {
],
"dictator_pubkey":
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2",
"time_between_blocks" : [ 1, 0 ],
"time_between_blocks" : [ "1", "0" ],
"blocks_per_roll_snapshot" : 4,
"blocks_per_cycle" : 8,
"preserved_cycles" : 2,

View File

@ -31,18 +31,13 @@ let wrap_error f =
let int64_encoding =
let open Json_encoding in
union [
case
int32
(fun i ->
let j = Int64.to_int32 i in
if Int64.equal (Int64.of_int32 j) i then Some j else None)
Int64.of_int32 ;
case
def "int64"
~title: "64 bit integers"
~description: "Decimal representation of 64 bit integers" @@
conv
Int64.to_string
(wrap_error Int64.of_string)
string
(fun i -> Some (Int64.to_string i))
Int64.of_string
]
let n_encoding =
let open Json_encoding in
@ -51,8 +46,7 @@ let n_encoding =
~description: "Decimal representation of a positive big number" @@
conv
(fun z ->
if Z.sign z < 0 then
raise (Json_encoding.Cannot_destruct ([], Failure "negative natural")) ;
if Z.sign z < 0 then invalid_arg "negative natural" ;
Z.to_string z)
(fun s ->
let n = Z.of_string s in

View File

@ -76,12 +76,12 @@ let protocol_parameters =
[ "btz1Q1N2ePwhVw5ED3aaRVek6EBzYs1GDkSVD", "3569618927693" ],
[ "btz1VFFVsVMYHd5WfaDTAt92BeQYGK8Ri4eLy", "9034781424478" ]
],
"time_between_blocks" : [ 1, 0 ],
"time_between_blocks" : [ "1", "0" ],
"blocks_per_cycle" : 4,
"blocks_per_roll_snapshot" : 2,
"preserved_cycles" : 1,
"first_free_baking_slot" : 4,
"proof_of_work_threshold": -1
"proof_of_work_threshold": "-1"
}
|json} in
match json_result with
@ -99,13 +99,13 @@ let vote_protocol_parameters =
[ "edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU", "4000000000000" ],
[ "edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n", "4000000000000" ]
],
"time_between_blocks" : [ 1, 0 ],
"time_between_blocks" : [ "1", "0" ],
"blocks_per_cycle" : 4,
"blocks_per_roll_snapshot" : 2,
"preserved_cycles" : 1,
"first_free_baking_slot" : 4,
"blocks_per_voting_period": 2,
"proof_of_work_threshold": -1
"proof_of_work_threshold": "-1"
}
|json} in
match json_result with