make lock methods private

This commit is contained in:
vyzo 2019-05-17 23:41:05 +03:00
parent 28b1a9f31d
commit 07ee3fb062

View File

@ -20,25 +20,25 @@ func NewProtoBook(meta pstore.PeerMetadata) pstore.ProtoBook {
return &dsProtoBook{meta: meta}
}
func (pb *dsProtoBook) Lock(p peer.ID) {
func (pb *dsProtoBook) lock(p peer.ID) {
pb.lks[byte(p[len(p)-1])].Lock()
}
func (pb *dsProtoBook) Unlock(p peer.ID) {
func (pb *dsProtoBook) unlock(p peer.ID) {
pb.lks[byte(p[len(p)-1])].Unlock()
}
func (pb *dsProtoBook) RLock(p peer.ID) {
func (pb *dsProtoBook) rlock(p peer.ID) {
pb.lks[byte(p[len(p)-1])].RLock()
}
func (pb *dsProtoBook) RUnlock(p peer.ID) {
func (pb *dsProtoBook) runlock(p peer.ID) {
pb.lks[byte(p[len(p)-1])].RUnlock()
}
func (pb *dsProtoBook) SetProtocols(p peer.ID, protos ...string) error {
pb.Lock(p)
defer pb.Unlock(p)
pb.lock(p)
defer pb.unlock(p)
protomap := make(map[string]struct{}, len(protos))
for _, proto := range protos {
@ -49,8 +49,8 @@ func (pb *dsProtoBook) SetProtocols(p peer.ID, protos ...string) error {
}
func (pb *dsProtoBook) AddProtocols(p peer.ID, protos ...string) error {
pb.Lock(p)
defer pb.Unlock(p)
pb.lock(p)
defer pb.unlock(p)
pmap, err := pb.getProtocolMap(p)
if err != nil {
@ -65,8 +65,8 @@ func (pb *dsProtoBook) AddProtocols(p peer.ID, protos ...string) error {
}
func (pb *dsProtoBook) GetProtocols(p peer.ID) ([]string, error) {
pb.RLock(p)
defer pb.RUnlock(p)
pb.rlock(p)
defer pb.runlock(p)
pmap, err := pb.getProtocolMap(p)
if err != nil {
@ -82,8 +82,8 @@ func (pb *dsProtoBook) GetProtocols(p peer.ID) ([]string, error) {
}
func (pb *dsProtoBook) SupportsProtocols(p peer.ID, protos ...string) ([]string, error) {
pb.RLock(p)
defer pb.RUnlock(p)
pb.rlock(p)
defer pb.runlock(p)
pmap, err := pb.getProtocolMap(p)
if err != nil {