Distributed_db: add an argument timeout to 'prefetch`.

This commit is contained in:
Grégoire Henry 2017-11-10 20:30:29 +01:00 committed by Benjamin Canou
parent e5c931c6a3
commit 06873da197
6 changed files with 34 additions and 11 deletions

View File

@ -883,7 +883,11 @@ module type DISTRIBUTED_DB = sig
val read_opt: t -> key -> value option Lwt.t val read_opt: t -> key -> value option Lwt.t
val read_exn: t -> key -> value Lwt.t val read_exn: t -> key -> value Lwt.t
val watch: t -> (key * value) Lwt_stream.t * Watcher.stopper val watch: t -> (key * value) Lwt_stream.t * Watcher.stopper
val prefetch: t -> ?peer:P2p.Peer_id.t -> key -> param -> unit val prefetch:
t ->
?peer:P2p.Peer_id.t ->
?timeout:float ->
key -> param -> unit
val fetch: val fetch:
t -> t ->
?peer:P2p.Peer_id.t -> ?peer:P2p.Peer_id.t ->
@ -909,7 +913,8 @@ module Make
let read t k = Table.read (Kind.proj t) k let read t k = Table.read (Kind.proj t) k
let read_opt t k = Table.read_opt (Kind.proj t) k let read_opt t k = Table.read_opt (Kind.proj t) k
let read_exn t k = Table.read_exn (Kind.proj t) k let read_exn t k = Table.read_exn (Kind.proj t) k
let prefetch t ?peer k p = Table.prefetch (Kind.proj t) ?peer k p let prefetch t ?peer ?timeout k p =
Table.prefetch (Kind.proj t) ?peer ?timeout k p
let fetch t ?peer ?timeout k p = let fetch t ?peer ?timeout k p =
Table.fetch (Kind.proj t) ?peer ?timeout k p Table.fetch (Kind.proj t) ?peer ?timeout k p
let clear_or_cancel t k = Table.clear_or_cancel (Kind.proj t) k let clear_or_cancel t k = Table.clear_or_cancel (Kind.proj t) k

View File

@ -86,7 +86,11 @@ module type DISTRIBUTED_DB = sig
val read_opt: t -> key -> value option Lwt.t val read_opt: t -> key -> value option Lwt.t
val read_exn: t -> key -> value Lwt.t val read_exn: t -> key -> value Lwt.t
val watch: t -> (key * value) Lwt_stream.t * Watcher.stopper val watch: t -> (key * value) Lwt_stream.t * Watcher.stopper
val prefetch: t -> ?peer:P2p.Peer_id.t -> key -> param -> unit val prefetch:
t ->
?peer:P2p.Peer_id.t ->
?timeout:float ->
key -> param -> unit
val fetch: val fetch:
t -> t ->
?peer:P2p.Peer_id.t -> ?peer:P2p.Peer_id.t ->

View File

@ -26,7 +26,12 @@ module type DISTRIBUTED_DB = sig
val read_opt: t -> key -> value option Lwt.t val read_opt: t -> key -> value option Lwt.t
val read_exn: t -> key -> value Lwt.t val read_exn: t -> key -> value Lwt.t
val prefetch: t -> ?peer:P2p.Peer_id.t -> key -> param -> unit val prefetch:
t ->
?peer:P2p.Peer_id.t ->
?timeout:float ->
key -> param -> unit
val fetch: val fetch:
t -> t ->
?peer:P2p.Peer_id.t -> ?peer:P2p.Peer_id.t ->
@ -207,7 +212,8 @@ end = struct
wrap s k ?timeout (Lwt.waiter_of_wakener data.wakener) wrap s k ?timeout (Lwt.waiter_of_wakener data.wakener)
| Found v -> return v | Found v -> return v
let prefetch s ?peer k param = Lwt.ignore_result (fetch s ?peer k param) let prefetch s ?peer ?timeout k param =
try ignore (fetch s ?peer ?timeout k param) with _ -> ()
let notify s p k v = let notify s p k v =
match Memory_table.find s.memory k with match Memory_table.find s.memory k with

View File

@ -24,7 +24,12 @@ module type DISTRIBUTED_DB = sig
val read_opt: t -> key -> value option Lwt.t val read_opt: t -> key -> value option Lwt.t
val read_exn: t -> key -> value Lwt.t val read_exn: t -> key -> value Lwt.t
val prefetch: t -> ?peer:P2p.Peer_id.t -> key -> param -> unit val prefetch:
t ->
?peer:P2p.Peer_id.t ->
?timeout:float ->
key -> param -> unit
val fetch: val fetch:
t -> t ->
?peer:P2p.Peer_id.t -> ?peer:P2p.Peer_id.t ->

View File

@ -617,6 +617,8 @@ module Registred_protocol = struct
val complete_b58prefix : Context.t -> string -> string list Lwt.t val complete_b58prefix : Context.t -> string -> string list Lwt.t
end end
type t = (module T)
let build_v1 hash = let build_v1 hash =
let (module F) = Tezos_protocol_compiler.Registerer.get_exn hash in let (module F) = Tezos_protocol_compiler.Registerer.get_exn hash in
let module Name = struct let module Name = struct
@ -637,7 +639,8 @@ module Registred_protocol = struct
VersionTable.create 20 VersionTable.create 20
let mem hash = let mem hash =
VersionTable.mem versions hash || Tezos_protocol_compiler.Registerer.mem hash VersionTable.mem versions hash ||
Tezos_protocol_compiler.Registerer.mem hash
let get_exn hash = let get_exn hash =
try VersionTable.find versions hash try VersionTable.find versions hash
@ -678,8 +681,6 @@ module Register_embedded_protocol
let complete_b58prefix = Env.Context.complete let complete_b58prefix = Env.Context.complete
end : Registred_protocol.T) end : Registred_protocol.T)
end end
let read let read

View File

@ -202,10 +202,12 @@ module Registred_protocol : sig
val complete_b58prefix : Context.t -> string -> string list Lwt.t val complete_b58prefix : Context.t -> string -> string list Lwt.t
end end
type t = (module T)
val mem: Protocol_hash.t -> bool val mem: Protocol_hash.t -> bool
val get: Protocol_hash.t -> (module T) option val get: Protocol_hash.t -> t option
val get_exn: Protocol_hash.t -> (module T) val get_exn: Protocol_hash.t -> t
end end