Fix: wrong pins metric when batching enabled

When batching is enabled, the "batchingstate" is used to add/remove pins, but the
non-batching state is used as read-only state for doing List().

This means that both states will be writing pins metrics but the batching
state is never used for List(), so it never has the right total number.

This fixes that.
This commit is contained in:
Hector Sanjuan 2022-04-25 23:45:34 +02:00
parent cc40a37daa
commit 6716f5471a

View File

@ -583,6 +583,9 @@ func (css *Consensus) State(ctx context.Context) (state.ReadOnly, error) {
case <-css.ctx.Done(): case <-css.ctx.Done():
return nil, css.ctx.Err() return nil, css.ctx.Err()
case <-css.stateReady: case <-css.stateReady:
if css.config.batchingEnabled() {
return css.batchingState, nil
}
return css.state, nil return css.state, nil
} }
} }