Get rid of forced operation injection

This commit is contained in:
Benjamin Canou 2017-11-23 16:39:33 +01:00 committed by Grégoire Henry
parent dee86fb462
commit 566a92197b
20 changed files with 82 additions and 116 deletions

View File

@ -24,9 +24,9 @@ let inject_block cctxt
call_err_service0 cctxt Services.inject_block
{ raw ; blocking = not async ; force ; net_id ; operations }
let inject_operation cctxt ?(async = false) ?force ?net_id operation =
let inject_operation cctxt ?(async = false) ?net_id operation =
call_err_service0 cctxt Services.inject_operation
(operation, not async, net_id, force)
(operation, not async, net_id)
let inject_protocol cctxt ?(async = false) ?force protocol =
call_err_service0 cctxt Services.inject_protocol

View File

@ -28,7 +28,7 @@ val inject_block:
val inject_operation:
#Client_rpcs.ctxt ->
?async:bool -> ?force:bool -> ?net_id:Net_id.t ->
?async:bool -> ?net_id:Net_id.t ->
MBytes.t ->
Operation_hash.t tzresult Lwt.t

View File

@ -89,7 +89,7 @@ let get_signing_slots cctxt ?max_priority block delegate level =
return slots
let inject_endorsement (cctxt : Client_commands.full_context)
block level ?async ?force
block level ?async
src_sk source slot =
let block = Client_rpcs.last_baked_block block in
Client_node_rpcs.Blocks.info cctxt block >>=? fun bi ->
@ -102,7 +102,7 @@ let inject_endorsement (cctxt : Client_commands.full_context)
() >>=? fun bytes ->
let signed_bytes = Ed25519.Signature.append src_sk bytes in
Client_node_rpcs.inject_operation
cctxt ?force ?async ~net_id:bi.net_id signed_bytes >>=? fun oph ->
cctxt ?async ~net_id:bi.net_id signed_bytes >>=? fun oph ->
State.record_endorsement cctxt level bi.hash slot oph >>=? fun () ->
return oph
@ -122,7 +122,7 @@ let check_endorsement cctxt level slot =
let forge_endorsement (cctxt : Client_commands.full_context)
block ?(force = false)
block
~src_sk ?slot ?max_priority src_pk =
let block = Client_rpcs.last_baked_block block in
let src_pkh = Ed25519.Public_key.hash src_pk in
@ -136,12 +136,9 @@ let forge_endorsement (cctxt : Client_commands.full_context)
| slot::_ -> return slot
| [] -> cctxt#error "No slot found at level %a" Raw_level.pp level
end >>=? fun slot ->
begin
if force then return ()
else check_endorsement cctxt level slot
end >>=? fun () ->
check_endorsement cctxt level slot >>=? fun () ->
inject_endorsement cctxt
block level ~force
block level
src_sk src_pk slot
@ -290,7 +287,7 @@ let endorse cctxt state =
lwt_debug "Endorsing %a for %s (slot %d)!"
Block_hash.pp_short hash name slot >>= fun () ->
inject_endorsement cctxt
b level ~async:true ~force:true
b level ~async:true
sk pk slot >>=? fun oph ->
cctxt#message
"Injected endorsement for block '%a' \

View File

@ -10,7 +10,6 @@
val forge_endorsement:
Client_commands.full_context ->
Client_proto_rpcs.block ->
?force:bool ->
src_sk:secret_key ->
?slot:int ->
?max_priority:int ->

View File

