@@ -763,15 +763,72 @@ func (p *ChainPorter) updateAssetProofFile(ctx context.Context,
763763 }, nil
764764}
765765
766+ // reportProofTransfers logs a summary of the transfer outputs that require
767+ // proof delivery and those that do not.
768+ func reportProofTransfers (notDeliveringOutputs []TransferOutput ,
769+ pendingDeliveryOutputs []TransferOutput ) {
770+
771+ log .Debugf ("Count of transfer output(s) by proof delivery status: " +
772+ "(count_delivery_not_applicable=%d, count_pending_delivery=%d)" ,
773+ len (notDeliveringOutputs ), len (pendingDeliveryOutputs ))
774+
775+ // Report the transfer outputs that do not require proof delivery.
776+ if len (notDeliveringOutputs ) > 0 {
777+ logEntries := make ([]string , 0 , len (notDeliveringOutputs ))
778+ for idx := range notDeliveringOutputs {
779+ out := notDeliveringOutputs [idx ]
780+ key := out .ScriptKey .PubKey
781+
782+ entry := fmt .Sprintf ("transfer_output_position=%d, " +
783+ "proof_delivery_status=%v, " +
784+ "script_key=%x" , out .Position ,
785+ out .ProofDeliveryComplete ,
786+ key .SerializeCompressed ())
787+ logEntries = append (logEntries , entry )
788+ }
789+
790+ entriesJoin := strings .Join (logEntries , "\n " )
791+ log .Debugf ("Transfer outputs that do not require proof " +
792+ "delivery:\n %v" , entriesJoin )
793+ }
794+
795+ // Report the transfer outputs that require proof delivery.
796+ if len (pendingDeliveryOutputs ) > 0 {
797+ logEntries := make ([]string , 0 , len (pendingDeliveryOutputs ))
798+ for idx := range pendingDeliveryOutputs {
799+ out := pendingDeliveryOutputs [idx ]
800+ key := out .ScriptKey .PubKey
801+
802+ entry := fmt .Sprintf ("transfer_output_position=%d, " +
803+ "proof_delivery_status=%v, " +
804+ "proof_courier_addr=%s, " +
805+ "script_key=%x" , out .Position ,
806+ out .ProofDeliveryComplete , out .ProofCourierAddr ,
807+ key .SerializeCompressed ())
808+ logEntries = append (logEntries , entry )
809+ }
810+
811+ entriesJoin := strings .Join (logEntries , "\n " )
812+ log .Debugf ("Transfer outputs that require proof delivery:\n %v" ,
813+ entriesJoin )
814+ }
815+ }
816+
766817// transferReceiverProof retrieves the sender and receiver proofs from the
767818// archive and then transfers the receiver's proof to the receiver. Upon
768819// successful transfer, the asset parcel delivery is marked as complete.
769820func (p * ChainPorter ) transferReceiverProof (pkg * sendPackage ) error {
770821 ctx , cancel := p .WithCtxQuitNoTimeout ()
771822 defer cancel ()
772823
773- deliver := func (ctx context.Context , out TransferOutput ) error {
774- key := out .ScriptKey .PubKey
824+ // Classify transfer outputs into those that require proof delivery and
825+ // those that do not.
826+ var (
827+ notDeliveringOutputs []TransferOutput
828+ pendingDeliveryOutputs []TransferOutput
829+ )
830+ for idx := range pkg .OutboundPkg .Outputs {
831+ out := pkg .OutboundPkg .Outputs [idx ]
775832
776833 // We'll first check to see if the proof should be delivered.
777834 shouldDeliverProof , err := out .ShouldDeliverProof ()
@@ -781,15 +838,20 @@ func (p *ChainPorter) transferReceiverProof(pkg *sendPackage) error {
781838 }
782839
783840 if ! shouldDeliverProof {
784- log .Debugf ("Transfer ouput proof does not require " +
785- "delivery (transfer_output_position=%d, " +
786- "proof_delivery_status=%v, " +
787- "script_key=%x)" , out .Position ,
788- out .ProofDeliveryComplete ,
789- key .SerializeCompressed ())
790- return nil
841+ notDeliveringOutputs = append (notDeliveringOutputs , out )
842+ continue
791843 }
792844
845+ pendingDeliveryOutputs = append (pendingDeliveryOutputs , out )
846+ }
847+
848+ // Log a summary of the transfer outputs that require proof delivery and
849+ // those that do not.
850+ reportProofTransfers (notDeliveringOutputs , pendingDeliveryOutputs )
851+
852+ deliver := func (ctx context.Context , out TransferOutput ) error {
853+ key := out .ScriptKey .PubKey
854+
793855 // We just look for the full proof in the list of final proofs
794856 // by matching the content of the proof suffix.
795857 var receiverProof * proof.AnnotatedProof
@@ -871,7 +933,7 @@ func (p *ChainPorter) transferReceiverProof(pkg *sendPackage) error {
871933 // If we have a non-interactive proof, then we'll launch several
872934 // goroutines to deliver the proof(s) to the receiver(s).
873935 instanceErrors , err := fn .ParSliceErrCollect (
874- ctx , pkg . OutboundPkg . Outputs , deliver ,
936+ ctx , pendingDeliveryOutputs , deliver ,
875937 )
876938 if err != nil {
877939 return fmt .Errorf ("error delivering proof(s): %w" , err )
0 commit comments