RPC: minor improvements in naming consistency
This commit is contained in:
parent
1b6ecbfc81
commit
495e887538
@ -15,9 +15,9 @@ module Services = Node_rpc_services
|
|||||||
let errors cctxt =
|
let errors cctxt =
|
||||||
call_service0 cctxt Services.Error.service ()
|
call_service0 cctxt Services.Error.service ()
|
||||||
|
|
||||||
let forge_block cctxt ?net ?level ?predecessor ?timestamp fitness ops header =
|
let forge_block cctxt ?net_id ?level ?predecessor ?timestamp fitness ops header =
|
||||||
call_service0 cctxt Services.forge_block
|
call_service0 cctxt Services.forge_block
|
||||||
(net, level, predecessor, timestamp, fitness, ops, header)
|
(net_id, level, predecessor, timestamp, fitness, ops, header)
|
||||||
|
|
||||||
let validate_block cctxt net block =
|
let validate_block cctxt net block =
|
||||||
call_err_service0 cctxt Services.validate_block (net, block)
|
call_err_service0 cctxt Services.validate_block (net, block)
|
||||||
@ -53,16 +53,16 @@ module Blocks = struct
|
|||||||
|
|
||||||
type block_info = Services.Blocks.block_info = {
|
type block_info = Services.Blocks.block_info = {
|
||||||
hash: Block_hash.t ;
|
hash: Block_hash.t ;
|
||||||
|
net_id: Net_id.t ;
|
||||||
level: Int32.t ;
|
level: Int32.t ;
|
||||||
predecessor: Block_hash.t ;
|
predecessor: Block_hash.t ;
|
||||||
fitness: MBytes.t list ;
|
|
||||||
timestamp: Time.t ;
|
timestamp: Time.t ;
|
||||||
protocol: Protocol_hash.t option ;
|
|
||||||
operations_hash: Operation_list_list_hash.t ;
|
operations_hash: Operation_list_list_hash.t ;
|
||||||
|
fitness: MBytes.t list ;
|
||||||
|
data: MBytes.t ;
|
||||||
operations: Operation_hash.t list list option ;
|
operations: Operation_hash.t list list option ;
|
||||||
data: MBytes.t option ;
|
protocol: Protocol_hash.t ;
|
||||||
net: Net_id.t ;
|
test_protocol: Protocol_hash.t ;
|
||||||
test_protocol: Protocol_hash.t option ;
|
|
||||||
test_network: (Net_id.t * Time.t) option ;
|
test_network: (Net_id.t * Time.t) option ;
|
||||||
}
|
}
|
||||||
type preapply_param = Services.Blocks.preapply_param = {
|
type preapply_param = Services.Blocks.preapply_param = {
|
||||||
@ -104,19 +104,19 @@ module Blocks = struct
|
|||||||
{ operations ; sort ; timestamp }
|
{ operations ; sort ; timestamp }
|
||||||
let pending_operations cctxt block =
|
let pending_operations cctxt block =
|
||||||
call_service1 cctxt Services.Blocks.pending_operations block ()
|
call_service1 cctxt Services.Blocks.pending_operations block ()
|
||||||
let info cctxt ?(operations = true) ?(data = true) h =
|
let info cctxt ?(include_ops = true) h =
|
||||||
call_service1 cctxt Services.Blocks.info h (operations, data)
|
call_service1 cctxt Services.Blocks.info h include_ops
|
||||||
let complete cctxt block prefix =
|
let complete cctxt block prefix =
|
||||||
call_service2 cctxt Services.Blocks.complete block prefix ()
|
call_service2 cctxt Services.Blocks.complete block prefix ()
|
||||||
let list cctxt ?(operations = false) ?(data = false)
|
let list cctxt ?(include_ops = false)
|
||||||
?length ?heads ?delay ?min_date ?min_heads () =
|
?length ?heads ?delay ?min_date ?min_heads () =
|
||||||
call_service0 cctxt Services.Blocks.list
|
call_service0 cctxt Services.Blocks.list
|
||||||
{ operations ; data ; length ; heads ; monitor = Some false ; delay ;
|
{ include_ops ; length ; heads ; monitor = Some false ; delay ;
|
||||||
min_date ; min_heads }
|
min_date ; min_heads }
|
||||||
let monitor cctxt ?(operations = false) ?(data = false)
|
let monitor cctxt ?(include_ops = false)
|
||||||
?length ?heads ?delay ?min_date ?min_heads () =
|
?length ?heads ?delay ?min_date ?min_heads () =
|
||||||
call_streamed_service0 cctxt Services.Blocks.list
|
call_streamed_service0 cctxt Services.Blocks.list
|
||||||
{ operations ; data ; length ; heads ; monitor = Some true ; delay ;
|
{ include_ops ; length ; heads ; monitor = Some true ; delay ;
|
||||||
min_date ; min_heads }
|
min_date ; min_heads }
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -14,7 +14,7 @@ val errors:
|
|||||||
|
|
||||||
val forge_block:
|
val forge_block:
|
||||||
config ->
|
config ->
|
||||||
?net:Net_id.t ->
|
?net_id:Net_id.t ->
|
||||||
?level:Int32.t ->
|
?level:Int32.t ->
|
||||||
?predecessor:Block_hash.t ->
|
?predecessor:Block_hash.t ->
|
||||||
?timestamp:Time.t ->
|
?timestamp:Time.t ->
|
||||||
@ -94,7 +94,7 @@ module Blocks : sig
|
|||||||
block -> Protocol_hash.t tzresult Lwt.t
|
block -> Protocol_hash.t tzresult Lwt.t
|
||||||
val test_protocol:
|
val test_protocol:
|
||||||
config ->
|
config ->
|
||||||
block -> Protocol_hash.t option tzresult Lwt.t
|
block -> Protocol_hash.t tzresult Lwt.t
|
||||||
val test_network:
|
val test_network:
|
||||||
config ->
|
config ->
|
||||||
block -> (Net_id.t * Time.t) option tzresult Lwt.t
|
block -> (Net_id.t * Time.t) option tzresult Lwt.t
|
||||||
@ -106,32 +106,32 @@ module Blocks : sig
|
|||||||
|
|
||||||
type block_info = {
|
type block_info = {
|
||||||
hash: Block_hash.t ;
|
hash: Block_hash.t ;
|
||||||
|
net_id: Net_id.t ;
|
||||||
level: Int32.t ;
|
level: Int32.t ;
|
||||||
predecessor: Block_hash.t ;
|
predecessor: Block_hash.t ;
|
||||||
fitness: MBytes.t list ;
|
|
||||||
timestamp: Time.t ;
|
timestamp: Time.t ;
|
||||||
protocol: Protocol_hash.t option ;
|
|
||||||
operations_hash: Operation_list_list_hash.t ;
|
operations_hash: Operation_list_list_hash.t ;
|
||||||
|
fitness: MBytes.t list ;
|
||||||
|
data: MBytes.t ;
|
||||||
operations: Operation_hash.t list list option ;
|
operations: Operation_hash.t list list option ;
|
||||||
data: MBytes.t option ;
|
protocol: Protocol_hash.t ;
|
||||||
net: Net_id.t ;
|
test_protocol: Protocol_hash.t ;
|
||||||
test_protocol: Protocol_hash.t option ;
|
|
||||||
test_network: (Net_id.t * Time.t) option ;
|
test_network: (Net_id.t * Time.t) option ;
|
||||||
}
|
}
|
||||||
|
|
||||||
val info:
|
val info:
|
||||||
config ->
|
config ->
|
||||||
?operations:bool -> ?data:bool -> block -> block_info tzresult Lwt.t
|
?include_ops:bool -> block -> block_info tzresult Lwt.t
|
||||||
|
|
||||||
val list:
|
val list:
|
||||||
config ->
|
config ->
|
||||||
?operations:bool -> ?data:bool -> ?length:int -> ?heads:Block_hash.t list ->
|
?include_ops:bool -> ?length:int -> ?heads:Block_hash.t list ->
|
||||||
?delay:int -> ?min_date:Time.t -> ?min_heads:int ->
|
?delay:int -> ?min_date:Time.t -> ?min_heads:int ->
|
||||||
unit -> block_info list list tzresult Lwt.t
|
unit -> block_info list list tzresult Lwt.t
|
||||||
|
|
||||||
val monitor:
|
val monitor:
|
||||||
config ->
|
config ->
|
||||||
?operations:bool -> ?data:bool -> ?length:int -> ?heads:Block_hash.t list ->
|
?include_ops:bool -> ?length:int -> ?heads:Block_hash.t list ->
|
||||||
?delay:int -> ?min_date:Time.t -> ?min_heads:int ->
|
?delay:int -> ?min_date:Time.t -> ?min_heads:int ->
|
||||||
unit -> block_info list list tzresult Lwt_stream.t tzresult Lwt.t
|
unit -> block_info list list tzresult Lwt_stream.t tzresult Lwt.t
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ type block_info = {
|
|||||||
predecessor: Block_hash.t ;
|
predecessor: Block_hash.t ;
|
||||||
fitness: MBytes.t list ;
|
fitness: MBytes.t list ;
|
||||||
timestamp: Time.t ;
|
timestamp: Time.t ;
|
||||||
protocol: Protocol_hash.t option ;
|
protocol: Protocol_hash.t ;
|
||||||
level: Level.t ;
|
level: Level.t ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,7 +21,8 @@ let convert_block_info cctxt
|
|||||||
: Client_node_rpcs.Blocks.block_info ) =
|
: Client_node_rpcs.Blocks.block_info ) =
|
||||||
Client_proto_rpcs.Context.level cctxt (`Hash hash) >>= function
|
Client_proto_rpcs.Context.level cctxt (`Hash hash) >>= function
|
||||||
| Ok level ->
|
| Ok level ->
|
||||||
Lwt.return (Some { hash ; predecessor ; fitness ; timestamp ; protocol ; level })
|
Lwt.return
|
||||||
|
(Some { hash ; predecessor ; fitness ; timestamp ; protocol ; level })
|
||||||
| Error _ ->
|
| Error _ ->
|
||||||
(* TODO log error *)
|
(* TODO log error *)
|
||||||
Lwt.return_none
|
Lwt.return_none
|
||||||
@ -32,8 +33,8 @@ let convert_block_info_err cctxt
|
|||||||
Client_proto_rpcs.Context.level cctxt (`Hash hash) >>=? fun level ->
|
Client_proto_rpcs.Context.level cctxt (`Hash hash) >>=? fun level ->
|
||||||
return { hash ; predecessor ; fitness ; timestamp ; protocol ; level }
|
return { hash ; predecessor ; fitness ; timestamp ; protocol ; level }
|
||||||
|
|
||||||
let info cctxt ?operations block =
|
let info cctxt ?include_ops block =
|
||||||
Client_node_rpcs.Blocks.info cctxt ?operations block >>=? fun block ->
|
Client_node_rpcs.Blocks.info cctxt ?include_ops block >>=? fun block ->
|
||||||
convert_block_info_err cctxt block
|
convert_block_info_err cctxt block
|
||||||
|
|
||||||
let compare (bi1 : block_info) (bi2 : block_info) =
|
let compare (bi1 : block_info) (bi2 : block_info) =
|
||||||
@ -54,10 +55,10 @@ let sort_blocks cctxt ?(compare = compare) blocks =
|
|||||||
List.sort compare blocks
|
List.sort compare blocks
|
||||||
|
|
||||||
let monitor cctxt
|
let monitor cctxt
|
||||||
?operations ?length ?heads ?delay
|
?include_ops ?length ?heads ?delay
|
||||||
?min_date ?min_heads ?compare () =
|
?min_date ?min_heads ?compare () =
|
||||||
Client_node_rpcs.Blocks.monitor cctxt
|
Client_node_rpcs.Blocks.monitor cctxt
|
||||||
?operations ?length ?heads ?delay ?min_date ?min_heads
|
?include_ops ?length ?heads ?delay ?min_date ?min_heads
|
||||||
() >>=? fun block_stream ->
|
() >>=? fun block_stream ->
|
||||||
let convert blocks =
|
let convert blocks =
|
||||||
Lwt.return blocks >>=? fun blocks ->
|
Lwt.return blocks >>=? fun blocks ->
|
||||||
|
@ -12,20 +12,20 @@ type block_info = {
|
|||||||
predecessor: Block_hash.t ;
|
predecessor: Block_hash.t ;
|
||||||
fitness: MBytes.t list ;
|
fitness: MBytes.t list ;
|
||||||
timestamp: Time.t ;
|
timestamp: Time.t ;
|
||||||
protocol: Protocol_hash.t option ;
|
protocol: Protocol_hash.t ;
|
||||||
level: Level.t ;
|
level: Level.t ;
|
||||||
}
|
}
|
||||||
|
|
||||||
val info:
|
val info:
|
||||||
Client_rpcs.config ->
|
Client_rpcs.config ->
|
||||||
?operations:bool -> Client_node_rpcs.Blocks.block -> block_info tzresult Lwt.t
|
?include_ops:bool -> Client_node_rpcs.Blocks.block -> block_info tzresult Lwt.t
|
||||||
|
|
||||||
val compare:
|
val compare:
|
||||||
block_info -> block_info -> int
|
block_info -> block_info -> int
|
||||||
|
|
||||||
val monitor:
|
val monitor:
|
||||||
Client_rpcs.config ->
|
Client_rpcs.config ->
|
||||||
?operations:bool -> ?length:int -> ?heads:Block_hash.t list ->
|
?include_ops:bool -> ?length:int -> ?heads:Block_hash.t list ->
|
||||||
?delay:int -> ?min_date:Time.t -> ?min_heads:int ->
|
?delay:int -> ?min_date:Time.t -> ?min_heads:int ->
|
||||||
?compare:(block_info -> block_info -> int) ->
|
?compare:(block_info -> block_info -> int) ->
|
||||||
unit -> block_info list tzresult Lwt_stream.t tzresult Lwt.t
|
unit -> block_info list tzresult Lwt_stream.t tzresult Lwt.t
|
||||||
|
@ -42,26 +42,26 @@ let rec compute_stamp
|
|||||||
let inject_block cctxt block
|
let inject_block cctxt block
|
||||||
?force
|
?force
|
||||||
~priority ~timestamp ~fitness ~seed_nonce
|
~priority ~timestamp ~fitness ~seed_nonce
|
||||||
~src_sk operation_list =
|
~src_sk operations =
|
||||||
let block = match block with `Prevalidation -> `Head 0 | block -> block in
|
let block = match block with `Prevalidation -> `Head 0 | block -> block in
|
||||||
Client_node_rpcs.Blocks.info cctxt block >>=? fun bi ->
|
Client_node_rpcs.Blocks.info cctxt block >>=? fun bi ->
|
||||||
let seed_nonce_hash = Nonce.hash seed_nonce in
|
let seed_nonce_hash = Nonce.hash seed_nonce in
|
||||||
Client_proto_rpcs.Context.next_level cctxt block >>=? fun level ->
|
Client_proto_rpcs.Context.next_level cctxt block >>=? fun level ->
|
||||||
let operations =
|
let operations_hash =
|
||||||
Operation_list_list_hash.compute
|
Operation_list_list_hash.compute
|
||||||
(List.map Operation_list_hash.compute operation_list) in
|
(List.map Operation_list_hash.compute operations) in
|
||||||
let shell =
|
let shell =
|
||||||
{ Store.Block_header.net_id = bi.net ; level = bi.level ;
|
{ Store.Block_header.net_id = bi.net_id ; level = bi.level ;
|
||||||
predecessor = bi.hash ; timestamp ; fitness ; operations } in
|
predecessor = bi.hash ; timestamp ; fitness ; operations_hash } in
|
||||||
compute_stamp cctxt block
|
compute_stamp cctxt block
|
||||||
src_sk shell priority seed_nonce_hash >>=? fun proof_of_work_nonce ->
|
src_sk shell priority seed_nonce_hash >>=? fun proof_of_work_nonce ->
|
||||||
Client_proto_rpcs.Helpers.Forge.block cctxt
|
Client_proto_rpcs.Helpers.Forge.block cctxt
|
||||||
block
|
block
|
||||||
~net:bi.net
|
~net:bi.net_id
|
||||||
~predecessor:bi.hash
|
~predecessor:bi.hash
|
||||||
~timestamp
|
~timestamp
|
||||||
~fitness
|
~fitness
|
||||||
~operations
|
~operations_hash
|
||||||
~level:level.level
|
~level:level.level
|
||||||
~priority:priority
|
~priority:priority
|
||||||
~seed_nonce_hash
|
~seed_nonce_hash
|
||||||
@ -69,7 +69,7 @@ let inject_block cctxt block
|
|||||||
() >>=? fun unsigned_header ->
|
() >>=? fun unsigned_header ->
|
||||||
let signed_header = Ed25519.Signature.append src_sk unsigned_header in
|
let signed_header = Ed25519.Signature.append src_sk unsigned_header in
|
||||||
Client_node_rpcs.inject_block cctxt
|
Client_node_rpcs.inject_block cctxt
|
||||||
?force signed_header operation_list >>=? fun block_hash ->
|
?force signed_header operations >>=? fun block_hash ->
|
||||||
return block_hash
|
return block_hash
|
||||||
|
|
||||||
let forge_block cctxt block
|
let forge_block cctxt block
|
||||||
|
@ -245,10 +245,10 @@ module Helpers = struct
|
|||||||
operations cctxt block ~net [Faucet { id ; nonce }]
|
operations cctxt block ~net [Faucet { id ; nonce }]
|
||||||
end
|
end
|
||||||
let block cctxt
|
let block cctxt
|
||||||
block ~net ~predecessor ~timestamp ~fitness ~operations
|
block ~net ~predecessor ~timestamp ~fitness ~operations_hash
|
||||||
~level ~priority ~seed_nonce_hash ~proof_of_work_nonce () =
|
~level ~priority ~seed_nonce_hash ~proof_of_work_nonce () =
|
||||||
call_error_service1 cctxt Services.Helpers.Forge.block block
|
call_error_service1 cctxt Services.Helpers.Forge.block block
|
||||||
(net, predecessor, timestamp, fitness, operations,
|
(net, predecessor, timestamp, fitness, operations_hash,
|
||||||
level, priority, seed_nonce_hash, proof_of_work_nonce)
|
level, priority, seed_nonce_hash, proof_of_work_nonce)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ module Helpers : sig
|
|||||||
predecessor:Block_hash.t ->
|
predecessor:Block_hash.t ->
|
||||||
timestamp:Time.t ->
|
timestamp:Time.t ->
|
||||||
fitness:Fitness.t ->
|
fitness:Fitness.t ->
|
||||||
operations:Operation_list_list_hash.t ->
|
operations_hash:Operation_list_list_hash.t ->
|
||||||
level:Raw_level.t ->
|
level:Raw_level.t ->
|
||||||
priority:int ->
|
priority:int ->
|
||||||
seed_nonce_hash:Nonce_hash.t ->
|
seed_nonce_hash:Nonce_hash.t ->
|
||||||
|
@ -51,7 +51,7 @@ let mine cctxt =
|
|||||||
(cctxt.message "Cannot parse fitness: %a" Fitness.pp bi.fitness);
|
(cctxt.message "Cannot parse fitness: %a" Fitness.pp bi.fitness);
|
||||||
exit 2 in
|
exit 2 in
|
||||||
Client_node_rpcs.forge_block cctxt.rpc_config
|
Client_node_rpcs.forge_block cctxt.rpc_config
|
||||||
~net:bi.net ~predecessor:bi.hash
|
~net_id:bi.net_id ~predecessor:bi.hash
|
||||||
fitness Operation_list_list_hash.empty (MBytes.create 0) >>=? fun bytes ->
|
fitness Operation_list_list_hash.empty (MBytes.create 0) >>=? fun bytes ->
|
||||||
Client_node_rpcs.inject_block cctxt.rpc_config bytes [] >>=? fun hash ->
|
Client_node_rpcs.inject_block cctxt.rpc_config bytes [] >>=? fun hash ->
|
||||||
cctxt.answer "Injected %a" Block_hash.pp_short hash >>= fun () ->
|
cctxt.answer "Injected %a" Block_hash.pp_short hash >>= fun () ->
|
||||||
|
@ -33,7 +33,8 @@ let forge_block
|
|||||||
|
|
||||||
let mine rpc_config ?timestamp block command fitness seckey =
|
let mine rpc_config ?timestamp block command fitness seckey =
|
||||||
Client_blocks.get_block_info rpc_config block >>=? fun bi ->
|
Client_blocks.get_block_info rpc_config block >>=? fun bi ->
|
||||||
forge_block rpc_config ?timestamp block bi.net command fitness >>=? fun blk ->
|
forge_block
|
||||||
|
rpc_config ?timestamp block bi.net_id command fitness >>=? fun blk ->
|
||||||
let signed_blk = Environment.Ed25519.Signature.append seckey blk in
|
let signed_blk = Environment.Ed25519.Signature.append seckey blk in
|
||||||
Client_node_rpcs.inject_block rpc_config signed_blk [[]]
|
Client_node_rpcs.inject_block rpc_config signed_blk [[]]
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ module Block_header = struct
|
|||||||
level: Int32.t ;
|
level: Int32.t ;
|
||||||
predecessor: Block_hash.t ;
|
predecessor: Block_hash.t ;
|
||||||
timestamp: Time.t ;
|
timestamp: Time.t ;
|
||||||
operations: Operation_list_list_hash.t ;
|
operations_hash: Operation_list_list_hash.t ;
|
||||||
fitness: MBytes.t list ;
|
fitness: MBytes.t list ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,17 +269,19 @@ module Block_header = struct
|
|||||||
let open Data_encoding in
|
let open Data_encoding in
|
||||||
conv
|
conv
|
||||||
(fun { net_id ; level ; predecessor ;
|
(fun { net_id ; level ; predecessor ;
|
||||||
timestamp ; operations ; fitness } ->
|
timestamp ; operations_hash ; fitness } ->
|
||||||
(net_id, level, predecessor, timestamp, operations, fitness))
|
(net_id, level, predecessor,
|
||||||
(fun (net_id, level, predecessor, timestamp, operations, fitness) ->
|
timestamp, operations_hash, fitness))
|
||||||
|
(fun (net_id, level, predecessor,
|
||||||
|
timestamp, operations_hash, fitness) ->
|
||||||
{ net_id ; level ; predecessor ;
|
{ net_id ; level ; predecessor ;
|
||||||
timestamp ; operations ; fitness })
|
timestamp ; operations_hash ; fitness })
|
||||||
(obj6
|
(obj6
|
||||||
(req "net_id" Net_id.encoding)
|
(req "net_id" Net_id.encoding)
|
||||||
(req "level" int32)
|
(req "level" int32)
|
||||||
(req "predecessor" Block_hash.encoding)
|
(req "predecessor" Block_hash.encoding)
|
||||||
(req "timestamp" Time.encoding)
|
(req "timestamp" Time.encoding)
|
||||||
(req "operations" Operation_list_list_hash.encoding)
|
(req "operations_hash" Operation_list_list_hash.encoding)
|
||||||
(req "fitness" Fitness.encoding))
|
(req "fitness" Fitness.encoding))
|
||||||
|
|
||||||
module Encoding = struct
|
module Encoding = struct
|
||||||
@ -311,7 +313,7 @@ module Block_header = struct
|
|||||||
Block_hash.compare b1.shell.predecessor b2.shell.predecessor >> fun () ->
|
Block_hash.compare b1.shell.predecessor b2.shell.predecessor >> fun () ->
|
||||||
compare b1.proto b2.proto >> fun () ->
|
compare b1.proto b2.proto >> fun () ->
|
||||||
Operation_list_list_hash.compare
|
Operation_list_list_hash.compare
|
||||||
b1.shell.operations b2.shell.operations >> fun () ->
|
b1.shell.operations_hash b2.shell.operations_hash >> fun () ->
|
||||||
Time.compare b1.shell.timestamp b2.shell.timestamp >> fun () ->
|
Time.compare b1.shell.timestamp b2.shell.timestamp >> fun () ->
|
||||||
list compare b1.shell.fitness b2.shell.fitness
|
list compare b1.shell.fitness b2.shell.fitness
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ module Block_header : sig
|
|||||||
level: Int32.t ;
|
level: Int32.t ;
|
||||||
predecessor: Block_hash.t ;
|
predecessor: Block_hash.t ;
|
||||||
timestamp: Time.t ;
|
timestamp: Time.t ;
|
||||||
operations: Operation_list_list_hash.t ;
|
operations_hash: Operation_list_list_hash.t ;
|
||||||
fitness: MBytes.t list ;
|
fitness: MBytes.t list ;
|
||||||
}
|
}
|
||||||
val shell_header_encoding: shell_header Data_encoding.t
|
val shell_header_encoding: shell_header Data_encoding.t
|
||||||
|
@ -348,7 +348,7 @@ module P2p_reader = struct
|
|||||||
| None -> Lwt.return_unit
|
| None -> Lwt.return_unit
|
||||||
| Some bh ->
|
| Some bh ->
|
||||||
if Operation_list_list_hash.compare
|
if Operation_list_list_hash.compare
|
||||||
found_hash bh.shell.operations <> 0 then
|
found_hash bh.shell.operations_hash <> 0 then
|
||||||
Lwt.return_unit
|
Lwt.return_unit
|
||||||
else
|
else
|
||||||
Raw_operation_list.Table.notify
|
Raw_operation_list.Table.notify
|
||||||
@ -624,7 +624,7 @@ let inject_block t bytes operations =
|
|||||||
(List.map Operation_list_hash.compute operations) in
|
(List.map Operation_list_hash.compute operations) in
|
||||||
fail_unless
|
fail_unless
|
||||||
(Operation_list_list_hash.compare
|
(Operation_list_list_hash.compare
|
||||||
computed_hash block.shell.operations = 0)
|
computed_hash block.shell.operations_hash = 0)
|
||||||
(Exn (Failure "Incoherent operation list")) >>=? fun () ->
|
(Exn (Failure "Incoherent operation list")) >>=? fun () ->
|
||||||
Raw_block_header.Table.inject
|
Raw_block_header.Table.inject
|
||||||
net_db.block_header_db.table hash block >>= function
|
net_db.block_header_db.table hash block >>= function
|
||||||
|
@ -138,31 +138,31 @@ module RPC = struct
|
|||||||
type block = Node_rpc_services.Blocks.block
|
type block = Node_rpc_services.Blocks.block
|
||||||
type block_info = Node_rpc_services.Blocks.block_info = {
|
type block_info = Node_rpc_services.Blocks.block_info = {
|
||||||
hash: Block_hash.t ;
|
hash: Block_hash.t ;
|
||||||
|
net_id: Net_id.t ;
|
||||||
level: Int32.t ;
|
level: Int32.t ;
|
||||||
predecessor: Block_hash.t ;
|
predecessor: Block_hash.t ;
|
||||||
fitness: MBytes.t list ;
|
|
||||||
timestamp: Time.t ;
|
timestamp: Time.t ;
|
||||||
protocol: Protocol_hash.t option ;
|
|
||||||
operations_hash: Operation_list_list_hash.t ;
|
operations_hash: Operation_list_list_hash.t ;
|
||||||
|
fitness: MBytes.t list ;
|
||||||
|
data: MBytes.t ;
|
||||||
operations: Operation_hash.t list list option ;
|
operations: Operation_hash.t list list option ;
|
||||||
data: MBytes.t option ;
|
protocol: Protocol_hash.t ;
|
||||||
net: Net_id.t ;
|
test_protocol: Protocol_hash.t ;
|
||||||
test_protocol: Protocol_hash.t option ;
|
|
||||||
test_network: (Net_id.t * Time.t) option ;
|
test_network: (Net_id.t * Time.t) option ;
|
||||||
}
|
}
|
||||||
|
|
||||||
let convert (block: State.Valid_block.t) = {
|
let convert (block: State.Valid_block.t) = {
|
||||||
hash = block.hash ;
|
hash = block.hash ;
|
||||||
|
net_id = block.net_id ;
|
||||||
level = block.level ;
|
level = block.level ;
|
||||||
predecessor = block.predecessor ;
|
predecessor = block.predecessor ;
|
||||||
fitness = block.fitness ;
|
|
||||||
timestamp = block.timestamp ;
|
timestamp = block.timestamp ;
|
||||||
protocol = Some block.protocol_hash ;
|
|
||||||
operations_hash = block.operations_hash ;
|
operations_hash = block.operations_hash ;
|
||||||
|
fitness = block.fitness ;
|
||||||
|
data = block.proto_header ;
|
||||||
operations = Some block.operations ;
|
operations = Some block.operations ;
|
||||||
data = Some block.proto_header ;
|
protocol = block.protocol_hash ;
|
||||||
net = block.net_id ;
|
test_protocol = block.test_protocol_hash ;
|
||||||
test_protocol = Some block.test_protocol_hash ;
|
|
||||||
test_network = block.test_network ;
|
test_network = block.test_network ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,6 +268,13 @@ module RPC = struct
|
|||||||
| Error _ -> Lwt.fail Not_found
|
| Error _ -> Lwt.fail Not_found
|
||||||
| Ok { context ; fitness } ->
|
| Ok { context ; fitness } ->
|
||||||
Context.get_protocol context >>= fun protocol ->
|
Context.get_protocol context >>= fun protocol ->
|
||||||
|
Context.get_test_protocol context >>= fun test_protocol ->
|
||||||
|
Context.get_test_network context >>= fun test_network ->
|
||||||
|
Context.get_test_network_expiration context >>= fun test_network_expiration ->
|
||||||
|
let test_network =
|
||||||
|
match test_network, test_network_expiration with
|
||||||
|
| Some n, Some t -> Some (n, t)
|
||||||
|
| _, None | None, _ -> None in
|
||||||
let operations =
|
let operations =
|
||||||
let pv_result, _ = Prevalidator.operations pv in
|
let pv_result, _ = Prevalidator.operations pv in
|
||||||
[ pv_result.applied ] in
|
[ pv_result.applied ] in
|
||||||
@ -277,15 +284,15 @@ module RPC = struct
|
|||||||
predecessor = head.hash ;
|
predecessor = head.hash ;
|
||||||
fitness ;
|
fitness ;
|
||||||
timestamp = Prevalidator.timestamp pv ;
|
timestamp = Prevalidator.timestamp pv ;
|
||||||
protocol = Some protocol ;
|
protocol ;
|
||||||
operations_hash =
|
operations_hash =
|
||||||
Operation_list_list_hash.compute
|
Operation_list_list_hash.compute
|
||||||
(List.map Operation_list_hash.compute operations) ;
|
(List.map Operation_list_hash.compute operations) ;
|
||||||
operations = Some operations ;
|
operations = Some operations ;
|
||||||
data = None ;
|
data = MBytes.of_string "" ;
|
||||||
net = head.net_id ;
|
net_id = head.net_id ;
|
||||||
test_protocol = None ;
|
test_protocol ;
|
||||||
test_network = None ;
|
test_network ;
|
||||||
}
|
}
|
||||||
|
|
||||||
let rpc_context block : Updater.rpc_context =
|
let rpc_context block : Updater.rpc_context =
|
||||||
|
@ -12,9 +12,8 @@ open Logging.RPC
|
|||||||
|
|
||||||
module Services = Node_rpc_services
|
module Services = Node_rpc_services
|
||||||
|
|
||||||
let filter_bi (operations, data) (bi: Services.Blocks.block_info) =
|
let filter_bi operations (bi: Services.Blocks.block_info) =
|
||||||
let bi = if operations then bi else { bi with operations = None } in
|
let bi = if operations then bi else { bi with operations = None } in
|
||||||
let bi = if data then bi else { bi with data = None } in
|
|
||||||
bi
|
bi
|
||||||
|
|
||||||
let register_bi_dir node dir =
|
let register_bi_dir node dir =
|
||||||
@ -34,7 +33,7 @@ let register_bi_dir node dir =
|
|||||||
let dir =
|
let dir =
|
||||||
let implementation b () =
|
let implementation b () =
|
||||||
Node.RPC.block_info node b >>= fun bi ->
|
Node.RPC.block_info node b >>= fun bi ->
|
||||||
RPC.Answer.return bi.net in
|
RPC.Answer.return bi.net_id in
|
||||||
RPC.register1 dir
|
RPC.register1 dir
|
||||||
Services.Blocks.net implementation in
|
Services.Blocks.net implementation in
|
||||||
let dir =
|
let dir =
|
||||||
@ -71,9 +70,7 @@ let register_bi_dir node dir =
|
|||||||
let dir =
|
let dir =
|
||||||
let implementation b () =
|
let implementation b () =
|
||||||
Node.RPC.block_info node b >>= fun bi ->
|
Node.RPC.block_info node b >>= fun bi ->
|
||||||
match bi.protocol with
|
RPC.Answer.return bi.protocol in
|
||||||
| None -> raise Not_found
|
|
||||||
| Some p -> RPC.Answer.return p in
|
|
||||||
RPC.register1 dir
|
RPC.register1 dir
|
||||||
Services.Blocks.protocol implementation in
|
Services.Blocks.protocol implementation in
|
||||||
let dir =
|
let dir =
|
||||||
@ -220,11 +217,10 @@ let create_delayed_stream
|
|||||||
|
|
||||||
let list_blocks
|
let list_blocks
|
||||||
node
|
node
|
||||||
{ Services.Blocks.operations ; data ; length ; heads ; monitor ; delay ;
|
{ Services.Blocks.include_ops ; length ; heads ; monitor ; delay ;
|
||||||
min_date; min_heads} =
|
min_date; min_heads} =
|
||||||
let len = match length with None -> 1 | Some x -> x in
|
let len = match length with None -> 1 | Some x -> x in
|
||||||
let monitor = match monitor with None -> false | Some x -> x in
|
let monitor = match monitor with None -> false | Some x -> x in
|
||||||
let include_ops = (operations, data) in
|
|
||||||
let time =
|
let time =
|
||||||
match delay with
|
match delay with
|
||||||
| None -> None
|
| None -> None
|
||||||
@ -410,16 +406,17 @@ let build_rpc_directory node =
|
|||||||
let dir =
|
let dir =
|
||||||
RPC.register1 dir Services.Protocols.contents (get_protocols node) in
|
RPC.register1 dir Services.Protocols.contents (get_protocols node) in
|
||||||
let dir =
|
let dir =
|
||||||
let implementation (net_id, level, pred, time, fitness, operations, header) =
|
let implementation
|
||||||
|
(net_id, level, pred, time, fitness, operations_hash, header) =
|
||||||
Node.RPC.block_info node (`Head 0) >>= fun bi ->
|
Node.RPC.block_info node (`Head 0) >>= fun bi ->
|
||||||
let timestamp = Utils.unopt ~default:(Time.now ()) time in
|
let timestamp = Utils.unopt ~default:(Time.now ()) time in
|
||||||
let net_id = Utils.unopt ~default:bi.net net_id in
|
let net_id = Utils.unopt ~default:bi.net_id net_id in
|
||||||
let predecessor = Utils.unopt ~default:bi.hash pred in
|
let predecessor = Utils.unopt ~default:bi.hash pred in
|
||||||
let level = Utils.unopt ~default:(Int32.succ bi.level) level in
|
let level = Utils.unopt ~default:(Int32.succ bi.level) level in
|
||||||
let res =
|
let res =
|
||||||
Data_encoding.Binary.to_bytes Store.Block_header.encoding {
|
Data_encoding.Binary.to_bytes Store.Block_header.encoding {
|
||||||
shell = { net_id ; predecessor ; level ;
|
shell = { net_id ; predecessor ; level ;
|
||||||
timestamp ; fitness ; operations } ;
|
timestamp ; fitness ; operations_hash } ;
|
||||||
proto = header ;
|
proto = header ;
|
||||||
} in
|
} in
|
||||||
RPC.Answer.return res in
|
RPC.Answer.return res in
|
||||||
|
@ -57,48 +57,46 @@ module Blocks = struct
|
|||||||
|
|
||||||
type block_info = {
|
type block_info = {
|
||||||
hash: Block_hash.t ;
|
hash: Block_hash.t ;
|
||||||
|
net_id: Net_id.t ;
|
||||||
level: Int32.t ;
|
level: Int32.t ;
|
||||||
predecessor: Block_hash.t ;
|
predecessor: Block_hash.t ;
|
||||||
fitness: MBytes.t list ;
|
|
||||||
timestamp: Time.t ;
|
timestamp: Time.t ;
|
||||||
protocol: Protocol_hash.t option ;
|
|
||||||
operations_hash: Operation_list_list_hash.t ;
|
operations_hash: Operation_list_list_hash.t ;
|
||||||
|
fitness: MBytes.t list ;
|
||||||
|
data: MBytes.t ;
|
||||||
operations: Operation_hash.t list list option ;
|
operations: Operation_hash.t list list option ;
|
||||||
data: MBytes.t option ;
|
protocol: Protocol_hash.t ;
|
||||||
net: Net_id.t ;
|
test_protocol: Protocol_hash.t ;
|
||||||
test_protocol: Protocol_hash.t option ;
|
|
||||||
test_network: (Net_id.t * Time.t) option ;
|
test_network: (Net_id.t * Time.t) option ;
|
||||||
}
|
}
|
||||||
|
|
||||||
let block_info_encoding =
|
let block_info_encoding =
|
||||||
conv
|
conv
|
||||||
(fun { hash ; level ; predecessor ; fitness ; timestamp ; protocol ;
|
(fun { hash ; net_id ; level ; predecessor ;
|
||||||
operations_hash ; operations ; data ; net ;
|
fitness ; timestamp ; protocol ; operations_hash ; data ;
|
||||||
test_protocol ; test_network } ->
|
operations ; test_protocol ; test_network } ->
|
||||||
((hash, level, predecessor, fitness, timestamp, protocol),
|
({ Store.Block_header.shell =
|
||||||
(operations_hash, operations, data,
|
{ net_id ; level ; predecessor ;
|
||||||
net, test_protocol, test_network)))
|
timestamp ; operations_hash ; fitness } ;
|
||||||
(fun ((hash, level, predecessor, fitness, timestamp, protocol),
|
proto = data },
|
||||||
(operations_hash, operations, data,
|
(hash, operations, protocol, test_protocol, test_network)))
|
||||||
net, test_protocol, test_network)) ->
|
(fun ({ Store.Block_header.shell =
|
||||||
{ hash ; level ; predecessor ; fitness ; timestamp ; protocol ;
|
{ net_id ; level ; predecessor ;
|
||||||
operations_hash ; operations ; data ; net ;
|
timestamp ; operations_hash ; fitness } ;
|
||||||
test_protocol ; test_network })
|
proto = data },
|
||||||
(merge_objs
|
(hash, operations, protocol, test_protocol, test_network)) ->
|
||||||
(obj6
|
{ hash ; net_id ; level ; predecessor ;
|
||||||
(req "hash" Block_hash.encoding)
|
fitness ; timestamp ; protocol ; operations_hash ; data ;
|
||||||
(req "level" int32)
|
operations ; test_protocol ; test_network })
|
||||||
(req "predecessor" Block_hash.encoding)
|
(dynamic_size
|
||||||
(req "fitness" Fitness.encoding)
|
(merge_objs
|
||||||
(req "timestamp" Time.encoding)
|
Store.Block_header.encoding
|
||||||
(opt "protocol" Protocol_hash.encoding))
|
(obj5
|
||||||
(obj6
|
(req "hash" Block_hash.encoding)
|
||||||
(req "operations_hash" Operation_list_list_hash.encoding)
|
(opt "operations" (list (list Operation_hash.encoding)))
|
||||||
(opt "operations" (list (list Operation_hash.encoding)))
|
(req "protocol" Protocol_hash.encoding)
|
||||||
(opt "data" bytes)
|
(req "test_protocol" Protocol_hash.encoding)
|
||||||
(req "net" Net_id.encoding)
|
(opt "test_network" (tup2 Net_id.encoding Time.encoding)))))
|
||||||
(opt "test_protocol" Protocol_hash.encoding)
|
|
||||||
(opt "test_network" (tup2 Net_id.encoding Time.encoding))))
|
|
||||||
|
|
||||||
let parse_block s =
|
let parse_block s =
|
||||||
try
|
try
|
||||||
@ -181,10 +179,7 @@ module Blocks = struct
|
|||||||
let info =
|
let info =
|
||||||
RPC.service
|
RPC.service
|
||||||
~description:"All the information about a block."
|
~description:"All the information about a block."
|
||||||
~input:
|
~input: (obj1 (dft "operations" bool true))
|
||||||
(obj2
|
|
||||||
(dft "operations" bool true)
|
|
||||||
(dft "data" bool true))
|
|
||||||
~output: block_info_encoding
|
~output: block_info_encoding
|
||||||
block_path
|
block_path
|
||||||
|
|
||||||
@ -257,7 +252,7 @@ module Blocks = struct
|
|||||||
RPC.service
|
RPC.service
|
||||||
~description:"List the block test protocol."
|
~description:"List the block test protocol."
|
||||||
~input: empty
|
~input: empty
|
||||||
~output: (obj1 (opt "protocol" Protocol_hash.encoding))
|
~output: (obj1 (req "protocol" Protocol_hash.encoding))
|
||||||
RPC.Path.(block_path / "test_protocol")
|
RPC.Path.(block_path / "test_protocol")
|
||||||
|
|
||||||
let test_network =
|
let test_network =
|
||||||
@ -329,8 +324,7 @@ module Blocks = struct
|
|||||||
RPC.Path.(block_path / "complete" /: prefix_arg )
|
RPC.Path.(block_path / "complete" /: prefix_arg )
|
||||||
|
|
||||||
type list_param = {
|
type list_param = {
|
||||||
operations: bool ;
|
include_ops: bool ;
|
||||||
data: bool ;
|
|
||||||
length: int option ;
|
length: int option ;
|
||||||
heads: Block_hash.t list option ;
|
heads: Block_hash.t list option ;
|
||||||
monitor: bool option ;
|
monitor: bool option ;
|
||||||
@ -340,25 +334,20 @@ module Blocks = struct
|
|||||||
}
|
}
|
||||||
let list_param_encoding =
|
let list_param_encoding =
|
||||||
conv
|
conv
|
||||||
(fun { operations ; data ; length ; heads ; monitor ;
|
(fun { include_ops ; length ; heads ; monitor ;
|
||||||
delay ; min_date ; min_heads } ->
|
delay ; min_date ; min_heads } ->
|
||||||
(operations, data, length, heads, monitor, delay, min_date, min_heads))
|
(include_ops, length, heads, monitor, delay, min_date, min_heads))
|
||||||
(fun (operations, data, length, heads, monitor, delay, min_date, min_heads) ->
|
(fun (include_ops, length, heads, monitor,
|
||||||
{ operations ; data ; length ; heads ; monitor ;
|
delay, min_date, min_heads) ->
|
||||||
|
{ include_ops ; length ; heads ; monitor ;
|
||||||
delay ; min_date ; min_heads })
|
delay ; min_date ; min_heads })
|
||||||
(obj8
|
(obj7
|
||||||
(dft "operations"
|
(dft "include_ops"
|
||||||
(Data_encoding.describe
|
(Data_encoding.describe
|
||||||
~description:
|
~description:
|
||||||
"Whether the resulting block informations should include the \
|
"Whether the resulting block informations should include the \
|
||||||
list of operations' hashes. Default false."
|
list of operations' hashes. Default false."
|
||||||
bool) false)
|
bool) false)
|
||||||
(dft "data"
|
|
||||||
(Data_encoding.describe
|
|
||||||
~description:
|
|
||||||
"Whether the resulting block informations should include the \
|
|
||||||
raw protocol dependent data. Default false."
|
|
||||||
bool) false)
|
|
||||||
(opt "length"
|
(opt "length"
|
||||||
(Data_encoding.describe
|
(Data_encoding.describe
|
||||||
~description:
|
~description:
|
||||||
|
@ -28,21 +28,21 @@ module Blocks : sig
|
|||||||
|
|
||||||
type block_info = {
|
type block_info = {
|
||||||
hash: Block_hash.t ;
|
hash: Block_hash.t ;
|
||||||
|
net_id: Net_id.t ;
|
||||||
level: Int32.t ;
|
level: Int32.t ;
|
||||||
predecessor: Block_hash.t ;
|
predecessor: Block_hash.t ;
|
||||||
fitness: MBytes.t list ;
|
|
||||||
timestamp: Time.t ;
|
timestamp: Time.t ;
|
||||||
protocol: Protocol_hash.t option ;
|
|
||||||
operations_hash: Operation_list_list_hash.t ;
|
operations_hash: Operation_list_list_hash.t ;
|
||||||
|
fitness: MBytes.t list ;
|
||||||
|
data: MBytes.t ;
|
||||||
operations: Operation_hash.t list list option ;
|
operations: Operation_hash.t list list option ;
|
||||||
data: MBytes.t option ;
|
protocol: Protocol_hash.t ;
|
||||||
net: Net_id.t ;
|
test_protocol: Protocol_hash.t ;
|
||||||
test_protocol: Protocol_hash.t option ;
|
|
||||||
test_network: (Net_id.t * Time.t) option ;
|
test_network: (Net_id.t * Time.t) option ;
|
||||||
}
|
}
|
||||||
|
|
||||||
val info:
|
val info:
|
||||||
(unit, unit * block, bool * bool, block_info) RPC.service
|
(unit, unit * block, bool, block_info) RPC.service
|
||||||
val net:
|
val net:
|
||||||
(unit, unit * block, unit, Net_id.t) RPC.service
|
(unit, unit * block, unit, Net_id.t) RPC.service
|
||||||
val level:
|
val level:
|
||||||
@ -62,7 +62,7 @@ module Blocks : sig
|
|||||||
val protocol:
|
val protocol:
|
||||||
(unit, unit * block, unit, Protocol_hash.t) RPC.service
|
(unit, unit * block, unit, Protocol_hash.t) RPC.service
|
||||||
val test_protocol:
|
val test_protocol:
|
||||||
(unit, unit * block, unit, Protocol_hash.t option) RPC.service
|
(unit, unit * block, unit, Protocol_hash.t) RPC.service
|
||||||
val test_network:
|
val test_network:
|
||||||
(unit, unit * block, unit, (Net_id.t * Time.t) option) RPC.service
|
(unit, unit * block, unit, (Net_id.t * Time.t) option) RPC.service
|
||||||
val pending_operations:
|
val pending_operations:
|
||||||
@ -70,8 +70,7 @@ module Blocks : sig
|
|||||||
error Prevalidation.preapply_result * Hash.Operation_hash.Set.t) RPC.service
|
error Prevalidation.preapply_result * Hash.Operation_hash.Set.t) RPC.service
|
||||||
|
|
||||||
type list_param = {
|
type list_param = {
|
||||||
operations: bool ;
|
include_ops: bool ;
|
||||||
data: bool ;
|
|
||||||
length: int option ;
|
length: int option ;
|
||||||
heads: Block_hash.t list option ;
|
heads: Block_hash.t list option ;
|
||||||
monitor: bool option ;
|
monitor: bool option ;
|
||||||
|
@ -149,7 +149,7 @@ let build_valid_block
|
|||||||
predecessor = header.shell.predecessor ;
|
predecessor = header.shell.predecessor ;
|
||||||
timestamp = header.shell.timestamp ;
|
timestamp = header.shell.timestamp ;
|
||||||
discovery_time ;
|
discovery_time ;
|
||||||
operations_hash = header.shell.operations ;
|
operations_hash = header.shell.operations_hash ;
|
||||||
operations ;
|
operations ;
|
||||||
fitness = header.shell.fitness ;
|
fitness = header.shell.fitness ;
|
||||||
protocol_hash ;
|
protocol_hash ;
|
||||||
@ -546,7 +546,7 @@ module Raw_block_header = struct
|
|||||||
predecessor = genesis.block ;
|
predecessor = genesis.block ;
|
||||||
timestamp = genesis.time ;
|
timestamp = genesis.time ;
|
||||||
fitness = [] ;
|
fitness = [] ;
|
||||||
operations = Operation_list_list_hash.empty ;
|
operations_hash = Operation_list_list_hash.empty ;
|
||||||
} in
|
} in
|
||||||
let header =
|
let header =
|
||||||
{ Store.Block_header.shell ; proto = MBytes.create 0 } in
|
{ Store.Block_header.shell ; proto = MBytes.create 0 } in
|
||||||
@ -700,7 +700,7 @@ module Block_header = struct
|
|||||||
level: Int32.t ;
|
level: Int32.t ;
|
||||||
predecessor: Block_hash.t ;
|
predecessor: Block_hash.t ;
|
||||||
timestamp: Time.t ;
|
timestamp: Time.t ;
|
||||||
operations: Operation_list_list_hash.t ;
|
operations_hash: Operation_list_list_hash.t ;
|
||||||
fitness: MBytes.t list ;
|
fitness: MBytes.t list ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ module Block_header : sig
|
|||||||
level: Int32.t ;
|
level: Int32.t ;
|
||||||
predecessor: Block_hash.t ;
|
predecessor: Block_hash.t ;
|
||||||
timestamp: Time.t ;
|
timestamp: Time.t ;
|
||||||
operations: Operation_list_list_hash.t ;
|
operations_hash: Operation_list_list_hash.t ;
|
||||||
fitness: MBytes.t list ;
|
fitness: MBytes.t list ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ let apply_block net db
|
|||||||
lwt_log_info "validation of %a: looking for dependencies..."
|
lwt_log_info "validation of %a: looking for dependencies..."
|
||||||
Block_hash.pp_short hash >>= fun () ->
|
Block_hash.pp_short hash >>= fun () ->
|
||||||
Distributed_db.Operation_list.fetch
|
Distributed_db.Operation_list.fetch
|
||||||
db (hash, 0) block.shell.operations >>= fun operation_hashes ->
|
db (hash, 0) block.shell.operations_hash >>= fun operation_hashes ->
|
||||||
Lwt_list.map_p
|
Lwt_list.map_p
|
||||||
(fun op -> Distributed_db.Operation.fetch db op)
|
(fun op -> Distributed_db.Operation.fetch db op)
|
||||||
operation_hashes >>= fun operations ->
|
operation_hashes >>= fun operations ->
|
||||||
|
@ -27,7 +27,7 @@ type shell_block = Store.Block_header.shell_header =
|
|||||||
level: Int32.t ;
|
level: Int32.t ;
|
||||||
predecessor: Block_hash.t ;
|
predecessor: Block_hash.t ;
|
||||||
timestamp: Time.t ;
|
timestamp: Time.t ;
|
||||||
operations: Operation_list_list_hash.t ;
|
operations_hash: Operation_list_list_hash.t ;
|
||||||
fitness: MBytes.t list ;
|
fitness: MBytes.t list ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ type shell_block = Store.Block_header.shell_header = {
|
|||||||
level: Int32.t ;
|
level: Int32.t ;
|
||||||
predecessor: Block_hash.t ;
|
predecessor: Block_hash.t ;
|
||||||
timestamp: Time.t ;
|
timestamp: Time.t ;
|
||||||
operations: Operation_list_list_hash.t ;
|
operations_hash: Operation_list_list_hash.t ;
|
||||||
fitness: MBytes.t list ;
|
fitness: MBytes.t list ;
|
||||||
}
|
}
|
||||||
let shell_block_encoding = Store.Block_header.shell_header_encoding
|
let shell_block_encoding = Store.Block_header.shell_header_encoding
|
||||||
|
@ -23,7 +23,7 @@ type shell_block = Store.Block_header.shell_header = {
|
|||||||
level: Int32.t ;
|
level: Int32.t ;
|
||||||
predecessor: Block_hash.t ;
|
predecessor: Block_hash.t ;
|
||||||
timestamp: Time.t ;
|
timestamp: Time.t ;
|
||||||
operations: Operation_list_list_hash.t ;
|
operations_hash: Operation_list_list_hash.t ;
|
||||||
fitness: MBytes.t list ;
|
fitness: MBytes.t list ;
|
||||||
}
|
}
|
||||||
val shell_block_encoding: shell_block Data_encoding.t
|
val shell_block_encoding: shell_block Data_encoding.t
|
||||||
|
@ -63,14 +63,14 @@ type error +=
|
|||||||
|
|
||||||
let parse_header
|
let parse_header
|
||||||
({ shell = { net_id ; level ; predecessor ;
|
({ shell = { net_id ; level ; predecessor ;
|
||||||
timestamp ; fitness ; operations } ;
|
timestamp ; fitness ; operations_hash } ;
|
||||||
proto } : Updater.raw_block) : header tzresult =
|
proto } : Updater.raw_block) : header tzresult =
|
||||||
match Data_encoding.Binary.of_bytes signed_proto_header_encoding proto with
|
match Data_encoding.Binary.of_bytes signed_proto_header_encoding proto with
|
||||||
| None -> Error [Cant_parse_proto_header]
|
| None -> Error [Cant_parse_proto_header]
|
||||||
| Some (proto, signature) ->
|
| Some (proto, signature) ->
|
||||||
let shell =
|
let shell =
|
||||||
{ Updater.net_id ; level ; predecessor ;
|
{ Updater.net_id ; level ; predecessor ;
|
||||||
timestamp ; fitness ; operations } in
|
timestamp ; fitness ; operations_hash } in
|
||||||
Ok { shell ; proto ; signature }
|
Ok { shell ; proto ; signature }
|
||||||
|
|
||||||
let forge_header shell proto =
|
let forge_header shell proto =
|
||||||
|
@ -434,12 +434,12 @@ let forge_operations _ctxt (shell, proto) =
|
|||||||
let () = register1 Services.Helpers.Forge.operations forge_operations
|
let () = register1 Services.Helpers.Forge.operations forge_operations
|
||||||
|
|
||||||
let forge_block _ctxt
|
let forge_block _ctxt
|
||||||
(net_id, predecessor, timestamp, fitness, operations,
|
(net_id, predecessor, timestamp, fitness, operations_hash,
|
||||||
level, priority, seed_nonce_hash, proof_of_work_nonce) : MBytes.t tzresult Lwt.t =
|
level, priority, seed_nonce_hash, proof_of_work_nonce) : MBytes.t tzresult Lwt.t =
|
||||||
let level = Raw_level.to_int32 level in
|
let level = Raw_level.to_int32 level in
|
||||||
return (Block.forge_header
|
return (Block.forge_header
|
||||||
{ net_id ; level ; predecessor ;
|
{ net_id ; level ; predecessor ;
|
||||||
timestamp ; fitness ; operations }
|
timestamp ; fitness ; operations_hash }
|
||||||
{ priority ; seed_nonce_hash ; proof_of_work_nonce })
|
{ priority ; seed_nonce_hash ; proof_of_work_nonce })
|
||||||
|
|
||||||
let () = register1 Services.Helpers.Forge.block forge_block
|
let () = register1 Services.Helpers.Forge.block forge_block
|
||||||
|
@ -25,8 +25,8 @@ type shell_block = {
|
|||||||
(** The preceding block in the chain. *)
|
(** The preceding block in the chain. *)
|
||||||
timestamp: Time.t ;
|
timestamp: Time.t ;
|
||||||
(** The date at which this block has been forged. *)
|
(** The date at which this block has been forged. *)
|
||||||
operations: Operation_list_list_hash.t ;
|
operations_hash: Operation_list_list_hash.t ;
|
||||||
(** The sequence of operations. *)
|
(** The hash lf the merkle tree of operations. *)
|
||||||
fitness: MBytes.t list ;
|
fitness: MBytes.t list ;
|
||||||
(** The announced score of the block. As a sequence of sequences
|
(** The announced score of the block. As a sequence of sequences
|
||||||
of unsigned bytes. Ordered by length and then by contents
|
of unsigned bytes. Ordered by length and then by contents
|
||||||
|
@ -54,7 +54,7 @@ let int64_to_bytes i =
|
|||||||
MBytes.set_int64 b 0 i;
|
MBytes.set_int64 b 0 i;
|
||||||
b
|
b
|
||||||
|
|
||||||
let operations =
|
let operations_hash =
|
||||||
Operation_list_list_hash.compute [Operation_list_hash.empty]
|
Operation_list_list_hash.compute [Operation_list_hash.empty]
|
||||||
|
|
||||||
let rpc_services : Updater.rpc_context RPC.directory =
|
let rpc_services : Updater.rpc_context RPC.directory =
|
||||||
@ -65,7 +65,7 @@ let rpc_services : Updater.rpc_context RPC.directory =
|
|||||||
(Forge.block RPC.Path.root)
|
(Forge.block RPC.Path.root)
|
||||||
(fun _ctxt ((net_id, level, predecessor, timestamp, fitness), command) ->
|
(fun _ctxt ((net_id, level, predecessor, timestamp, fitness), command) ->
|
||||||
let shell = { Updater.net_id ; level ; predecessor ;
|
let shell = { Updater.net_id ; level ; predecessor ;
|
||||||
timestamp ; fitness ; operations } in
|
timestamp ; fitness ; operations_hash } in
|
||||||
let bytes = Data.Command.forge shell command in
|
let bytes = Data.Command.forge shell command in
|
||||||
RPC.Answer.return bytes) in
|
RPC.Answer.return bytes) in
|
||||||
dir
|
dir
|
||||||
|
@ -393,21 +393,22 @@ module Mining = struct
|
|||||||
Client_node_rpcs.Blocks.info rpc_config block >>=? fun bi ->
|
Client_node_rpcs.Blocks.info rpc_config block >>=? fun bi ->
|
||||||
let seed_nonce_hash = Nonce.hash seed_nonce in
|
let seed_nonce_hash = Nonce.hash seed_nonce in
|
||||||
Client_proto_rpcs.Context.next_level rpc_config block >>=? fun level ->
|
Client_proto_rpcs.Context.next_level rpc_config block >>=? fun level ->
|
||||||
let operations =
|
let operations_hash =
|
||||||
Operation_list_list_hash.compute
|
Operation_list_list_hash.compute
|
||||||
[Operation_list_hash.compute operation_list] in
|
[Operation_list_hash.compute operation_list] in
|
||||||
let shell =
|
let shell =
|
||||||
{ Store.Block_header.net_id = bi.net ; predecessor = bi.hash ;
|
{ Store.Block_header.net_id = bi.net_id ; predecessor = bi.hash ;
|
||||||
timestamp ; fitness ; operations ; level = Raw_level.to_int32 level.level } in
|
timestamp ; fitness ; operations_hash ;
|
||||||
|
level = Raw_level.to_int32 level.level } in
|
||||||
mine_stamp
|
mine_stamp
|
||||||
block src_sk shell priority seed_nonce_hash >>=? fun proof_of_work_nonce ->
|
block src_sk shell priority seed_nonce_hash >>=? fun proof_of_work_nonce ->
|
||||||
Client_proto_rpcs.Helpers.Forge.block rpc_config
|
Client_proto_rpcs.Helpers.Forge.block rpc_config
|
||||||
block
|
block
|
||||||
~net:bi.net
|
~net:bi.net_id
|
||||||
~predecessor:bi.hash
|
~predecessor:bi.hash
|
||||||
~timestamp
|
~timestamp
|
||||||
~fitness
|
~fitness
|
||||||
~operations
|
~operations_hash
|
||||||
~level:level.level
|
~level:level.level
|
||||||
~priority
|
~priority
|
||||||
~seed_nonce_hash
|
~seed_nonce_hash
|
||||||
|
@ -62,7 +62,7 @@ let operation op =
|
|||||||
Data_encoding.Binary.to_bytes Store.Operation.encoding op
|
Data_encoding.Binary.to_bytes Store.Operation.encoding op
|
||||||
|
|
||||||
let block _state ?(operations = []) pred_hash pred name : Store.Block_header.t =
|
let block _state ?(operations = []) pred_hash pred name : Store.Block_header.t =
|
||||||
let operations =
|
let operations_hash =
|
||||||
Operation_list_list_hash.compute
|
Operation_list_list_hash.compute
|
||||||
[Operation_list_hash.compute operations] in
|
[Operation_list_hash.compute operations] in
|
||||||
let fitness = incr_fitness pred.Store.Block_header.shell.fitness in
|
let fitness = incr_fitness pred.Store.Block_header.shell.fitness in
|
||||||
@ -71,7 +71,7 @@ let block _state ?(operations = []) pred_hash pred name : Store.Block_header.t =
|
|||||||
net_id = pred.shell.net_id ;
|
net_id = pred.shell.net_id ;
|
||||||
level = Int32.succ pred.shell.level ;
|
level = Int32.succ pred.shell.level ;
|
||||||
predecessor = pred_hash ;
|
predecessor = pred_hash ;
|
||||||
timestamp ; operations; fitness } ;
|
timestamp ; operations_hash ; fitness } ;
|
||||||
proto = MBytes.of_string name ;
|
proto = MBytes.of_string name ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ let build_chain state tbl otbl pred names =
|
|||||||
|
|
||||||
let block _state ?(operations = []) (pred: State.Valid_block.t) name
|
let block _state ?(operations = []) (pred: State.Valid_block.t) name
|
||||||
: State.Block_header.t =
|
: State.Block_header.t =
|
||||||
let operations =
|
let operations_hash =
|
||||||
Operation_list_list_hash.compute
|
Operation_list_list_hash.compute
|
||||||
[Operation_list_hash.compute operations] in
|
[Operation_list_hash.compute operations] in
|
||||||
let fitness = incr_fitness pred.fitness in
|
let fitness = incr_fitness pred.fitness in
|
||||||
@ -142,7 +142,7 @@ let block _state ?(operations = []) (pred: State.Valid_block.t) name
|
|||||||
{ shell = { net_id = pred.net_id ;
|
{ shell = { net_id = pred.net_id ;
|
||||||
level = Int32.succ pred.level ;
|
level = Int32.succ pred.level ;
|
||||||
predecessor = pred.hash ;
|
predecessor = pred.hash ;
|
||||||
timestamp ; operations; fitness } ;
|
timestamp ; operations_hash ; fitness } ;
|
||||||
proto = MBytes.of_string name ;
|
proto = MBytes.of_string name ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,14 +89,14 @@ let test_operation s =
|
|||||||
(** Block store *)
|
(** Block store *)
|
||||||
|
|
||||||
let lolblock ?(operations = []) header =
|
let lolblock ?(operations = []) header =
|
||||||
let operations =
|
let operations_hash =
|
||||||
Operation_list_list_hash.compute
|
Operation_list_list_hash.compute
|
||||||
[Operation_list_hash.compute operations] in
|
[Operation_list_hash.compute operations] in
|
||||||
{ Store.Block_header.shell =
|
{ Store.Block_header.shell =
|
||||||
{ timestamp = Time.of_seconds (Random.int64 1500L) ;
|
{ timestamp = Time.of_seconds (Random.int64 1500L) ;
|
||||||
level = 0l ; (* dummy *)
|
level = 0l ; (* dummy *)
|
||||||
net_id ;
|
net_id ;
|
||||||
predecessor = genesis_block ; operations ;
|
predecessor = genesis_block ; operations_hash ;
|
||||||
fitness = [MBytes.of_string @@ string_of_int @@ String.length header;
|
fitness = [MBytes.of_string @@ string_of_int @@ String.length header;
|
||||||
MBytes.of_string @@ string_of_int @@ 12] } ;
|
MBytes.of_string @@ string_of_int @@ 12] } ;
|
||||||
proto = MBytes.of_string header ;
|
proto = MBytes.of_string header ;
|
||||||
|
Loading…
Reference in New Issue
Block a user