Fix EOF error in gRPC state-sync (#489)

* Fix EOF error in gRPC state-sync

* linters

Co-authored-by: Evgeny Danienko <6655321@bk.ru>
This commit is contained in:
Krishna Upadhyaya 2022-08-11 23:10:08 +05:30 committed by GitHub
parent 1d1f00cbe7
commit 72aa44efe6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,11 +2,13 @@ package heimdallgrpc
import (
"context"
proto "github.com/maticnetwork/polyproto/heimdall"
"errors"
"io"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/bor/clerk"
proto "github.com/maticnetwork/polyproto/heimdall"
)
func (h *HeimdallGRPCClient) StateSyncEvents(ctx context.Context, fromID uint64, to int64) ([]*clerk.EventRecordWithTime, error) {
@ -31,8 +33,12 @@ func (h *HeimdallGRPCClient) StateSyncEvents(ctx context.Context, fromID uint64,
for {
events, err = res.Recv()
if errors.Is(err, io.EOF) {
return eventRecords, nil
}
if err != nil {
break
return nil, err
}
for _, event := range events.Result {
@ -50,6 +56,4 @@ func (h *HeimdallGRPCClient) StateSyncEvents(ctx context.Context, fromID uint64,
eventRecords = append(eventRecords, eventRecord)
}
}
return eventRecords, err
}