Shell/RPC: simplify block-watcher signature

This commit is contained in:
Grégoire Henry 2017-04-10 15:54:34 +02:00
parent f805507702
commit 1b6ecbfc81
2 changed files with 2 additions and 22 deletions

View File

@ -166,21 +166,6 @@ module RPC = struct
test_network = block.test_network ; test_network = block.test_network ;
} }
let convert_block hash ({ shell ; proto }: State.Block_header.t) = {
net = shell.net_id ;
hash = hash ;
level = shell.level ;
predecessor = shell.predecessor ;
fitness = shell.fitness ;
timestamp = shell.timestamp ;
protocol = None ;
operations_hash = shell.operations ;
operations = None ;
data = Some proto ;
test_protocol = None ;
test_network = None ;
}
let inject_block node = node.inject_block let inject_block node = node.inject_block
let inject_operation node = node.inject_operation let inject_operation node = node.inject_operation
let inject_protocol node = node.inject_protocol let inject_protocol node = node.inject_protocol
@ -534,12 +519,7 @@ module RPC = struct
heads >>= fun (_, blocks) -> heads >>= fun (_, blocks) ->
Lwt.return (List.rev blocks) Lwt.return (List.rev blocks)
let block_watcher node = let block_watcher node = Distributed_db.watch_block node.distributed_db
let stream, shutdown = Distributed_db.watch_block node.distributed_db in
Lwt_stream.map
(fun (hash, block) -> convert_block hash block)
stream,
shutdown
let valid_block_watcher node = let valid_block_watcher node =
let stream, shutdown = Validator.global_watcher node.validator in let stream, shutdown = Validator.global_watcher node.validator in

View File

@ -44,7 +44,7 @@ module RPC : sig
val raw_block_info: val raw_block_info:
t -> Block_hash.t -> block_info Lwt.t t -> Block_hash.t -> block_info Lwt.t
val block_watcher: val block_watcher:
t -> block_info Lwt_stream.t * Watcher.stopper t -> (Block_hash.t * Store.Block_header.t) Lwt_stream.t * Watcher.stopper
val valid_block_watcher: val valid_block_watcher:
t -> (block_info Lwt_stream.t * Watcher.stopper) t -> (block_info Lwt_stream.t * Watcher.stopper)
val heads: t -> block_info Block_hash.Map.t Lwt.t val heads: t -> block_info Block_hash.Map.t Lwt.t