text stringlengths 0 601k |
|---|
let restore_state st = global_table := st |
let hide_additions ( st : global_map ) = if st . cnt > ! global_table . cnt then fatal_error " Symtable . hide_additions " ; global_table := { GlobalMap . cnt = ! global_table . cnt ; tbl = st . tbl } |
let filter_global_map p ( gmap : global_map ) = let newtbl = ref Ident . Map . empty in Ident . Map . iter ( fun id num -> if p id then newtbl := Ident . Map . add id num ! newtbl ) gmap . tbl ; { GlobalMap . cnt = gmap . cnt ; tbl = ! newtbl } |
let iter_global_map f ( gmap : global_map ) = Ident . Map . iter f gmap . tbl |
let is_defined_in_global_map ( gmap : global_map ) id = Ident . Map . mem id gmap . tbl |
let report_error ppf = function | Undefined_global s -> fprintf ppf " Reference to undefined global ` % s ' " s | Unavailable_primitive s -> fprintf ppf " The external function ` % s ' is not available " s | Wrong_vm s -> fprintf ppf " Cannot find or execute the runtime system % s " s | Uninitialized_global s -> fprint... |
let ( ) = Location . register_error_of_exn ( function | Error err -> Some ( Location . error_of_printer_file report_error err ) | _ -> None ) |
let reset ( ) = global_table := GlobalMap . empty ; literal_table := [ ] ; c_prim_table := PrimMap . empty |
module Query = struct module Presence = struct type t = Offline | Online | Unavailable let to_string = function | Offline -> " offline " | Online -> " online " | Unavailable -> " unavailable " let pp ppf = function | Offline -> Fmt . pf ppf " Offline " | Online -> Fmt . pf ppf " Online " | Unavailable -> Fmt . pf ppf "... |
module Response = struct type t = { next_batch : string ; rooms : Rooms . t option ; presence : Events . State_event . t list option ; account_data : Events . State_event . t list option ; to_device : Events . State_event . t list option ; device_lists : Device_lists . t option ; device_one_time_keys_count : ( string *... |
type Structured_log_events . t += Snarked_ledger_synced [ @@ deriving register_event { msg = " Snarked database sync ' d . All done " } ] |
let rec funpow n f r = if n > 0 then funpow ( n - 1 ) 1 f ( f r ) r else r |
module Query = struct [ %% versioned module Stable = struct module V1 = struct type ' addr t = | What_child_hashes of ' addr | What_contents of ' addr | Num_accounts [ @@ deriving sexp , yojson , hash , compare ] compare end end ] end end |
module Answer = struct [ %% versioned module Stable = struct module V1 = struct type ( ' hash , ' account ) ' account t = | Child_hashes_are of ' hash * ' hash | Contents_are of ' account list | Num_accounts of int * ' hash [ @@ deriving sexp , yojson ] yojson let to_latest acct_to_latest = function | Child_hashes_are ... |
module type Inputs_intf = sig module Addr : module type of Merkle_address module Account : sig type t [ @@ deriving bin_io , sexp , yojson ] yojson end module Hash : Merkle_ledger . Intf . Hash with type account := Account . t module Root_hash : sig type t [ @@ deriving equal , sexp , yojson ] yojson val to_hash : t ->... |
module type S = sig type ' a t [ @@ deriving sexp ] sexp type merkle_tree type merkle_path type hash type root_hash type addr type diff type account type index = int type query type answer module Responder : sig type t val create : merkle_tree -> ( query -> unit ) unit -> logger : Logger . t -> trust_system : Trust_sys... |
module Make ( Inputs : Inputs_intf ) Inputs_intf : sig open Inputs include S with type merkle_tree := MT . t and type hash := Hash . t and type root_hash := Root_hash . t and type addr := Addr . t and type merkle_path := MT . path and type account := Account . t and type query := Addr . t Query . t and type answer := (... |
let wait_for ~ statuses node = let filter json = match JSON . ( json |=> 1 |-> " event " |> as_string_opt ) with | None -> Log . info " % s : none " ( Node . name node ) ; None | Some status -> Log . info " % s : % s " ( Node . name node ) status ; if List . exists ( fun st -> String . equal st status ) statuses then S... |
let wait_for_sync node = let filter json = match JSON . ( json |=> 1 |-> " event " |> as_string_opt ) with | None -> Log . info " % s : none " ( Node . name node ) ; None | Some status -> Log . info " % s : % s " ( Node . name node ) status ; if String . equal status " synced " then Some ( ) else None in let event = No... |
let check_node_synchronization_state = let n = 4 in let blocks_to_bake = 5 in Protocol . register_test ~ __FILE__ ~ title " : check synchronization state " ~ tags [ " : bootstrap " ; " node " ; " sync " ] @@ fun protocol -> let * main_node = Node . init ~ name " : main_node " [ ] in let * nodes = Lwt_list . map_p ( fun... |
let check_is_prevalidator_started endpoint = let client = Client . create ~ endpoint ( ) in let process = Client . spawn_rpc GET ( String . split_on_char ' ' / " chains / main / mempool / filter " ) client in Process . check ~ expect_failure : false process |
let check_is_prevalidator_closed endpoint = let client = Client . create ~ endpoint ( ) in let process = Client . spawn_rpc GET ( String . split_on_char ' ' / " chains / main / mempool / filter " ) client in Process . check ~ expect_failure : true process |
let check_prevalidator_start = Protocol . register_test ~ __FILE__ ~ title " : Check prevalidator start " ~ tags [ " : bootstrap " ; " node " ; " prevalidator " ] @@ fun protocol -> let init_node threshold = Node . init [ Synchronisation_threshold threshold ] in let * node1 = init_node 0 in let * node2 = init_node 1 in... |
let register ~ protocols = check_node_synchronization_state ~ protocols ; check_prevalidator_start ~ protocols |
module Time_ns = struct include Time_ns external format : float -> string -> string = " core_kernel_time_ns_format " let sexp_of_t t = [ % sexp ( format ( t |> to_span_since_epoch |> Span . to_sec ) " % Y -% m -% dT % H :% M :% S % z " : string ) ] ; ; end |
module Alarm = struct include Timing_wheel . Alarm let is_null t = phys_equal t ( null ( ) ) end |
let default_timing_wheel_config = Timing_wheel . Config . create ~ alarm_precision : Alarm_precision . ( div about_one_millisecond ~ pow2 : 3 ) ~ level_bits ( : Timing_wheel . Level_bits . create_exn [ 13 ; 6 ; 6 ; 5 ] ) ( ) ; ; |
type callback = unit -> unit |
module T1 = struct module Event = struct module Status = struct type t = Types . Event . Status . t = | Aborted | Fired | Happening | Scheduled | Unscheduled [ @@ deriving compare , sexp_of ] let transition_is_allowed ~ from ~ to_ = match from , to_ with | Aborted , Unscheduled | Fired , Happening | Fired , Aborted | H... |
type t = read T1 . t [ @@ deriving sexp_of ] |
module Read_write = struct type t = read_write T1 . t [ @@ deriving sexp_of ] let invariant = invariant let invariant_with_jobs = invariant_with_jobs end |
let id t = t . id |
let is_wall_clock t = t . is_wall_clock |
let length t = Timing_wheel . length t . events |
let max_allowed_alarm_time t = Timing_wheel . max_allowed_alarm_time t . events |
let read_only ( t : [ > read ] T1 . t ) = ( t :> t ) |
let fire t ( event : Event . t ) = Event . set_status event Fired ; event . alarm <- Alarm . null ( ) ; let prev = ref Event . none in let current = ref t . fired_events in if Event . is_some t . most_recently_fired && Time_ns . ( >= ) event . at t . most_recently_fired . at then ( prev := t . most_recently_fired ; cur... |
let alarm_precision t = Timing_wheel . alarm_precision t . events |
let next_alarm_fires_at t = Timing_wheel . next_alarm_fires_at t . events |
let now t = if t . is_wall_clock then Time_ns . now ( ) else timing_wheel_now t |
let schedule t ( event : Event . t ) = Event . set_status event Scheduled ; event . alarm <- Timing_wheel . add t . events ~ at : event . at ( event |> Job_or_event . of_event ) ; ; |
module Event = struct include Event let create_internal t ~ at ~ interval ~ callback = { alarm = Alarm . null ( ) ; at ; callback ; execution_context = t . scheduler . current_execution_context ; interval ; next_fired = none ; status = Unscheduled } ; ; let add t event = if Time_ns . ( <= ) event . at ( timing_wheel_no... |
let run_after t span callback = ignore ( Event . after t span callback : Event . t ) |
let run_at t at callback = ignore ( Event . at t at callback : Event . t ) |
let run_at_intervals t span callback = ignore ( Event . at_intervals t span callback : Event . t ) ; ; |
type send_exn = Monitor0 . t -> ? backtrace [ : ` Get | ` This of Backtrace . t ] -> exn -> unit |
let run_fired_events t ( ~ send_exn : send_exn option ) = let current_execution_context = t . scheduler . current_execution_context in while Event . is_some t . fired_events do let event = t . fired_events in if phys_equal event t . most_recently_fired then t . most_recently_fired <- Event . none ; t . fired_events <- ... |
let advance_clock t ~ to_ ~ send_exn = Timing_wheel . advance_clock t . events ~ to_ ~ handle_fired : t . handle_fired ; run_fired_events t ~ send_exn ; ; |
let fire_past_alarms t ~ send_exn = Timing_wheel . fire_past_alarms t . events ~ handle_fired : t . handle_fired ; run_fired_events t ~ send_exn ; ; |
let advance_internal t ~ to_ ~ send_exn = advance_clock t ~ to_ ~ send_exn ; fire_past_alarms t ~ send_exn ; ; |
let prepare_to_advance t ~ send_exn = if t . am_advancing then raise_s [ % message " cannot call [ advance_by_alarms ] from callback " ] ; t . am_advancing <- true ; ( match t . advance_errors with | [ ] -> ( ) | _ -> t . advance_errors <- [ ] ) ; run_fired_events t ~ send_exn ; ; |
let finish_advancing t = t . am_advancing <- false ; match t . advance_errors with | [ ] -> Ok ( ) | errors -> t . advance_errors <- [ ] ; Error ( Error . of_list errors ) ; ; |
let advance_by_alarms t ~ to_ = let send_exn = None in prepare_to_advance t ~ send_exn ; let continue = ref true in while ! continue do if Timing_wheel . is_empty t . events then continue := false else ( let next_alarm_fires_at = Timing_wheel . next_alarm_fires_at_exn t . events in if Time_ns . ( >= ) next_alarm_fires_... |
let advance_directly t ~ to_ = let send_exn = None in prepare_to_advance t ~ send_exn ; advance_internal t ~ to_ ~ send_exn ; finish_advancing t ; ; |
module Expert = struct let max_alarm_time_in_min_timing_wheel_interval t = Timing_wheel . max_alarm_time_in_min_interval t . events ; ; let has_events_to_run t = Event . is_some t . fired_events end |
module type Inputs_intf = sig module Transition_frontier : module type of Transition_frontier module Best_tip_prover : Mina_intf . Best_tip_prover_intf with type transition_frontier := Transition_frontier . t end |
module Make ( Inputs : Inputs_intf ) Inputs_intf : Mina_intf . Sync_handler_intf with type transition_frontier := Inputs . Transition_frontier . t = struct open Inputs let find_in_root_history frontier state_hash = let open Transition_frontier . Extensions in let root_history = get_extension ( Transition_frontier . ext... |
module Hash = struct include Ledger_hash . Stable . V1 let to_base58_check = Ledger_hash . to_base58_check let merge = Ledger_hash . merge let hash_account = Fn . compose Ledger_hash . of_digest Account . digest let empty_account = Ledger_hash . of_digest Account . empty_digest end |
module Root_hash = struct include Ledger_hash let to_hash ( h : t ) t = Ledger_hash . of_digest ( h :> Random_oracle . Digest . t ) t end |
module Mask = Syncable_ledger . Make ( struct module Addr = Ledger . Location . Addr module MT = Ledger module Account = Account . Stable . Latest module Hash = Hash module Root_hash = Root_hash let account_subtree_height = 3 end ) end |
module Any_ledger = Syncable_ledger . Make ( struct module Addr = Ledger . Location . Addr module MT = Ledger . Any_ledger . M module Account = Account . Stable . Latest module Hash = Hash module Root_hash = Root_hash let account_subtree_height = 3 end ) end |
module Db = Syncable_ledger . Make ( struct module Addr = Ledger . Db . Addr module MT = Ledger . Db module Account = Account . Stable . Latest module Hash = Hash module Root_hash = Root_hash let account_subtree_height = 3 end ) end |
module Answer = struct [ %% versioned module Stable = struct module V2 = struct type t = ( Ledger_hash . Stable . V1 . t , Account . Stable . V2 . t ) Syncable_ledger . Answer . Stable . V1 . t [ @@ deriving sexp , to_yojson ] to_yojson let to_latest = Fn . id end end ] end end |
module Query = struct [ %% versioned module Stable = struct module V1 = struct type t = Ledger . Location . Addr . Stable . V1 . t Syncable_ledger . Query . Stable . V1 . t [ @@ deriving sexp , to_yojson , hash , compare ] compare let to_latest = Fn . id end end ] end end |
let sync_releases token src_user src_repo dst_user dst_repo = Github . ( Monad . ( run ( let releases = Release . for_repo ~ token ~ user : src_user ~ repo : src_repo ( ) in Stream . to_list releases ) ) ) >>= fun src -> Github . ( Monad . ( run ( let releases = Release . for_repo ~ token ~ user : dst_user ~ repo : dst... |
let run token src_user src_repo dst_user dst_repo = Lwt_main . run ( sync_releases token src_user src_repo dst_user dst_repo ) |
let cmd = let cookie = Jar_cli . cookie ( ) in let src_user = let doc = " The source user name on GitHub " in Arg . ( required & pos 0 ( some string ) None & info [ ] ~ docv " : SRC_USER " ~ doc ) in let src_repo = let doc = " The source repository on GitHub " in Arg . ( required & pos 1 ( some string ) None & info [ ]... |
let ( ) = exit @@ Cmd . eval cmd |
let to_string = function | ` Connecting -> " Connecting " | ` Listening -> " Listening " | ` Offline -> " Offline " | ` Bootstrap -> " Bootstrap " | ` Synced -> " Synced " | ` Catchup -> " Catchup " |
let of_string string = match String . lowercase string with | " connecting " -> Ok ` Connecting | " listening " -> Ok ` Listening | " offline " -> Ok ` Offline | " bootstrap " -> Ok ` Bootstrap | " synced " -> Ok ` Synced | " catchup " -> Ok ` Catchup | status -> Error ( Error . createf " !% s is not a valid status " s... |
let to_yojson status = ` String ( to_string status ) status |
let of_yojson : Yojson . Safe . t -> ( _ , string ) string Result . t = function | ` String s -> Result . map_error ~ f : Error . to_string_hum ( of_string s ) s | _ -> Error " expected string " |
module T = struct [ %% versioned module Stable = struct module V1 = struct type t = [ ` Connecting | ` Listening | ` Offline | ` Bootstrap | ` Synced | ` Catchup ] [ @@ deriving sexp , hash , compare , equal , enumerate ] enumerate let to_latest = Fn . id let to_yojson = to_yojson let of_yojson = of_yojson module T = s... |
let check_conv to_repr of_repr ok_or_fail = List . for_all [ ` Offline ; ` Bootstrap ; ` Synced ; ` Connecting ; ` Listening ; ` Catchup ] ~ f ( : fun sync_status -> equal sync_status ( of_repr ( to_repr sync_status ) sync_status |> ok_or_fail ) ok_or_fail ) check_conv to_string of_string Or_error . ok_exn check_conv t... |
type state = Free | Bound | None |
let config = { config with agent_width = 0 . 30 . * config . agent_width ; agent_height = 0 . 23 . * config . agent_width ; site_width = 0 . 6 . * config . site_width ; site_height = 0 . 6 . * config . site_height ; state_width = 1 . 2 . * config . state_width ; state_height = 1 . 2 . * config . state_height ; free_wid... |
let [ _ , [ ax , _ ; ay , _ ; az , _ ] ] , p = add_in_graph [ a , 0 . , 0 . , [ ] , [ x , [ ] , [ ] ; y , [ ] , [ Internal_state ( yp , [ Direction e ] ) ] ; z , [ ] , [ Internal_state ( zu , [ Direction w ] ) ] ] ] signature |
let _ , p = add_free_list [ ax , [ ] ; ay , [ ] ; az , [ ] ] p |
let _ = dump " syntax_agent . ladot " p let [ a , [ ax , _ ; ay , _ ; az , _ ] ; a ' , [ ax ' , _ ; ay ' , _ ; az ' , _ ] ; a ' ' , [ ax ' ' , _ ; ay ' ' , _ ; az ' ' , _ ] ] , ring = add_in_graph [ a , 0 . , 0 . , [ ] , [ x , [ Direction se ] , [ ] ; y , [ Direction sw ] , [ Internal_state ( yu , [ Direction w ] ) ] ;... |
let ring = add_link_list [ ax , ay ' ' ; ay , ax ' ; ay ' , ax ' ' ] ring |
let _ , ring = add_free_list [ az , [ Direction n ] ; az ' , [ Direction w ] ; az ' ' , [ Direction se ] ] ring |
let _ = dump " syntax_ring . ladot " ring |
module Make ( Pretty : Pretty_intf . S ) ( Parser : Parser_intf . S ) = struct type ' a syntax = { parse : unit -> ' a Parser . syntax ; print : unit -> ' a Pretty . syntax } let ( ) <$> d0 p0 = { parse = ( fun ( ) -> Parser . ( d0 <$> p0 . parse ( ) ) ) ; print = ( fun ( ) -> Pretty . ( d0 <$> p0 . print ( ) ) ) } let... |
module Make ( Symbol : Symbol . S ) = struct module Cof = Kado . Syntax . Endo type t = | Var of int | Global of Symbol . t | Let of t * Ident . t * t | Ann of t * tp | Zero | Suc of t | NatElim of t * t * t * t | Base | Loop of t | CircleElim of t * t * t * t | Lam of Ident . t * t | Ap of t * t | Pair of t * t | Fst ... |
type error = Unclosed of Location . t * string * Location . t * string | Expecting of Location . t * string | Not_expecting of Location . t * string | Applicative_path of Location . t | Variable_in_scope of Location . t * string | Other of Location . t | Ill_formed_ast of Location . t * string | Invalid_package_type of... |
let prepare_error = function | Unclosed ( opening_loc , opening , closing_loc , closing ) -> Location . errorf ~ loc : closing_loc ~ sub [ : Location . errorf ~ loc : opening_loc " This ' % s ' might be unmatched " opening ] ~ if_highlight : ( Printf . sprintf " Syntax error : ' % s ' expected , \ the highlighted ' % s... |
let ( ) = Location . register_error_of_exn ( function | Error err -> Some ( prepare_error err ) | _ -> None ) |
let report_error ppf err = Location . report_error ppf ( prepare_error err ) |
let location_of_error = function | Unclosed ( l , _ , _ , _ ) | Applicative_path l | Variable_in_scope ( l , _ ) | Other l | Not_expecting ( l , _ ) | Ill_formed_ast ( l , _ ) | Invalid_package_type ( l , _ ) | Expecting ( l , _ ) -> l |
let ill_formed_ast loc s = raise ( Error ( Ill_formed_ast ( loc , s ) ) ) |
let a_ident = Gramf . mk " a_ident " |
let aident = Gramf . mk " aident " |
let amp_ctyp = Gramf . mk " amp_ctyp " |
let and_ctyp = Gramf . mk " and_ctyp " |
let case = Gramf . mk " case " |
let case0 = Gramf . mk " case0 " |
let bind = Gramf . mk " bind " |
let class_declaration = Gramf . mk " class_declaration " |
let class_description = Gramf . mk " class_description " |
let let_bind = Gramf . mk " let_bind " |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.