First entity ID is always a duplicate
I've noticed this issue happening for a while and just got around to filing an issue. The first entity ID on any getScrutinizerEntities
request is always duplicated. This is not just a problem with the api call, Scrutinizer.EntityList()
has this same behavior. I believe this is because of #307 (closed). The first time iter.Next() is called on the kv store, rewind() is also called, so that the first item is repeated.
SO I think the fix would be removing the whole
if i.first {
// For the first element, we only rewind.
// Don't call iter.Next, as that would skip the first element
// entirely.
i.Iter.Rewind()
i.first = false
at https://gitlab.com/vocdoni/go-dvote/-/blob/master/db/badger.go#L127
Example behavior:
natewilliams:go-dvote 🐓 echo '{"method": "getScrutinizerEntities","timestamp": 1556110671,}' | go run cmd/testclient/testclient.go -host=wss://gw2.dev.vocdoni.net/dvote
EntityIDs: [182935eb9152ff79a26d8b97c2fcc7413543c64a 182935eb9152ff79a26d8b97c2fcc7413543c64a e1e9dded6f1f2b63d96b64f4789744737f34198f]
Ok: true
Request: 216
Timestamp: 1603720633