Proto: let genesis be agnostic on fitness

This commit is contained in:
Grégoire Henry 2017-02-25 18:01:29 +01:00
parent e88e4b0848
commit c277b5b56d
4 changed files with 11 additions and 4 deletions

View File

@ -59,6 +59,8 @@ let commands () =
end
(fun hash fitness seckey cctxt ->
let block = Client_config.block () in
let fitness =
Client_embedded_proto_alpha.Fitness_repr.from_int64 fitness in
mine cctxt block (Activate hash) fitness seckey >>= handle_error cctxt)
;
command ~desc: "Fork a test protocol" begin
@ -77,6 +79,8 @@ let commands () =
end
(fun hash fitness seckey cctxt ->
let block = Client_config.block () in
let fitness =
Client_embedded_proto_alpha.Fitness_repr.from_int64 fitness in
mine cctxt block (Activate_testnet hash) fitness seckey >>= handle_error cctxt) ;
]

View File

@ -11,5 +11,7 @@ val mine:
Client_commands.context ->
Client_node_rpcs.Blocks.block ->
Data.Command.t ->
int64 -> Sodium.secret Sodium.Sign.key -> unit tzresult Lwt.t
Fitness.fitness ->
Environment.Ed25519.secret_key ->
unit tzresult Lwt.t

View File

@ -42,7 +42,7 @@ module Forge = struct
(req "net_id" Updater.Net_id.encoding)
(req "predecessor" Block_hash.encoding)
(req "timestamp" Time.encoding)
(req "fitness" Data_encoding.int64))
(req "fitness" Fitness.encoding))
Data.Command.encoding)
~output: (obj1 (req "payload" bytes))
RPC.Path.(custom_root / "helpers" / "forge" / "block")
@ -60,7 +60,6 @@ let rpc_services : Context.t RPC.directory =
dir
(Forge.block RPC.Path.root)
(fun _ctxt ((net_id, predecessor, timestamp, fitness), command) ->
let fitness = [ MBytes.of_string "\000" ; int64_to_bytes fitness ] in
let shell = { Updater.net_id ; predecessor ; timestamp ;
fitness ; operations = [] } in
let bytes = Data.Command.forge shell command in

View File

@ -82,9 +82,11 @@ let genesis_sk =
"edskRhxswacLW6jF6ULavDdzwqnKJVS4UcDTNiCyiH6H8ZNnn2pmNviL7pRNz9kRxxaWQFzEQEcZExGHKbwmuaAcoMegj5T99z"
let switch_protocol () =
let fitness =
Client_embedded_proto_alpha.Fitness_repr.from_int64 0L in
Client_genesis.Client_proto_main.mine cctxt `Genesis
(Activate Client_alpha.Client_proto_main.protocol)
0L genesis_sk
fitness genesis_sk
let bootstrap_accounts () =
Client_proto_rpcs.Constants.bootstrap cctxt (`Head 0)