chore: add debug logging gor registry query and set

This commit is contained in:
Derrick Hammer 2024-03-11 11:50:27 -04:00
parent ee6f140b7e
commit 3cce024829
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 34 additions and 0 deletions

View File

@ -1,8 +1,11 @@
package protocol package protocol
import ( import (
"git.lumeweb.com/LumeWeb/libs5-go/encoding"
"git.lumeweb.com/LumeWeb/libs5-go/internal/bases"
"git.lumeweb.com/LumeWeb/libs5-go/types" "git.lumeweb.com/LumeWeb/libs5-go/types"
"github.com/vmihailenco/msgpack/v5" "github.com/vmihailenco/msgpack/v5"
"go.uber.org/zap"
) )
var _ IncomingMessage = (*RegistryEntryRequest)(nil) var _ IncomingMessage = (*RegistryEntryRequest)(nil)
@ -50,5 +53,18 @@ func (s *RegistryEntryRequest) DecodeMessage(dec *msgpack.Decoder, message Incom
} }
func (s *RegistryEntryRequest) HandleMessage(message IncomingMessageData) error { func (s *RegistryEntryRequest) HandleMessage(message IncomingMessageData) error {
entry, err := encoding.CIDFromRegistryPublicKey(s.sre.PK())
if err != nil {
return err
}
pid, err := message.Peer.Id().ToString()
if err != nil {
return err
}
b64, err := bases.ToBase64Url(s.sre.PK())
if err != nil {
return err
}
message.Logger.Debug("Handling registry entry set request", zap.Any("entryCID", entry), zap.Any("entryBase64", b64), zap.Any("peer", pid))
return message.Mediator.RegistrySet(s.sre, false, message.Peer) return message.Mediator.RegistrySet(s.sre, false, message.Peer)
} }

View File

@ -1,8 +1,11 @@
package protocol package protocol
import ( import (
"git.lumeweb.com/LumeWeb/libs5-go/encoding"
"git.lumeweb.com/LumeWeb/libs5-go/internal/bases"
"git.lumeweb.com/LumeWeb/libs5-go/types" "git.lumeweb.com/LumeWeb/libs5-go/types"
"github.com/vmihailenco/msgpack/v5" "github.com/vmihailenco/msgpack/v5"
"go.uber.org/zap"
) )
var _ IncomingMessage = (*RegistryQuery)(nil) var _ IncomingMessage = (*RegistryQuery)(nil)
@ -52,6 +55,21 @@ func (s *RegistryQuery) DecodeMessage(dec *msgpack.Decoder, message IncomingMess
func (s *RegistryQuery) HandleMessage(message IncomingMessageData) error { func (s *RegistryQuery) HandleMessage(message IncomingMessageData) error {
mediator := message.Mediator mediator := message.Mediator
peer := message.Peer peer := message.Peer
entry, err := encoding.CIDFromRegistryPublicKey(s.pk)
if err != nil {
return err
}
pid, err := peer.Id().ToString()
if err != nil {
return err
}
b64, err := bases.ToBase64Url(s.pk)
if err != nil {
return err
}
message.Logger.Debug("Handling registry entry query request", zap.Any("entryCID", entry), zap.Any("entryBase64", b64), zap.Any("peer", pid))
sre, err := mediator.RegistryGet(s.pk) sre, err := mediator.RegistryGet(s.pk)
if err != nil { if err != nil {
return err return err