Alpha: rename cycle_length into blocks_per_cycle

This commit is contained in:
Grégoire Henry 2018-03-15 15:03:23 +01:00 committed by Benjamin Canou
parent 4f968d6fdc
commit 4be6897368
11 changed files with 33 additions and 33 deletions

View File

@ -265,7 +265,7 @@ module Constants : sig
val faucet_credit: Tez.t val faucet_credit: Tez.t
val preserved_cycles: context -> int val preserved_cycles: context -> int
val cycle_length: context -> int32 val blocks_per_cycle: context -> int32
val blocks_per_commitment: context -> int32 val blocks_per_commitment: context -> int32
val blocks_per_roll_snapshot: context -> int32 val blocks_per_roll_snapshot: context -> int32
val voting_period_length: context -> int32 val voting_period_length: context -> int32

View File

@ -269,7 +269,7 @@ let check_fitness_gap ctxt (block : Block_header.t) =
let last_of_a_cycle ctxt l = let last_of_a_cycle ctxt l =
Compare.Int32.(Int32.succ l.Level.cycle_position = Compare.Int32.(Int32.succ l.Level.cycle_position =
Constants.cycle_length ctxt) Constants.blocks_per_cycle ctxt)
let dawn_of_a_new_cycle ctxt = let dawn_of_a_new_cycle ctxt =
let level = Level.current ctxt in let level = Level.current ctxt in

View File

