2017-11-17 05:47:16 +04:00
|
|
|
#use "topfind";;
|
2018-03-07 21:06:16 +04:00
|
|
|
#thread;;
|
|
|
|
#require "threads";;
|
2017-11-17 05:47:16 +04:00
|
|
|
#require "stringext";;
|
|
|
|
#require "lwt";;
|
2018-03-07 21:06:16 +04:00
|
|
|
#require "lwt.unix";;
|
2017-11-17 05:47:16 +04:00
|
|
|
#require "zarith";;
|
2018-05-17 06:36:40 +04:00
|
|
|
#require "re";;
|
|
|
|
#require "hacl";;
|
2018-03-07 21:06:16 +04:00
|
|
|
#require "calendar";;
|
|
|
|
#mod_use "../src/lib_stdlib/tzString.ml";;
|
|
|
|
#mod_use "../src/lib_stdlib/option.ml";;
|
|
|
|
#mod_use "../src/lib_stdlib/tzList.ml";;
|
|
|
|
#mod_use "../src/lib_stdlib/utils.ml";;
|
|
|
|
#mod_use "../src/lib_crypto/base58.ml";;
|
|
|
|
|
2018-07-02 13:02:59 +04:00
|
|
|
open Lwt.Infix;;
|
2018-03-07 21:06:16 +04:00
|
|
|
|
2017-09-22 00:24:10 +04:00
|
|
|
let prefix = "BLockGenesisGenesisGenesisGenesisGenesis"
|
2018-06-19 06:11:58 +04:00
|
|
|
let rec genesis () =
|
|
|
|
let date =
|
|
|
|
Lwt_main.run
|
|
|
|
(Lwt_process.pread_line (Lwt_process.shell "date +%FT%TZ --utc")) in
|
|
|
|
let suffix = String.sub Digest.(to_hex (string date)) 0 5 in
|
2018-03-07 21:06:16 +04:00
|
|
|
match Base58.raw_decode (prefix ^ suffix ^ "crcCRC") with
|
2018-06-19 06:11:58 +04:00
|
|
|
| None -> genesis ()
|
|
|
|
| Some p ->
|
|
|
|
let p = String.sub p 0 (String.length p - 4) in
|
|
|
|
Base58.safe_encode p, date
|
|
|
|
|
|
|
|
let genesis, date = genesis ()
|
2018-03-07 21:06:16 +04:00
|
|
|
|
|
|
|
let () =
|
2018-07-02 13:02:59 +04:00
|
|
|
Lwt_main.run @@
|
|
|
|
let stream = Lwt_io.lines_of_file "alphanet_version" in
|
|
|
|
Lwt_stream.to_list stream >>= function
|
|
|
|
| [] | _ :: _ :: _ -> failwith "bad alphanet_version file"
|
|
|
|
| [ line ] -> match String.split_on_char 'Z' line with
|
|
|
|
| [ _ ; branch ] ->
|
|
|
|
let contents = if String.trim branch = "" then date else date ^ branch in
|
|
|
|
Lwt_io.lines_to_file "alphanet_version" (Lwt_stream.of_list [ contents ])
|
|
|
|
| _ -> failwith "bad alphanet_version file"
|
2018-03-07 21:06:16 +04:00
|
|
|
|
|
|
|
let sed =
|
|
|
|
Format.sprintf
|
|
|
|
"sed -i \
|
|
|
|
-e 's/Time.of_notation_exn \"[^\\\"]*\"/Time.of_notation_exn \"%s\"/' \
|
|
|
|
-e 's/BLockGenesisGenesisGenesisGenesisGenesis.........../%s/' \
|
2018-03-15 14:02:08 +04:00
|
|
|
../src/bin_node/node_run_command.ml"
|
2018-03-07 21:06:16 +04:00
|
|
|
date
|
|
|
|
genesis
|
|
|
|
|
|
|
|
let _ =
|
|
|
|
Lwt_main.run (Lwt_process.exec (Lwt_process.shell sed))
|
|
|
|
|
|
|
|
let sed =
|
|
|
|
Format.sprintf
|
2018-07-02 13:02:59 +04:00
|
|
|
"sed -E -i \
|
|
|
|
-e 's/name = \"(TEZOS[A_Z]+)[^\"]*\" ;/name = \"\\1%s\" ;/' \
|
2018-03-15 14:02:08 +04:00
|
|
|
../src/lib_shell/distributed_db_message.ml"
|
2018-03-08 10:05:33 +04:00
|
|
|
date
|
2017-09-22 00:24:10 +04:00
|
|
|
|
2018-03-07 21:06:16 +04:00
|
|
|
let _ =
|
|
|
|
Lwt_main.run (Lwt_process.exec (Lwt_process.shell sed))
|