@ -379,7 +379,7 @@ let insert_block
begin
safe_get_unrevealed_nonces cctxt (`Hash bi.hash) >>= fun nonces ->
Client_baking_revelation.forge_seed_nonce_revelation
cctxt ~force:true (`Hash bi.hash) (List.map snd nonces)
cctxt (`Hash bi.hash) (List.map snd nonces)
end >>= fun _ignore_error ->
if Fitness.compare state.best.fitness bi.fitness < 0 then begin
state.best <- bi ;

View File

@ -30,10 +30,10 @@ let bake_block (cctxt : Client_commands.full_context) block
cctxt#message "Injected block %a" Block_hash.pp_short block_hash >>= fun () ->
return ()
let endorse_block cctxt ?force ?max_priority delegate =
let endorse_block cctxt ?max_priority delegate =
Client_keys.get_key cctxt delegate >>=? fun (_src_name, src_pk, src_sk) ->
Client_baking_endorsement.forge_endorsement cctxt
cctxt#block ?force ?max_priority ~src_sk src_pk >>=? fun oph ->
cctxt#block ?max_priority ~src_sk src_pk >>=? fun oph ->
cctxt#answer "Operation successfully injected in the node." >>= fun () ->
cctxt#answer "Operation hash is '%a'." Operation_hash.pp oph >>= fun () ->
return ()
@ -49,14 +49,14 @@ let get_predecessor_cycle (cctxt : #Client_commands.logger) cycle =
Cycle.pp cycle
| Some cycle -> Lwt.return cycle
let do_reveal cctxt ?force block blocks =
let do_reveal cctxt block blocks =
let nonces = List.map snd blocks in
Client_baking_revelation.forge_seed_nonce_revelation cctxt
block ?force nonces >>=? fun () ->
block nonces >>=? fun () ->
Client_proto_nonces.dels cctxt (List.map fst blocks) >>=? fun () ->
return ()
let reveal_block_nonces (cctxt : Client_commands.full_context) ?force block_hashes =
let reveal_block_nonces (cctxt : Client_commands.full_context) block_hashes =
Lwt_list.filter_map_p
(fun hash ->
Lwt.catch
@ -80,13 +80,13 @@ let reveal_block_nonces (cctxt : Client_commands.full_context) ?force block_hash
| Some nonce ->
return (Some (bi.hash, (bi.level.level, nonce))))
block_infos >>=? fun blocks ->
do_reveal cctxt ?force cctxt#block blocks
do_reveal cctxt cctxt#block blocks
let reveal_nonces cctxt ?force () =
let reveal_nonces cctxt () =
let block = Client_rpcs.last_baked_block cctxt#block in
Client_baking_forge.get_unrevealed_nonces
cctxt ?force block >>=? fun nonces ->
do_reveal cctxt ?force cctxt#block nonces
cctxt block >>=? fun nonces ->
do_reveal cctxt cctxt#block nonces
let run_daemon cctxt ?max_priority ~endorsement_delay delegates ~endorsement ~baking ~denunciation =
Client_baking_daemon.run cctxt

View File

@ -21,7 +21,6 @@ val bake_block:
(** Endorse a block *)
val endorse_block:
Client_commands.full_context ->
?force:bool ->
?max_priority:int ->
Client_keys.Public_key_hash.t ->
unit Error_monad.tzresult Lwt.t
@ -35,14 +34,12 @@ val get_predecessor_cycle:
(** Reveal the nonces used to bake each block in the given list *)
val reveal_block_nonces :
Client_commands.full_context ->
?force:bool ->
Block_hash.t list ->
unit Error_monad.tzresult Lwt.t
(** Reveal all unrevealed nonces *)
val reveal_nonces :
Client_commands.full_context ->
?force:bool ->
unit ->
unit Error_monad.tzresult Lwt.t

View File

@ -29,14 +29,13 @@ let commands () =
else (endorsement, baking, denunciation) in
run_daemon cctxt ?max_priority ~endorsement_delay ~endorsement ~baking ~denunciation delegates) ;
command ~group ~desc: "Forge and inject an endorsement operation"
(args2 force_switch max_priority_arg)
(args1 max_priority_arg)
(prefixes [ "endorse"; "for" ]
@@ Client_keys.Public_key_hash.alias_param
~name:"baker" ~desc: "name of the delegate owning the endorsement right"
@@ stop)
(fun (force, max_priority) (_, delegate) cctxt ->
endorse_block cctxt
~force ?max_priority delegate) ;
(fun max_priority (_, delegate) cctxt ->
endorse_block cctxt ?max_priority delegate) ;
command ~group ~desc: "Forge and inject block using the delegate rights"
(args3 max_priority_arg force_switch free_baking_switch)
(prefixes [ "bake"; "for" ]
@ -47,16 +46,15 @@ let commands () =
bake_block cctxt cctxt#block
~force ?max_priority ~free_baking delegate) ;
command ~group ~desc: "Forge and inject a seed-nonce revelation operation"
(args1 force_switch)
no_options
(prefixes [ "reveal"; "nonce"; "for" ]
@@ seq_of_param Block_hash.param)
(fun force block_hashes cctxt ->
reveal_block_nonces cctxt
~force block_hashes) ;
(fun () block_hashes cctxt ->
reveal_block_nonces cctxt block_hashes) ;
command ~group ~desc: "Forge and inject redemption operations"
(args1 force_switch)
no_options
(prefixes [ "reveal"; "nonces" ]
@@ stop)
(fun force cctxt ->
reveal_nonces cctxt ~force ()) ;
(fun () cctxt ->
reveal_nonces cctxt ()) ;
]

View File

@ -9,7 +9,7 @@
open Tezos_context
let inject_seed_nonce_revelation rpc_config block ?force ?async nonces =
let inject_seed_nonce_revelation rpc_config block ?async nonces =
let operations =
List.map
(fun (level, nonce) ->
@ -19,13 +19,13 @@ let inject_seed_nonce_revelation rpc_config block ?force ?async nonces =
Client_proto_rpcs.Helpers.Forge.Anonymous.operations rpc_config
block ~branch:bi.hash operations >>=? fun bytes ->
Client_node_rpcs.inject_operation
rpc_config ?force ?async ~net_id:bi.net_id
rpc_config ?async ~net_id:bi.net_id
bytes >>=? fun oph ->
return oph
let forge_seed_nonce_revelation
(cctxt: Client_commands.full_context)
block ?(force = false) nonces =
block nonces =
Client_node_rpcs.Blocks.hash cctxt block >>=? fun hash ->
match nonces with
| [] ->
@ -33,7 +33,7 @@ let forge_seed_nonce_revelation
Block_hash.pp_short hash >>= fun () ->
return ()
| _ ->
inject_seed_nonce_revelation cctxt block ~force nonces >>=? fun oph ->
inject_seed_nonce_revelation cctxt block nonces >>=? fun oph ->
cctxt#answer
"Operation successfully injected %d revelation(s) for %a."
(List.length nonces)

View File

@ -10,7 +10,6 @@
val inject_seed_nonce_revelation:
#Client_rpcs.ctxt ->
Client_proto_rpcs.block ->
?force:bool ->
?async:bool ->
(Raw_level.t * Nonce.t) list ->
Operation_hash.t tzresult Lwt.t
@ -18,6 +17,5 @@ val inject_seed_nonce_revelation:
val forge_seed_nonce_revelation:
Client_commands.full_context ->
Client_proto_rpcs.block ->
?force:bool ->
(Raw_level.t * Nonce.t) list ->
unit tzresult Lwt.t

View File

@ -43,7 +43,7 @@ let parse_expression arg =
(Michelson_v1_parser.parse_expression arg))
let transfer rpc_config
block ?force ?branch
block ?branch
~source ~src_pk ~src_sk ~destination ?arg ~amount ~fee () =
get_branch rpc_config block branch >>=? fun (net_id, branch) ->
begin match arg with
@ -66,11 +66,11 @@ let transfer rpc_config
Client_proto_rpcs.Helpers.apply_operation rpc_config block
predecessor oph bytes (Some signature) >>=? fun contracts ->
Client_node_rpcs.inject_operation
rpc_config ?force ~net_id signed_bytes >>=? fun injected_oph ->
rpc_config ~net_id signed_bytes >>=? fun injected_oph ->
assert (Operation_hash.equal oph injected_oph) ;
return (oph, contracts)
let originate rpc_config ?force ?net_id ~block ?signature bytes =
let originate rpc_config ?net_id ~block ?signature bytes =
let signed_bytes =
match signature with
| None -> bytes
@ -81,7 +81,7 @@ let originate rpc_config ?force ?net_id ~block ?signature bytes =
predecessor oph bytes signature >>=? function
| [ contract ] ->
Client_node_rpcs.inject_operation
rpc_config ?force ?net_id signed_bytes >>=? fun injected_oph ->
rpc_config ?net_id signed_bytes >>=? fun injected_oph ->
assert (Operation_hash.equal oph injected_oph) ;
return (oph, contract)
| contracts ->
@ -89,13 +89,8 @@ let originate rpc_config ?force ?net_id ~block ?signature bytes =
"The origination introduced %d contracts instead of one."
(List.length contracts)
let operation_submitted_message (cctxt : #Client_commands.logger) ?(force=false) ?(contracts = []) oph =
begin
if not force then
cctxt#message "Operation successfully injected in the node."
else
Lwt.return_unit
end >>= fun () ->
let operation_submitted_message (cctxt : #Client_commands.logger) ?(contracts = []) oph =
cctxt#message "Operation successfully injected in the node." >>= fun () ->
cctxt#message "Operation hash is '%a'." Operation_hash.pp oph >>= fun () ->
Lwt_list.iter_s
(fun c ->
@ -104,7 +99,7 @@ let operation_submitted_message (cctxt : #Client_commands.logger) ?(force=false)
Contract.pp c)
contracts >>= return
let originate_account ?(force=false) ?branch
let originate_account ?branch
~source ~src_pk ~src_sk ~manager_pkh
?delegatable ?delegate ~balance ~fee block rpc_config () =
get_branch rpc_config block branch >>=? fun (net_id, branch) ->
@ -116,16 +111,16 @@ let originate_account ?(force=false) ?branch
~counter ~balance ~spendable:true
?delegatable ?delegatePubKey:delegate ~fee () >>=? fun bytes ->
let signature = Ed25519.sign src_sk bytes in
originate rpc_config ~force ~block ~net_id ~signature bytes
originate rpc_config ~block ~net_id ~signature bytes
let faucet ?force ?branch ~manager_pkh block rpc_config () =
let faucet ?branch ~manager_pkh block rpc_config () =
get_branch rpc_config block branch >>=? fun (net_id, branch) ->
Client_proto_rpcs.Helpers.Forge.Anonymous.faucet
rpc_config block ~branch ~id:manager_pkh () >>=? fun bytes ->
originate rpc_config ?force ~net_id ~block bytes
originate rpc_config ~net_id ~block bytes
let delegate_contract rpc_config
block ?force ?branch
block ?branch
~source ?src_pk ~manager_sk
~fee delegate_opt =
get_branch rpc_config block branch >>=? fun (net_id, branch) ->
@ -139,7 +134,7 @@ let delegate_contract rpc_config
let signed_bytes = Ed25519.Signature.concat bytes signature in
let oph = Operation_hash.hash_bytes [ signed_bytes ] in
Client_node_rpcs.inject_operation
rpc_config ?force ~net_id signed_bytes >>=? fun injected_oph ->
rpc_config ~net_id signed_bytes >>=? fun injected_oph ->
assert (Operation_hash.equal oph injected_oph) ;
return oph
@ -209,7 +204,6 @@ let save_contract ~force cctxt alias_name contract =
let originate_contract
~fee
~delegate
?(force=false)
?(delegatable=true)
?(spendable=false)
~initial_storage
@ -234,4 +228,4 @@ let originate_contract
~delegatable ?delegatePubKey:delegate
~script:{ code ; storage } ~fee () >>=? fun bytes ->
let signature = Ed25519.sign src_sk bytes in
originate cctxt ~force ~block ~signature bytes
originate cctxt ~block ~signature bytes

View File

@ -44,7 +44,6 @@ val set_delegate :
val operation_submitted_message :
#Client_commands.logger ->
?force:bool ->
Operation_hash.t ->
unit tzresult Lwt.t
@ -55,7 +54,6 @@ val source_to_keys:
(public_key * secret_key) tzresult Lwt.t
val originate_account :
?force:bool ->
?branch:int ->
source:Contract.t ->
src_pk:public_key ->
@ -78,7 +76,6 @@ val save_contract :
val operation_submitted_message :
#Client_commands.logger ->
?force:bool ->
?contracts:Contract.t list ->
Operation_hash.t ->
unit tzresult Lwt.t
@ -86,7 +83,6 @@ val operation_submitted_message :
val originate_contract:
fee:Tez.t ->
delegate:public_key_hash option ->
?force:bool ->
?delegatable:bool ->
?spendable:bool ->
initial_storage:string ->
@ -100,7 +96,6 @@ val originate_contract:
(Operation_hash.t * Contract.t) tzresult Lwt.t
val faucet :
?force:bool ->
?branch:int ->
manager_pkh:public_key_hash ->
Client_rpcs.block ->
@ -110,7 +105,6 @@ val faucet :
val transfer :
#Client_rpcs.ctxt ->
Client_proto_rpcs.block ->
?force:bool ->
?branch:int ->
source:Contract.t ->
src_pk:public_key ->

View File

@ -116,17 +116,17 @@ let commands () =
end ;
command ~group ~desc: "set the delegate of a contract"
(args2 fee_arg force_switch)
(args1 fee_arg)
(prefixes [ "set" ; "delegate" ; "for" ]
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
@@ prefix "to"
@@ Public_key_hash.alias_param
~name: "mgr" ~desc: "New delegate of the contract"
@@ stop)
begin fun (fee, force) (_, contract) (_, delegate) cctxt ->
begin fun fee (_, contract) (_, delegate) cctxt ->
source_to_keys cctxt cctxt#block contract >>=? fun (src_pk, manager_sk) ->
set_delegate ~fee cctxt cctxt#block contract (Some delegate) ~src_pk ~manager_sk >>=? fun oph ->
operation_submitted_message cctxt ~force oph
operation_submitted_message cctxt oph
end ;
command ~group ~desc:"open a new account"
@ -153,7 +153,6 @@ let commands () =
~fee
?delegate
~delegatable
~force
~manager_pkh
~balance
~source
@ -163,7 +162,7 @@ let commands () =
cctxt
() >>=? fun (oph, contract) ->
save_contract ~force cctxt alias_name contract >>=? fun () ->
operation_submitted_message ~force ~contracts:[ contract ] cctxt oph
operation_submitted_message ~contracts:[ contract ] cctxt oph
end ;
command ~group ~desc: "Launch a smart contract on the blockchain"
@ -193,14 +192,14 @@ let commands () =
Lwt.return (Micheline_parser.no_parsing_error program) >>=? fun { expanded = code } ->
source_to_keys cctxt cctxt#block source >>=? fun (src_pk, src_sk) ->
get_pkh cctxt delegate >>=? fun delegate ->
originate_contract ~fee ~delegate ~force ~delegatable ~spendable ~initial_storage
originate_contract ~fee ~delegate ~delegatable ~spendable ~initial_storage
~manager ~balance ~source ~src_pk ~src_sk ~code cctxt >>= fun errors ->
report_michelson_errors ~no_print_source ~msg:"origination simulation failed" cctxt errors >>= function
| None -> return ()
| Some (oph, contract) ->
save_contract ~force cctxt alias_name contract >>=? fun () ->
operation_submitted_message cctxt
~force ~contracts:[contract] oph
~contracts:[contract] oph
end ;
command ~group ~desc: "open a new (free) account"
@ -214,14 +213,14 @@ let commands () =
@@ stop)
begin fun force alias_name (_, manager_pkh) cctxt ->
RawContractAlias.of_fresh cctxt force alias_name >>=? fun alias_name ->
faucet ~force ~manager_pkh cctxt#block cctxt () >>=? fun (oph, contract) ->
faucet ~manager_pkh cctxt#block cctxt () >>=? fun (oph, contract) ->
operation_submitted_message cctxt
~force ~contracts:[contract] oph >>=? fun () ->
~contracts:[contract] oph >>=? fun () ->
save_contract ~force cctxt alias_name contract
end;
command ~group ~desc: "transfer tokens"
(args4 fee_arg arg_arg force_switch no_print_source_flag)
(args3 fee_arg arg_arg no_print_source_flag)
(prefixes [ "transfer" ]
@@ tez_param
~name: "qty" ~desc: "amount taken from source"
@ -232,18 +231,18 @@ let commands () =
@@ ContractAlias.destination_param
~name: "dst" ~desc: "name/literal of the destination contract"
@@ stop)
begin fun (fee, arg, force, no_print_source) amount (_, source) (_, destination) cctxt ->
begin fun (fee, arg, no_print_source) amount (_, source) (_, destination) cctxt ->
source_to_keys cctxt cctxt#block source >>=? fun (src_pk, src_sk) ->
transfer ~force cctxt ~fee cctxt#block
transfer cctxt ~fee cctxt#block
~source ~src_pk ~src_sk ~destination ~arg ~amount () >>=
report_michelson_errors ~no_print_source ~msg:"transfer simulation failed" cctxt >>= function
| None -> return ()
| Some (oph, contracts) ->
operation_submitted_message cctxt ~force ~contracts oph
operation_submitted_message cctxt ~contracts oph
end;
command ~desc: "Activate a protocol"
(args1 force_switch)
no_options
(prefixes [ "activate" ; "protocol" ]
@@ Protocol_hash.param ~name:"version"
~desc:"Protocol version (b58check)"
@ -251,14 +250,14 @@ let commands () =
@@ Environment.Ed25519.Secret_key.param
~name:"password" ~desc:"Dictator's key"
@@ stop)
begin fun force hash seckey cctxt ->
begin fun () hash seckey cctxt ->
dictate cctxt cctxt#block
(Activate hash) seckey >>=? fun oph ->
operation_submitted_message cctxt ~force:force oph
operation_submitted_message cctxt oph
end ;
command ~desc: "Fork a test protocol"
(args1 force_switch)
no_options
(prefixes [ "fork" ; "test" ; "protocol" ]
@@ Protocol_hash.param ~name:"version"
~desc:"Protocol version (b58check)"
@ -266,10 +265,10 @@ let commands () =
@@ Environment.Ed25519.Secret_key.param
~name:"password" ~desc:"Dictator's key"
@@ stop)
begin fun force hash seckey cctxt ->
begin fun () hash seckey cctxt ->
dictate cctxt cctxt#block
(Activate_testnet hash) seckey >>=? fun oph ->
operation_submitted_message cctxt ~force:force oph
operation_submitted_message cctxt oph
end ;
]

View File

@ -758,7 +758,7 @@ let inject_operation =
prevalidation context."
~query: RPC_query.empty
~input:
(obj4
(obj3
(req "signedOperationContents"
(describe ~title: "Tezos signed operation (hex encoded)"
bytes))
@ -769,13 +769,7 @@ let inject_operation =
(pre-)validated before answering. (default: true)"
bool)
true)
(opt "net_id" Net_id.encoding)
(opt "force"
(describe
~description:
"Should we inject operation that are \"branch_refused\" \
or \"branch_delayed\". (default: false)"
bool)))
(opt "net_id" Net_id.encoding))
~output:
(Error.wrap @@
describe

View File

@ -267,7 +267,7 @@ val inject_block:
val inject_operation:
([ `POST ], unit,
unit, unit, (MBytes.t * bool * Net_id.t option * bool option),
unit, unit, (MBytes.t * bool * Net_id.t option),
Operation_hash.t tzresult, unit) RPC_service.t
val inject_protocol:

