]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/sp.go
Map keys existence check simplification
[nncp.git] / src / sp.go
index 84d74bbc4ab629def551545511557ab54183b5eb..5937d35e30084d5480adedf273afd2e209aa1ddf 100644 (file)
--- a/src/sp.go
+++ b/src/sp.go
@@ -932,8 +932,9 @@ func (state *SPState) StartWorkers(
                                                        logMsg(les), humanize.IBytes(uint64(n)),
                                                )
                                        })
+                               } else {
+                                       state.closeFd(pth)
                                }
-                               state.closeFd(pth)
                                payload = MarshalSP(SPTypeFile, SPFile{
                                        Hash:    freq.Hash,
                                        Offset:  freq.Offset,
@@ -1323,9 +1324,9 @@ func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) {
                        }
                        fullsize := int64(0)
                        state.RLock()
-                       infoTheir, ok := state.infosTheir[*file.Hash]
+                       infoTheir := state.infosTheir[*file.Hash]
                        state.RUnlock()
-                       if !ok {
+                       if infoTheir == nil {
                                state.Ctx.LogE("sp-file-open", lesp, err, func(les LEs) string {
                                        return logMsg(les) + ": unknown file"
                                })