return bool if stream exists in StreamsMap GetStream

This commit is contained in:
Marten Seemann 2016-08-05 14:11:36 +07:00
parent b3e76770de
commit c3dcb649c7
2 changed files with 9 additions and 9 deletions

View file

@ -19,14 +19,14 @@ func newStreamsMap() *streamsMap {
}
}
func (m *streamsMap) GetStream(id protocol.StreamID) (*stream, error) {
func (m *streamsMap) GetStream(id protocol.StreamID) (*stream, bool) {
m.mutex.RLock()
s, ok := m.streams[id]
m.mutex.RUnlock()
if !ok {
return nil, fmt.Errorf("unknown stream: %d", id)
return nil, false
}
return s, nil
return s, true
}
func (m *streamsMap) PutStream(s *stream) error {