@@ -138,9 +138,9 @@ func (m *StateUpdateMessageMaker) getStatesOnBlock(ctx context.Context, issuer,
138
138
return nil , nil , errors .Wrap (err , "failed to get overall states count" )
139
139
}
140
140
141
- if length .Cmp (big .NewInt (m .statesPerRequest )) = = 0 {
141
+ if length .Cmp (big .NewInt (m .statesPerRequest )) < = 0 {
142
142
// We need more states on contract. Ignore that state transition.
143
- return nil , nil , nil
143
+ return nil , nil , errors . New ( "states count less then required" )
144
144
}
145
145
146
146
length = new (big.Int ).Sub (length , big .NewInt (m .statesPerRequest ))
@@ -155,8 +155,8 @@ func (m *StateUpdateMessageMaker) getStatesOnBlock(ctx context.Context, issuer,
155
155
}
156
156
157
157
for i := 1 ; i < len (states ); i ++ {
158
- replacedState := states [0 ]
159
- latestState := states [1 ]
158
+ replacedState := states [i - 1 ]
159
+ latestState := states [i ]
160
160
if latestState .CreatedAtBlock .Cmp (block ) == 0 {
161
161
return & latestState , & replacedState , nil
162
162
}
@@ -177,9 +177,9 @@ func (m *StateUpdateMessageMaker) getGISTsOnBlock(ctx context.Context, block *bi
177
177
return nil , nil , errors .Wrap (err , "failed to get overall gists count" )
178
178
}
179
179
180
- if length .Cmp (big .NewInt (m .statesPerRequest )) = = 0 {
180
+ if length .Cmp (big .NewInt (m .statesPerRequest )) < = 0 {
181
181
// We need more states on contract. Ignore that state transition.
182
- return nil , nil , nil
182
+ return nil , nil , errors . New ( "GISTs count less then required" )
183
183
}
184
184
185
185
length = new (big.Int ).Sub (length , big .NewInt (m .statesPerRequest ))
0 commit comments