Browse Source

light: avert a data race (#7888)

pull/7874/head
M. J. Fromberger 3 years ago
committed by GitHub
parent
commit
a185163c57
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions
  1. +2
    -3
      light/detector.go

+ 2
- 3
light/detector.go View File

@ -26,6 +26,8 @@ import (
// If there are no conflictinge headers, the light client deems the verified target header
// trusted and saves it to the trusted store.
func (c *Client) detectDivergence(ctx context.Context, primaryTrace []*types.LightBlock, now time.Time) error {
c.providerMutex.Lock()
defer c.providerMutex.Unlock()
if len(c.witnesses) < 1 {
return nil
}
@ -40,9 +42,6 @@ func (c *Client) detectDivergence(ctx context.Context, primaryTrace []*types.Lig
c.logger.Debug("running detector against trace", "endBlockHeight", lastVerifiedHeader.Height,
"endBlockHash", lastVerifiedHeader.Hash, "length", len(primaryTrace))
c.providerMutex.Lock()
defer c.providerMutex.Unlock()
// launch one goroutine per witness to retrieve the light block of the target height
// and compare it with the header from the primary
errc := make(chan error, len(c.witnesses))


Loading…
Cancel
Save