Merge branch 'v0.9.0-dev' into large-reorg-logs

This commit is contained in:
stasatdaglabs 2021-01-29 10:48:24 +02:00 committed by GitHub
commit 5dfc630980
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 3 deletions

View File

@ -117,8 +117,14 @@ func handleFoundBlock(client *minerClient, block *externalapi.DomainBlock) error
rejectReason, err := client.SubmitBlock(block)
if err != nil {
if nativeerrors.Is(err, router.ErrTimeout) {
log.Warnf("Got timeout while submitting block %s to %s: %s", blockHash, client.Address(), err)
return nil
}
if rejectReason == appmessage.RejectReasonIsInIBD {
log.Warnf("Block %s was rejected because the node is in IBD", blockHash)
const waitTime = 1 * time.Second
log.Warnf("Block %s was rejected because the node is in IBD. Waiting for %s", blockHash, waitTime)
time.Sleep(waitTime)
return nil
}
return errors.Errorf("Error submitting block %s to %s: %s", blockHash, client.Address(), err)
@ -152,7 +158,7 @@ func templatesLoop(client *minerClient, miningAddr util.Address,
getBlockTemplate := func() {
template, err := client.GetBlockTemplate(miningAddr.String())
if nativeerrors.Is(err, router.ErrTimeout) {
log.Infof("Got timeout while requesting block template from %s", client.Address())
log.Warnf("Got timeout while requesting block template from %s: %s", client.Address(), err)
return
} else if err != nil {
errChan <- errors.Errorf("Error getting block template from %s: %s", client.Address(), err)

View File

@ -9,6 +9,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/peer"
"net"
"time"
)
type gRPCServer struct {
@ -61,7 +62,20 @@ func (s *gRPCServer) listenOn(listenAddr string) error {
}
func (s *gRPCServer) Stop() error {
s.server.GracefulStop()
const stopTimeout = 2 * time.Second
stopChan := make(chan interface{})
spawn("gRPCServer.Stop", func() {
s.server.GracefulStop()
close(stopChan)
})
select {
case <-stopChan:
case <-time.After(stopTimeout):
log.Warnf("Could not gracefully stop %s: timed out after %s", s.name, stopTimeout)
s.server.Stop()
}
return nil
}