cache: Avoid unlikely zero division. (#282)

This commit is contained in:
JoeGruffins 2021-08-03 18:39:02 +09:00 committed by GitHub
parent c1ba46347e
commit f9c4e03eaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@ package webapi
import (
"context"
"encoding/base64"
"errors"
"sync"
"time"
@ -78,6 +79,10 @@ func updateCache(ctx context.Context, db *database.VspDatabase,
return err
}
if bestBlock.PoolSize == 0 {
return errors.New("dcr node reports a network ticket pool size of zero")
}
cacheMtx.Lock()
defer cacheMtx.Unlock()