Skip to content

Commit

Permalink
Merge "[FAB-3335] Gossip pull may send zero-length digests"
Browse files Browse the repository at this point in the history
  • Loading branch information
christo4ferris authored and Gerrit Code Review committed Apr 22, 2017
2 parents d39dee5 + 9b5c180 commit 88ac3ba
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions gossip/gossip/algo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,17 @@ func (engine *PullEngine) OnHello(nonce uint64, context interface{}) {
})

a := engine.state.ToArray()
digest := make([]string, len(a))
var digest []string
filter := engine.digFilter(context)
for i, item := range a {
for _, item := range a {
dig := item.(string)
if !filter(dig) {
continue
}
digest[i] = dig
digest = append(digest, dig)
}
if len(digest) == 0 {
return
}
engine.SendDigest(digest, nonce, context)
}
Expand All @@ -309,6 +312,7 @@ func (engine *PullEngine) OnReq(items []string, nonce uint64, context interface{
return
}
engine.lock.Lock()
defer engine.lock.Unlock()

filter := engine.digFilter(context)
var items2Send []string
Expand All @@ -318,7 +322,9 @@ func (engine *PullEngine) OnReq(items []string, nonce uint64, context interface{
}
}

engine.lock.Unlock()
if len(items2Send) == 0 {
return
}

go engine.SendRes(items2Send, context, nonce)
}
Expand Down

0 comments on commit 88ac3ba

Please sign in to comment.