Shell/RPC: allow to fetch raw Block_header
This commit is contained in:
parent
9df99e4553
commit
5aa65ee71f
@ -67,6 +67,10 @@ let build_raw_rpc_directory
|
|||||||
return { Block_services.hash ; chain_id ;
|
return { Block_services.hash ; chain_id ;
|
||||||
shell = header.shell ; protocol_data }
|
shell = header.shell ; protocol_data }
|
||||||
end ;
|
end ;
|
||||||
|
register0 S.raw_header begin fun block () () ->
|
||||||
|
let header = State.Block.header block in
|
||||||
|
return (Data_encoding.Binary.to_bytes_exn Block_header.encoding header)
|
||||||
|
end ;
|
||||||
register0 S.Header.shell_header begin fun block () () ->
|
register0 S.Header.shell_header begin fun block () () ->
|
||||||
return (State.Block.header block).shell
|
return (State.Block.header block).shell
|
||||||
end ;
|
end ;
|
||||||
@ -77,6 +81,10 @@ let build_raw_rpc_directory
|
|||||||
Proto.block_header_data_encoding
|
Proto.block_header_data_encoding
|
||||||
header.protocol_data)
|
header.protocol_data)
|
||||||
end ;
|
end ;
|
||||||
|
register0 S.Header.raw_protocol_data begin fun block () () ->
|
||||||
|
let header = State.Block.header block in
|
||||||
|
return header.protocol_data
|
||||||
|
end ;
|
||||||
|
|
||||||
(* block metadata *)
|
(* block metadata *)
|
||||||
|
|
||||||
@ -197,7 +205,7 @@ let build_raw_rpc_directory
|
|||||||
|
|
||||||
(* helpers *)
|
(* helpers *)
|
||||||
|
|
||||||
register0 Shell_services.Blocks.S.Helpers.Forge.block_header begin fun _block () header ->
|
register0 S.Helpers.Forge.block_header begin fun _block () header ->
|
||||||
return (Data_encoding.Binary.to_bytes_exn Block_header.encoding header)
|
return (Data_encoding.Binary.to_bytes_exn Block_header.encoding header)
|
||||||
end ;
|
end ;
|
||||||
|
|
||||||
|
@ -337,6 +337,13 @@ module Make(Proto : PROTO)(Next_proto : PROTO) = struct
|
|||||||
~output: block_header_encoding
|
~output: block_header_encoding
|
||||||
RPC_path.(path / "header")
|
RPC_path.(path / "header")
|
||||||
|
|
||||||
|
let raw_header =
|
||||||
|
RPC_service.get_service
|
||||||
|
~description:"The whole block header (unparsed)."
|
||||||
|
~query: RPC_query.empty
|
||||||
|
~output: bytes
|
||||||
|
RPC_path.(path / "header" / "raw")
|
||||||
|
|
||||||
let metadata =
|
let metadata =
|
||||||
RPC_service.get_service
|
RPC_service.get_service
|
||||||
~description:"All the metadata associated to the block."
|
~description:"All the metadata associated to the block."
|
||||||
@ -375,6 +382,13 @@ module Make(Proto : PROTO)(Next_proto : PROTO) = struct
|
|||||||
Proto.block_header_data_encoding))
|
Proto.block_header_data_encoding))
|
||||||
RPC_path.(path / "protocol_data")
|
RPC_path.(path / "protocol_data")
|
||||||
|
|
||||||
|
let raw_protocol_data =
|
||||||
|
RPC_service.get_service
|
||||||
|
~description:"The version-specific fragment of the block header (unparsed)."
|
||||||
|
~query: RPC_query.empty
|
||||||
|
~output: bytes
|
||||||
|
RPC_path.(path / "protocol_data" / "raw")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Operation = struct
|
module Operation = struct
|
||||||
@ -611,6 +625,11 @@ module Make(Proto : PROTO)(Next_proto : PROTO) = struct
|
|||||||
fun ?(chain = `Main) ?(block = `Head 0) () ->
|
fun ?(chain = `Main) ?(block = `Head 0) () ->
|
||||||
f chain block () ()
|
f chain block () ()
|
||||||
|
|
||||||
|
let raw_header ctxt =
|
||||||
|
let f = make_call0 S.raw_header ctxt in
|
||||||
|
fun ?(chain = `Main) ?(block = `Head 0) () ->
|
||||||
|
f chain block () ()
|
||||||
|
|
||||||
let metadata ctxt =
|
let metadata ctxt =
|
||||||
let f = make_call0 S.metadata ctxt in
|
let f = make_call0 S.metadata ctxt in
|
||||||
fun ?(chain = `Main) ?(block = `Head 0) () ->
|
fun ?(chain = `Main) ?(block = `Head 0) () ->
|
||||||
@ -633,6 +652,10 @@ module Make(Proto : PROTO)(Next_proto : PROTO) = struct
|
|||||||
let f = make_call0 S.protocol_data ctxt in
|
let f = make_call0 S.protocol_data ctxt in
|
||||||
fun ?(chain = `Main) ?(block = `Head 0) () ->
|
fun ?(chain = `Main) ?(block = `Head 0) () ->
|
||||||
f chain block () ()
|
f chain block () ()
|
||||||
|
let raw_protocol_data ctxt =
|
||||||
|
let f = make_call0 S.raw_protocol_data ctxt in
|
||||||
|
fun ?(chain = `Main) ?(block = `Head 0) () ->
|
||||||
|
f chain block () ()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -119,6 +119,10 @@ module Make(Proto : PROTO)(Next_proto : PROTO) : sig
|
|||||||
#simple -> ?chain:chain -> ?block:block ->
|
#simple -> ?chain:chain -> ?block:block ->
|
||||||
unit -> Block_hash.t tzresult Lwt.t
|
unit -> Block_hash.t tzresult Lwt.t
|
||||||
|
|
||||||
|
val raw_header:
|
||||||
|
#simple -> ?chain:chain -> ?block:block ->
|
||||||
|
unit -> MBytes.t tzresult Lwt.t
|
||||||
|
|
||||||
val header:
|
val header:
|
||||||
#simple -> ?chain:chain -> ?block:block ->
|
#simple -> ?chain:chain -> ?block:block ->
|
||||||
unit -> block_header tzresult Lwt.t
|
unit -> block_header tzresult Lwt.t
|
||||||
@ -135,6 +139,9 @@ module Make(Proto : PROTO)(Next_proto : PROTO) : sig
|
|||||||
val protocol_data:
|
val protocol_data:
|
||||||
#simple -> ?chain:chain -> ?block:block ->
|
#simple -> ?chain:chain -> ?block:block ->
|
||||||
unit -> Proto.block_header_data tzresult Lwt.t
|
unit -> Proto.block_header_data tzresult Lwt.t
|
||||||
|
val raw_protocol_data:
|
||||||
|
#simple -> ?chain:chain -> ?block:block ->
|
||||||
|
unit -> MBytes.t tzresult Lwt.t
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -228,6 +235,11 @@ module Make(Proto : PROTO)(Next_proto : PROTO) : sig
|
|||||||
prefix, unit, unit,
|
prefix, unit, unit,
|
||||||
block_header) RPC_service.t
|
block_header) RPC_service.t
|
||||||
|
|
||||||
|
val raw_header:
|
||||||
|
([ `GET ], prefix,
|
||||||
|
prefix, unit, unit,
|
||||||
|
MBytes.t) RPC_service.t
|
||||||
|
|
||||||
val metadata:
|
val metadata:
|
||||||
([ `GET ], prefix,
|
([ `GET ], prefix,
|
||||||
prefix, unit, unit,
|
prefix, unit, unit,
|
||||||
@ -245,6 +257,11 @@ module Make(Proto : PROTO)(Next_proto : PROTO) : sig
|
|||||||
prefix, unit, unit,
|
prefix, unit, unit,
|
||||||
Proto.block_header_data) RPC_service.t
|
Proto.block_header_data) RPC_service.t
|
||||||
|
|
||||||
|
val raw_protocol_data:
|
||||||
|
([ `GET ], prefix,
|
||||||
|
prefix, unit, unit,
|
||||||
|
MBytes.t) RPC_service.t
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Operation : sig
|
module Operation : sig
|
||||||
|
Loading…
Reference in New Issue
Block a user