View File

@ -10,12 +10,12 @@
open Lwt.Infix
open Logging.Node.Worker
let inject_operation validator ?force ?net_id bytes =
let inject_operation validator ?net_id bytes =
let t =
match Data_encoding.Binary.of_bytes Operation.encoding bytes with
| None -> failwith "Can't parse the operation"
| Some op ->
Validator.inject_operation validator ?force ?net_id op
Validator.inject_operation validator ?net_id op
in
let hash = Operation_hash.hash_bytes [bytes] in
Lwt.return (hash, t)
@ -56,7 +56,7 @@ type t = {
MBytes.t -> Operation.t list list ->
(Block_hash.t * unit tzresult Lwt.t) tzresult Lwt.t ;
inject_operation:
?force:bool -> ?net_id:Net_id.t -> MBytes.t ->
?net_id:Net_id.t -> MBytes.t ->
(Operation_hash.t * unit tzresult Lwt.t) Lwt.t ;
inject_protocol:
?force:bool -> Protocol.t ->

View File

@ -44,7 +44,7 @@ module RPC : sig
non strictly increasing fitness. *)
val inject_operation:
t -> ?force:bool -> ?net_id:Net_id.t -> MBytes.t ->
t -> ?net_id:Net_id.t -> MBytes.t ->
(Operation_hash.t * unit tzresult Lwt.t) Lwt.t
val inject_protocol:
t -> ?force:bool -> Protocol.t ->

