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 ;
|
||||
shell = header.shell ; protocol_data }
|
||||
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 () () ->
|
||||
return (State.Block.header block).shell
|
||||
end ;
|
||||
@ -77,6 +81,10 @@ let build_raw_rpc_directory
|
||||
Proto.block_header_data_encoding
|
||||
header.protocol_data)
|
||||
end ;
|
||||
register0 S.Header.raw_protocol_data begin fun block () () ->
|
||||
let header = State.Block.header block in
|
||||
return header.protocol_data
|
||||
end ;
|
||||
|
||||
(* block metadata *)
|
||||
|
||||
@ -197,7 +205,7 @@ let build_raw_rpc_directory
|
||||
|
||||
(* 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)
|
||||
end ;
|
||||
|
||||
|
@ -337,6 +337,13 @@ module Make(Proto : PROTO)(Next_proto : PROTO) = struct
|
||||
~output: block_header_encoding
|
||||
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 =
|
||||
RPC_service.get_service
|
||||
~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))
|
||||
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
|
||||
|
||||
module Operation = struct
|
||||
@ -611,6 +625,11 @@ module Make(Proto : PROTO)(Next_proto : PROTO) = struct
|
||||
fun ?(chain = `Main) ?(block = `Head 0) () ->
|
||||
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 f = make_call0 S.metadata ctxt in
|
||||
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
|
||||
fun ?(chain = `Main) ?(block = `Head 0) () ->
|
||||
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
|
||||
|
||||
|
@ -119,6 +119,10 @@ module Make(Proto : PROTO)(Next_proto : PROTO) : sig
|
||||
#simple -> ?chain:chain -> ?block:block ->
|
||||
unit -> Block_hash.t tzresult Lwt.t
|
||||
|
||||
val raw_header:
|
||||
#simple -> ?chain:chain -> ?block:block ->
|
||||
unit -> MBytes.t tzresult Lwt.t
|
||||
|
||||
val header:
|
||||
#simple -> ?chain:chain -> ?block:block ->
|
||||
unit -> block_header tzresult Lwt.t
|
||||
@ -135,6 +139,9 @@ module Make(Proto : PROTO)(Next_proto : PROTO) : sig
|
||||
val protocol_data:
|
||||
#simple -> ?chain:chain -> ?block:block ->
|
||||
unit -> Proto.block_header_data tzresult Lwt.t
|
||||
val raw_protocol_data:
|
||||
#simple -> ?chain:chain -> ?block:block ->
|
||||
unit -> MBytes.t tzresult Lwt.t
|
||||
|
||||
end
|
||||
|
||||
@ -228,6 +235,11 @@ module Make(Proto : PROTO)(Next_proto : PROTO) : sig
|
||||
prefix, unit, unit,
|
||||
block_header) RPC_service.t
|
||||
|
||||
val raw_header:
|
||||
([ `GET ], prefix,
|
||||
prefix, unit, unit,
|
||||
MBytes.t) RPC_service.t
|
||||
|
||||
val metadata:
|
||||
([ `GET ], prefix,
|
||||
prefix, unit, unit,
|
||||
@ -245,6 +257,11 @@ module Make(Proto : PROTO)(Next_proto : PROTO) : sig
|
||||
prefix, unit, unit,
|
||||
Proto.block_header_data) RPC_service.t
|
||||
|
||||
val raw_protocol_data:
|
||||
([ `GET ], prefix,
|
||||
prefix, unit, unit,
|
||||
MBytes.t) RPC_service.t
|
||||
|
||||
end
|
||||
|
||||
module Operation : sig
|
||||
|
Loading…
Reference in New Issue
Block a user