text stringlengths 0 601k |
|---|
type error += Cannot_reconstruct of History_mode . t |
let ( ) = let open Data_encoding in register_error_kind ` Permanent ~ id " : reconstruction . reconstruction_failure " ~ title " : Reconstruction failure " ~ description " : Error while performing storage reconstruction . " ~ pp ( : fun ppf reason -> Format . fprintf ppf " The data contained in the storage is not valid... |
type metadata_status = Complete | Partial of Int32 . t | Not_stored |
let cemented_metadata_status cemented_store { Cemented_block_store . start_level ; end_level ; _ } = let open Lwt_tzresult_syntax in let * o = Cemented_block_store . read_block_metadata cemented_store end_level in match o with | None -> return Not_stored | Some _ -> ( let * o = Cemented_block_store . read_block_metadat... |
let check_context_hash_consistency block_validation_result block_header = let expected = block_header . Block_header . shell . context in let got = block_validation_result . Block_validation . context_hash in fail_unless ( Context_hash . equal expected got ) ( Reconstruction_failure ( Context_hash_mismatch ( block_head... |
let compute_block_metadata_hash block_metadata = Some ( Block_metadata_hash . hash_bytes block_metadata ) |
let compute_operations_metadata_hashes ops_metadata_hashes = Some ( List . map ( List . map ( fun r -> Operation_metadata_hash . hash_bytes [ r ] ) ) ops_metadata_hashes ) |
let compute_all_operations_metadata_hash block = if Block_repr . validation_passes block = 0 then None else Option . map ( fun ll -> Operation_metadata_list_list_hash . compute ( List . map Operation_metadata_list_hash . compute ll ) ) ( Block_repr . operations_metadata_hashes block ) |
let apply_context context_index chain_id ~ user_activated_upgrades ~ user_activated_protocol_overrides ~ predecessor_block_metadata_hash ~ predecessor_ops_metadata_hash ~ predecessor_block block = let open Lwt_tzresult_syntax in let block_header = Store . Block . header block in let operations = Store . Block . operati... |
let protocol_env_of_protocol_level chain_store protocol_level block_hash = let open Lwt_tzresult_syntax in let * protocol_hash = let *! o = Store . Chain . find_protocol chain_store ~ protocol_level in match o with | Some ph -> return ph | None -> fail ( Store_errors . Cannot_find_protocol protocol_level ) in match Reg... |
let restore_block_contents chain_store block_protocol_env ~ block_metadata ~ operations_metadata metadata block = let contents = if Store . Block . is_genesis chain_store ( Block_repr . hash block ) || block_protocol_env = Protocol . V0 then block . contents else { block . contents with block_metadata_hash = compute_bl... |
let reconstruct_chunk chain_store context_index ~ user_activated_upgrades ~ user_activated_protocol_overrides ~ start_level ~ end_level = let open Lwt_tzresult_syntax in let chain_id = Store . Chain . chain_id chain_store in let rec loop level acc = if level > end_level then return List . ( rev acc ) else let * block =... |
let store_chunk cemented_store chunk = let open Lwt_tzresult_syntax in let * ( lower_block , lower_env_version ) = match List . hd chunk with | None -> failwith " Cannot read chunk to cement . " | Some e -> return e in let * ( _ , higher_env_version ) = match List . hd ( List . rev chunk ) with | None -> failwith " Can... |
let gather_available_metadata chain_store ~ start_level ~ end_level = let open Lwt_tzresult_syntax in let rec aux level acc = if level > end_level then return acc else let * block = Store . Block . read_block_by_level chain_store level in let * metadata = Store . Block . get_block_metadata chain_store block in let bloc... |
let reconstruct_cemented chain_store context_index ~ user_activated_upgrades ~ user_activated_protocol_overrides ~ start_block_level = let open Lwt_tzresult_syntax in let block_store = Store . Unsafe . get_block_store chain_store in let cemented_block_store = Block_store . cemented_block_store block_store in let chain_... |
let reconstruct_floating chain_store context_index ~ user_activated_upgrades ~ user_activated_protocol_overrides = let open Lwt_tzresult_syntax in let chain_id = Store . Chain . chain_id chain_store in let chain_dir = Store . Chain . chain_dir chain_store in let block_store = Store . Unsafe . get_block_store chain_stor... |
let check_history_mode_compatibility chain_store savepoint genesis_block = match Store . Chain . history_mode chain_store with | History_mode . ( Full _ ) -> fail_when ( snd savepoint = Store . Block . level genesis_block ) ( Reconstruction_failure Nothing_to_reconstruct ) | _ as history_mode -> fail ( Cannot_reconstru... |
let restore_constants chain_store genesis_block head_lafl_block ~ cementing_highwatermark = let open Lwt_result_syntax in let head_lafl_descr = Store . Block . descriptor head_lafl_block in let checkpoint = match cementing_highwatermark with | None -> head_lafl_descr | Some chw -> if snd chw > Store . Block . level hea... |
let compute_start_level chain_store savepoint = let open Lwt_tzresult_syntax in let chain_dir = Store . Chain . chain_dir chain_store in let reconstruct_lockfile = Naming . reconstruction_lock_file chain_dir in let reconstruct_lockfile_path = Naming . file_path reconstruct_lockfile in if Sys . file_exists reconstruct_l... |
let locked chain_dir f = let open Lwt_result_syntax in let reconstruct_lockfile_path = Naming . reconstruction_lock_file chain_dir |> Naming . file_path in let *! file = Lwt_unix . openfile reconstruct_lockfile_path [ Unix . O_CREAT ; O_RDWR ; O_CLOEXEC ; O_SYNC ] 0o644 in let *! ( ) = Lwt_unix . close file in let * re... |
let reconstruct ? patch_context ~ store_dir ~ context_dir genesis ~ user_activated_upgrades ~ user_activated_protocol_overrides = let open Lwt_result_syntax in let * store = Store . init ~ block_cache_limit : 1 ? patch_context ~ store_dir ~ context_dir ~ allow_testchains : false genesis in protect ~ on_error ( : fun er... |
module Event = struct include Internal_event . Simple let section = [ " node " ; " reconstruction " ] let reconstruct_start_default = declare_1 ~ section ~ level : Notice ~ name " : reconstruct_start_default " ~ msg " : starting reconstruct from genesis toward block { block } " ~ pp1 : pp_block_descriptor ( " block " ,... |
type scalars = { string : string ; int : int } |
module Scalars = struct let pp fmt ( obj : scalars ) = pp_record fmt [ ( " string " , print_string_literal obj . string ) ; ( " int " , print_int_literal obj . int ) ; ] let equal ( a : scalars ) ( b : scalars ) = a . string = b . string && a . int = b . int end |
module MyQuery = [ % graphql { | { variousScalars @ ppxAs ( type : " scalars " ) { string int } } } ] | |
module MyQueryTest = struct let pp fmt ( obj : qt ) = pp_record fmt [ ( " variousScalars " , ( pp_to_print Scalars . pp ) obj . variousScalars ) ] let equal ( a : qt ) ( b : qt ) = Scalars . equal a . variousScalars b . variousScalars end ; ; [ % graphql { | fragment ExternalFragment on VariousScalars @ ppxAs ( type : ... |
module ExternalFragmentQueryTest = struct let pp fmt ( obj : ExternalFragmentQuery . t ) = pp_record fmt [ ( " variousScalars " , ( pp_to_print Scalars . pp ) obj . variousScalars ) ] let equal ( a : ExternalFragmentQuery . t ) ( b : ExternalFragmentQuery . t ) = Scalars . equal a . variousScalars b . variousScalars en... |
module InlineFragmentQuery = [ % graphql { | { dogOrHuman { . . . on Dog { name barkVolume } } } } ] | |
module InlineFragmentQueryTest = struct let pp fmt ( obj : if_qt ) = pp_record fmt [ ( " dogOrHuman " , fun fmt -> match obj . dogOrHuman with | ` FutureAddedValue _ -> Format . fprintf fmt " ` FutureAddedValue ( _ ) " | ` Dog ( dog : InlineFragmentQuery . t_dogOrHuman_Dog ) -> Format . fprintf fmt " ` Dog [ @% a ] " @... |
module UnionExternalFragmentQueryTest = struct let pp fmt ( obj : UnionExternalFragmentQuery . t ) = pp_record fmt [ ( " dogOrHuman " , fun fmt -> match obj . dogOrHuman with | ` FutureAddedValue _ -> Format . fprintf fmt " ` FutureAddedValue ( _ ) " | ` Dog ( dog : DogFragment . t ) -> Format . fprintf fmt " ` Dog [ @... |
let decodes_record_in_selection ( ) = test_exp ( { | { " variousScalars " : { " string " : " a string " , " int " : 123 } } } | |> Json . Read . from_string |> MyQuery . unsafe_fromJson |> MyQuery . parse ) { variousScalars = { string = " a string " ; int = 123 } } MyQueryTest . equal MyQueryTest . pp |
let decodes_record_in_external_fragment ( ) = test_exp ( { | { " variousScalars " : { " string " : " a string " , " int " : 123 } } } | |> Json . Read . from_string |> ExternalFragmentQuery . unsafe_fromJson |> ExternalFragmentQuery . parse ) { variousScalars = { string = " a string " ; int = 123 } } ExternalFragmentQu... |
let decodes_record_in_inline_fragment ( ) = test_exp ( { | { " dogOrHuman " : { " __typename " : " Dog " , " name " : " name " , " barkVolume " : 123 . 0 } } } | |> Json . Read . from_string |> InlineFragmentQuery . unsafe_fromJson |> InlineFragmentQuery . parse ) { dogOrHuman = ` Dog { name = " name " ; barkVolume = 1... |
let decodes_record_in_external_fragment_on_union_selections ( ) = test_exp ( { | { " dogOrHuman " : { " __typename " : " Dog " , " name " : " name " , " barkVolume " : 123 . 0 } } } | |> Json . Read . from_string |> UnionExternalFragmentQuery . unsafe_fromJson |> UnionExternalFragmentQuery . parse ) { dogOrHuman = ` Do... |
let tests = [ ( " Decodes a record in a selection " , decodes_record_in_selection ) ; ( " Decodes a record in an external fragment " , decodes_record_in_external_fragment ) ; ( " Decodes a record in an inline fragment " , decodes_record_in_inline_fragment ) ; ( " Decodes a record in an external fragment on union select... |
type t = A of { x : int ; mutable y : int } ; ; |
let f ( A r ) = r ; ; |
let f ( A r ) = r . x ; ; |
let f x = A { x ; y = x } ; ; |
let f ( A r ) = A { r with y = r . x + 1 } ; ; |
let f ( ) = A { a = 1 } ; ; |
let f ( ) = A { x = 1 ; y = 3 } ; ; |
type _ t = A : { x : ' a ; y : ' b } -> ' a t ; ; |
let f ( A { x ; y } ) = A { x ; y = ( ) } ; ; |
let f ( A ( { x ; y } as r ) ) = A { x = r . x ; y = r . y } ; ; |
module M = struct type ' a t = | A of { x : ' a } | B : { u : ' b } -> unit t ; ; exception Foo of { x : int } ; ; end ; ; |
module N : sig type ' b t = ' b M . t = | A of { x : ' b } | B : { u : ' bla } -> unit t exception Foo of { x : int } type ' b t = ' b M . t = | A of { x : ' b } | B : { u : ' z } -> unit t exception Foo = M . Foo end ; ; |
module type S = sig exception A of { x : int } end ; ; |
module F ( X : sig val x : ( module S ) end ) = struct module A = ( val X . x ) |
module type S = sig exception A of { x : int } exception A of { x : string } end ; ; |
module M = struct exception A of { x : int } exception A of { x : string } end ; ; |
module M1 = struct exception A of { x : int } end ; ; |
module M = struct include M1 include M1 end ; ; |
module type S1 = sig exception A of { x : int } end ; ; |
module type S = sig include S1 include S1 end ; ; |
module M = struct exception A = M1 . A end ; ; |
module X1 = struct type t = . . end ; ; |
module X2 = struct type t = . . end ; ; |
module Z = struct type X1 . t += A of { x : int } type X2 . t += A of { x : int } end ; ; |
type _ c = C : [ ` A ] c |
type t = T : { x [ ` :< A ] c } -> t ; ; |
let f ( T { x = C } ) = ( ) ; ; |
module M1 = struct type t = { x : int ; y : int } type u = { x : bool ; y : bool } end ; ; [ %% expect { | |
module M1 : sig type t = { x : int ; y : int ; } type u = { x : bool ; y : bool ; } end } ] | |
module OK = struct open M1 let f1 ( r : t ) = r . x let f2 r = ignore ( r : t ) ; r . x let f3 ( r : t ) = match r with { x ; y } -> y + y end ; ; [ %% expect { | ^ ^ ^ ^ ^ |
module OK : sig val f1 : M1 . t -> int val f2 : M1 . t -> int val f3 : M1 . t -> int end ^ ^ ^ ^ ^ ^ |
module OK : sig val f1 : M1 . t -> int val f2 : M1 . t -> int val f3 : M1 . t -> int end } ] | |
module F1 = struct open M1 let f r = match r with { x ; y } -> y + y [ %% expect { | ^^^^^^ ^ int } ] | |
module F2 = struct open M1 let f r = ignore ( r : t ) ; match r with { x ; y } -> y + y [ %% expect { | ^ ^ ^ |
module F2 : sig val f : M1 . t -> int end ^^^^^^ ^^^^^^ but a pattern was expected which matches values of type M1 . t } ] | |
module M = struct type t = { x : int } type u = { x : bool } end ; ; [ %% expect { | |
module M : sig type t = { x : int ; } type u = { x : bool ; } end } ] | |
let f ( r : M . t ) = r . M . x ; ; [ %% expect { | ^^^ } ] | |
let f ( r : M . t ) = r . x ; ; [ %% expect { | ^ ^ } ] | |
let f ( { x } : M . t ) = x ; ; [ %% expect { | ^ ^^^ } ] | |
module M = struct type t = { x : int ; y : int } end ; ; [ %% expect { | |
module M : sig type t = { x : int ; y : int ; } end } ] | |
module N = struct type u = { x : bool ; y : bool } end ; ; [ %% expect { | |
module N : sig type u = { x : bool ; y : bool ; } end } ] | |
module OK = struct open M open N let f ( r : M . t ) = r . x end ; ; [ %% expect { | ^ ^^^^^^ |
module OK : sig val f : M . t -> int end } ] | |
module M = struct type t = { x : int } module N = struct type s = t = { x : int } end type u = { x : bool } end ; ; [ %% expect { | |
module M : sig type t = { x : int ; } module N : sig type s = t = { x : int ; } end type u = { x : bool ; } end } ] | |
module OK = struct open M . N let f ( r : M . t ) = r . x end ; ; [ %% expect { | |
module OK : sig val f : M . t -> int end } ] | |
module M = struct type u = { x : bool ; y : int ; z : char } type t = { x : int ; y : bool } end ; ; [ %% expect { | |
module M : sig type u = { x : bool ; y : int ; z : char ; } type t = { x : int ; y : bool ; } end } ] | |
module OK = struct open M let f { x ; z } = x , z [ %% expect { | ^ ^^^^^ y |
module OK : sig val f : M . u -> bool * char end } ] | |
module F3 = struct open M let r = { x = true ; z ' = z ' } [ %% expect { | ^^^^^^^^^^^^^^ } ] | |
module OK = struct type u = { x : int ; y : bool } type t = { x : bool ; y : int ; z : char } let r = { x = 3 ; y = true } [ %% expect { | ^ ^ |
module OK : sig type u = { x : int ; y : bool ; } type t = { x : bool ; y : int ; z : char ; } val r : u end } ] | |
module F4 = struct type foo = { x : int ; y : int } type bar = { x : int } let b : bar = { x = 3 ; y = 4 } [ %% expect { | ^ The field y does not belong to type bar } ] | |
module M = struct type foo = { x : int ; y : int } end ; ; [ %% expect { | |
module M : sig type foo = { x : int ; y : int ; } end } ] | |
module N = struct type bar = { x : int ; y : int } end ; ; [ %% expect { | |
module N : sig type bar = { x : int ; y : int ; } end } ] | |
let r = { M . x = 3 ; N . y = 4 ; } ; ; [ %% expect { | ^^^ but is mixed here with fields of type M . foo } ] | |
module MN = struct include M include N end |
module NM = struct include N include M end ; ; [ %% expect { | |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.