View File

@ -420,9 +420,9 @@ let build_rpc_directory node =
end >>= RPC_answer.return in
RPC_directory.register0 dir Services.inject_block implementation in
let dir =
let implementation () (contents, blocking, net_id, force) =
let implementation () (contents, blocking, net_id) =
Node.RPC.inject_operation
node ?force ?net_id contents >>= fun (hash, wait) ->
node ?net_id contents >>= fun (hash, wait) ->
begin
(if blocking then wait else return ()) >>=? fun () -> return hash
end >>= RPC_answer.return in

View File

@ -114,7 +114,7 @@ let shutdown { active_nets ; block_validator } =
let watcher { valid_block_input } =
Lwt_watcher.create_stream valid_block_input
let inject_operation v ?(force = false) ?net_id op =
let inject_operation v ?net_id op =
begin
match net_id with
| None -> begin
@ -127,17 +127,14 @@ let inject_operation v ?(force = false) ?net_id op =
end
| Some net_id ->
get v net_id >>=? fun nv ->
if force then
return nv
else
Distributed_db.Block_header.known
(Net_validator.net_db nv)
op.shell.branch >>= function
| true ->
return nv
| false ->
failwith "Unknown branch (%a), cannot inject the operation."
Block_hash.pp_short op.shell.branch
Distributed_db.Block_header.known
(Net_validator.net_db nv)
op.shell.branch >>= function
| true ->
return nv
| false ->
failwith "Unknown branch (%a), cannot inject the operation."
Block_hash.pp_short op.shell.branch
end >>=? fun nv ->
let pv = Net_validator.prevalidator nv in
Prevalidator.inject_operation pv ~force op
Prevalidator.inject_operation pv op

View File

@ -39,6 +39,5 @@ val watcher: t -> State.Block.t Lwt_stream.t * Lwt_watcher.stopper
val inject_operation:
t ->
?force:bool ->
?net_id:Net_id.t ->
Operation.t -> unit tzresult Lwt.t