@@ -128,19 +128,21 @@ func (m *machineImpl) OutputsHash(ctx context.Context) (Hash, error) {
128128
129129// Advance sends an input to the machine and processes it
130130func (m * machineImpl ) Advance (ctx context.Context , input []byte ) (bool , []Output , []Report , Hash , error ) {
131+ outputsHash := Hash {}
132+
131133 // TODO: return the exception reason
132134 accepted , outputs , reports , data , err := m .process (ctx , input , AdvanceStateRequest )
133135 if err != nil {
134- return accepted , outputs , reports , Hash {} , err
136+ return accepted , outputs , reports , outputsHash , err
135137 }
136138
137- if length := len (data ); length != HashSize {
138- err = fmt .Errorf ("%w (it has %d bytes)" , ErrHashLength , length )
139- return accepted , outputs , reports , Hash {}, err
139+ if accepted {
140+ if length := len (data ); length != HashSize {
141+ err = fmt .Errorf ("%w (it has %d bytes)" , ErrHashLength , length )
142+ return accepted , outputs , reports , outputsHash , err
143+ }
144+ copy (outputsHash [:], data )
140145 }
141-
142- var outputsHash Hash
143- copy (outputsHash [:], data )
144146 return accepted , outputs , reports , outputsHash , nil
145147}
146148
0 commit comments