Skip to content

Commit

Permalink
fixed indexes in states search
Browse files Browse the repository at this point in the history
  • Loading branch information
olegfomenko committed Dec 5, 2023
1 parent 8500f4f commit 9b1ee87
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/rarimo/stateupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ func (m *StateUpdateMessageMaker) getStatesOnBlock(ctx context.Context, issuer,
return nil, nil, errors.Wrap(err, "failed to get overall states count")
}

if length.Cmp(big.NewInt(m.statesPerRequest)) == 0 {
if length.Cmp(big.NewInt(m.statesPerRequest)) <= 0 {
// We need more states on contract. Ignore that state transition.
return nil, nil, nil
return nil, nil, errors.New("states count less then required")
}

length = new(big.Int).Sub(length, big.NewInt(m.statesPerRequest))
Expand All @@ -155,8 +155,8 @@ func (m *StateUpdateMessageMaker) getStatesOnBlock(ctx context.Context, issuer,
}

for i := 1; i < len(states); i++ {
replacedState := states[0]
latestState := states[1]
replacedState := states[i-1]
latestState := states[i]
if latestState.CreatedAtBlock.Cmp(block) == 0 {
return &latestState, &replacedState, nil
}
Expand All @@ -177,9 +177,9 @@ func (m *StateUpdateMessageMaker) getGISTsOnBlock(ctx context.Context, block *bi
return nil, nil, errors.Wrap(err, "failed to get overall gists count")
}

if length.Cmp(big.NewInt(m.statesPerRequest)) == 0 {
if length.Cmp(big.NewInt(m.statesPerRequest)) <= 0 {
// We need more states on contract. Ignore that state transition.
return nil, nil, nil
return nil, nil, errors.New("GISTs count less then required")
}

length = new(big.Int).Sub(length, big.NewInt(m.statesPerRequest))
Expand Down

0 comments on commit 9b1ee87

Please sign in to comment.