@@ -63,31 +63,34 @@ func (context *asyncContext) complete() error {
6363 return nil
6464 }
6565
66+ gasToAccumulate := context .gasAccumulated
67+ notifyChildComplete := true
6668 currentCallID := context .GetCallID ()
67- if context .callType == vm .AsynchronousCall {
69+ switch context .callType {
70+ case vm .AsynchronousCall :
6871 vmOutput := context .childResults
69- isCallbackComplete , _ , err : = context .callCallback (currentCallID , vmOutput , nil )
72+ notifyChildComplete , _ , err = context .callCallback (currentCallID , vmOutput , nil )
7073 if err != nil {
7174 return err
7275 }
73- if isCallbackComplete {
74- return context .NotifyChildIsComplete (currentCallID , 0 )
75- }
76- } else if context .callType == vm .AsynchronousCallBack {
76+ gasToAccumulate = 0
77+ case vm .AsynchronousCallBack :
7778 err = context .LoadParentContext ()
7879 if err != nil {
7980 return err
8081 }
8182
82- currentCallID := context .GetCallerCallID ()
83- return context .NotifyChildIsComplete (currentCallID , context .gasAccumulated )
84- } else if context .callType == vm .DirectCall {
83+ currentCallID = context .GetCallerCallID ()
84+ case vm .DirectCall :
8585 err = context .LoadParentContext ()
8686 if err != nil {
8787 return err
8888 }
89+ currentCallID = nil
90+ }
8991
90- return context .NotifyChildIsComplete (nil , context .gasAccumulated )
92+ if notifyChildComplete {
93+ return context .NotifyChildIsComplete (currentCallID , gasToAccumulate )
9194 }
9295
9396 return nil
0 commit comments