@ -46,7 +46,7 @@ let bootstrap_wealth =
type constants = { type constants = {
preserved_cycles: int ; preserved_cycles: int ;
cycle_length: int32 ; blocks_per_cycle: int32 ;
blocks_per_commitment: int32 ; blocks_per_commitment: int32 ;
blocks_per_roll_snapshot: int32 ; blocks_per_roll_snapshot: int32 ;
voting_period_length: int32 ; voting_period_length: int32 ;
@ -67,7 +67,7 @@ let read_public_key s = Ed25519.Public_key.of_hex_exn (`Hex s)
let default = { let default = {
preserved_cycles = 5 ; preserved_cycles = 5 ;
cycle_length = 4096l ; blocks_per_cycle = 4096l ;
blocks_per_commitment = 32l ; blocks_per_commitment = 32l ;
blocks_per_roll_snapshot = 256l ; blocks_per_roll_snapshot = 256l ;
voting_period_length = 32768l ; voting_period_length = 32768l ;
@ -116,9 +116,9 @@ let constants_encoding =
let preserved_cycles = let preserved_cycles =
opt Compare.Int.(=) opt Compare.Int.(=)
default.preserved_cycles c.preserved_cycles default.preserved_cycles c.preserved_cycles
and cycle_length = and blocks_per_cycle =
opt Compare.Int32.(=) opt Compare.Int32.(=)
default.cycle_length c.cycle_length default.blocks_per_cycle c.blocks_per_cycle
and blocks_per_commitment = and blocks_per_commitment =
opt Compare.Int32.(=) opt Compare.Int32.(=)
default.blocks_per_commitment c.blocks_per_commitment default.blocks_per_commitment c.blocks_per_commitment
@ -163,7 +163,7 @@ let constants_encoding =
default.michelson_maximum_type_size c.michelson_maximum_type_size default.michelson_maximum_type_size c.michelson_maximum_type_size
in in
((( preserved_cycles, ((( preserved_cycles,
cycle_length, blocks_per_cycle,
blocks_per_commitment, blocks_per_commitment,
blocks_per_roll_snapshot, blocks_per_roll_snapshot,
voting_period_length, voting_period_length,
@ -179,7 +179,7 @@ let constants_encoding =
token_per_rolls, token_per_rolls,
michelson_maximum_type_size)), ()) ) michelson_maximum_type_size)), ()) )
(fun ((( preserved_cycles, (fun ((( preserved_cycles,
cycle_length, blocks_per_cycle,
blocks_per_commitment, blocks_per_commitment,
blocks_per_roll_snapshot, blocks_per_roll_snapshot,
voting_period_length, voting_period_length,
@ -196,8 +196,8 @@ let constants_encoding =
michelson_maximum_type_size)), ()) -> michelson_maximum_type_size)), ()) ->
{ preserved_cycles = { preserved_cycles =
unopt default.preserved_cycles preserved_cycles ; unopt default.preserved_cycles preserved_cycles ;
cycle_length = blocks_per_cycle =
unopt default.cycle_length cycle_length ; unopt default.blocks_per_cycle blocks_per_cycle ;
blocks_per_commitment = blocks_per_commitment =
unopt default.blocks_per_commitment blocks_per_commitment ; unopt default.blocks_per_commitment blocks_per_commitment ;
blocks_per_roll_snapshot = blocks_per_roll_snapshot =
@ -233,7 +233,7 @@ let constants_encoding =
(merge_objs (merge_objs
(obj9 (obj9
(opt "preserved_cycles" uint8) (opt "preserved_cycles" uint8)
(opt "cycle_length" int32) (opt "blocks_per_cycle" int32)
(opt "blocks_per_commitment" int32) (opt "blocks_per_commitment" int32)
(opt "blocks_per_roll_snapshot" int32) (opt "blocks_per_roll_snapshot" int32)
(opt "voting_period_length" int32) (opt "voting_period_length" int32)
@ -261,7 +261,7 @@ let read = function
match Data_encoding.Json.(destruct constants_encoding json) with match Data_encoding.Json.(destruct constants_encoding json) with
| exception exn -> fail (Constant_read exn) | exception exn -> fail (Constant_read exn)
| c -> | c ->
if Compare.Int32.(c.blocks_per_roll_snapshot > c.cycle_length) then if Compare.Int32.(c.blocks_per_roll_snapshot > c.blocks_per_cycle) then
failwith "Invalid sandbox: 'blocks_per_roll_snapshot > cycle_length'" failwith "Invalid sandbox: 'blocks_per_roll_snapshot > blocks_per_cycle'"
else else
return c return c

View File

@ -24,13 +24,13 @@ module S = struct
~output: (obj1 (req "preserved_cycles" int31)) ~output: (obj1 (req "preserved_cycles" int31))
RPC_path.(custom_root / "preserved_cycles") RPC_path.(custom_root / "preserved_cycles")
let cycle_length = let blocks_per_cycle =
RPC_service.post_service RPC_service.post_service
~description: "Cycle length" ~description: "Cycle length"
~query: RPC_query.empty ~query: RPC_query.empty
~input: empty ~input: empty
~output: (obj1 (req "cycle_length" int32)) ~output: (obj1 (req "blocks_per_cycle" int32))
RPC_path.(custom_root / "cycle_length") RPC_path.(custom_root / "blocks_per_cycle")
let voting_period_length = let voting_period_length =
RPC_service.post_service RPC_service.post_service
@ -112,8 +112,8 @@ let () =
register0 S.preserved_cycles begin fun ctxt () () -> register0 S.preserved_cycles begin fun ctxt () () ->
return (Constants.preserved_cycles ctxt) return (Constants.preserved_cycles ctxt)
end ; end ;
register0 S.cycle_length begin fun ctxt () () -> register0 S.blocks_per_cycle begin fun ctxt () () ->
return (Constants.cycle_length ctxt) return (Constants.blocks_per_cycle ctxt)
end ; end ;
register0 S.voting_period_length begin fun ctxt () () -> register0 S.voting_period_length begin fun ctxt () () ->
return (Constants.voting_period_length ctxt) return (Constants.voting_period_length ctxt)
@ -143,8 +143,8 @@ let () =
return (Data_encoding.Json.(schema error_encoding)) return (Data_encoding.Json.(schema error_encoding))
end end
let cycle_length ctxt block = let blocks_per_cycle ctxt block =
RPC_context.make_call0 S.cycle_length ctxt block () () RPC_context.make_call0 S.blocks_per_cycle ctxt block () ()
let preserved_cycles ctxt block = let preserved_cycles ctxt block =
RPC_context.make_call0 S.preserved_cycles ctxt block () () RPC_context.make_call0 S.preserved_cycles ctxt block () ()
let voting_period_length ctxt block = let voting_period_length ctxt block =

View File

@ -12,7 +12,7 @@ open Alpha_context
val preserved_cycles: val preserved_cycles:
'a #RPC_context.simple -> 'a -> int shell_tzresult Lwt.t 'a #RPC_context.simple -> 'a -> int shell_tzresult Lwt.t
val cycle_length: val blocks_per_cycle:
'a #RPC_context.simple -> 'a -> int32 shell_tzresult Lwt.t 'a #RPC_context.simple -> 'a -> int32 shell_tzresult Lwt.t
val voting_period_length: val voting_period_length:

View File

@ -10,9 +10,9 @@
let preserved_cycles c = let preserved_cycles c =
let constants = Raw_context.constants c in let constants = Raw_context.constants c in
constants.preserved_cycles constants.preserved_cycles
let cycle_length c = let blocks_per_cycle c =
let constants = Raw_context.constants c in let constants = Raw_context.constants c in
constants.cycle_length constants.blocks_per_cycle
let blocks_per_commitment c = let blocks_per_commitment c =
let constants = Raw_context.constants c in let constants = Raw_context.constants c in
constants.blocks_per_commitment constants.blocks_per_commitment

View File

@ -72,7 +72,7 @@ let root first_level =
} }
let from_raw let from_raw
~first_level ~cycle_length ~voting_period_length ~first_level ~blocks_per_cycle ~voting_period_length
~blocks_per_commitment ~blocks_per_commitment
level = level =
let raw_level = Raw_level_repr.to_int32 level in let raw_level = Raw_level_repr.to_int32 level in
@ -80,8 +80,8 @@ let from_raw
let level_position = let level_position =
Compare.Int32.max 0l (Int32.sub raw_level first_level) in Compare.Int32.max 0l (Int32.sub raw_level first_level) in
let cycle = let cycle =
Cycle_repr.of_int32_exn (Int32.div level_position cycle_length) in Cycle_repr.of_int32_exn (Int32.div level_position blocks_per_cycle) in
let cycle_position = Int32.rem level_position cycle_length in let cycle_position = Int32.rem level_position blocks_per_cycle in
let voting_period = let voting_period =
Voting_period_repr.of_int32_exn Voting_period_repr.of_int32_exn
(Int32.div level_position voting_period_length) in (Int32.div level_position voting_period_length) in

View File

@ -29,7 +29,7 @@ val root: Raw_level_repr.t -> level
val from_raw: val from_raw:
first_level:Raw_level_repr.t -> first_level:Raw_level_repr.t ->
cycle_length:int32 -> blocks_per_cycle:int32 ->
voting_period_length:int32 -> voting_period_length:int32 ->
blocks_per_commitment:int32 -> blocks_per_commitment:int32 ->
Raw_level_repr.t -> level Raw_level_repr.t -> level

View File

@ -18,7 +18,7 @@ let from_raw c ?offset l =
let first_level = Raw_context.first_level c in let first_level = Raw_context.first_level c in
Level_repr.from_raw Level_repr.from_raw
~first_level ~first_level
~cycle_length:constants.Constants_repr.cycle_length ~blocks_per_cycle:constants.Constants_repr.blocks_per_cycle
~voting_period_length:constants.Constants_repr.voting_period_length ~voting_period_length:constants.Constants_repr.voting_period_length
~blocks_per_commitment:constants.Constants_repr.blocks_per_commitment ~blocks_per_commitment:constants.Constants_repr.blocks_per_commitment
l l
@ -48,7 +48,7 @@ let first_level_in_cycle ctxt c =
(Int32.add (Int32.add
(Raw_level_repr.to_int32 first_level) (Raw_level_repr.to_int32 first_level)
(Int32.mul (Int32.mul
constants.Constants_repr.cycle_length constants.Constants_repr.blocks_per_cycle
(Cycle_repr.to_int32 c)))) (Cycle_repr.to_int32 c))))
let last_level_in_cycle ctxt c = let last_level_in_cycle ctxt c =

View File

@ -203,7 +203,7 @@ let prepare ~level ~timestamp ~fitness ctxt =
let level = let level =
Level_repr.from_raw Level_repr.from_raw
~first_level ~first_level
~cycle_length:constants.Constants_repr.cycle_length ~blocks_per_cycle:constants.Constants_repr.blocks_per_cycle
~voting_period_length:constants.Constants_repr.voting_period_length ~voting_period_length:constants.Constants_repr.voting_period_length
~blocks_per_commitment:constants.Constants_repr.blocks_per_commitment ~blocks_per_commitment:constants.Constants_repr.blocks_per_commitment
level in level in

View File

@ -48,13 +48,13 @@ end
module Constants = struct module Constants = struct
let cycle_length custom_root = let blocks_per_cycle custom_root =
RPC_service.post_service RPC_service.post_service
~description: "Cycle length" ~description: "Cycle length"
~query: RPC_query.empty ~query: RPC_query.empty
~input: empty ~input: empty
~output: (obj1 (req "cycle_length" int32)) ~output: (obj1 (req "blocks_per_cycle" int32))
RPC_path.(custom_root / "constants" / "cycle_length") RPC_path.(custom_root / "constants" / "blocks_per_cycle")
let voting_period_length custom_root = let voting_period_length custom_root =
RPC_service.post_service RPC_service.post_service