Merge remote-tracking branch 'origin/master' into Maintenance_Tests

This commit is contained in:
aya 2025-04-08 20:42:58 +02:00
commit 05255eeeeb
3 changed files with 36 additions and 22 deletions

View File

@ -15,7 +15,7 @@ type Envelope struct {
hash MessageHash
}
type tmpWakuMessageJson struct {
type wakuMessage struct {
Payload []byte `json:"payload,omitempty"`
ContentTopic string `json:"contentTopic,omitempty"`
Version *uint32 `json:"version,omitempty"`
@ -25,32 +25,32 @@ type tmpWakuMessageJson struct {
RateLimitProof []byte `json:"proof,omitempty"`
}
type tmpEnvelopeStruct struct {
WakuMessage tmpWakuMessageJson `json:"wakuMessage"`
PubsubTopic string `json:"pubsubTopic"`
MessageHash MessageHash `json:"messageHash"`
type wakuEnvelope struct {
WakuMessage wakuMessage `json:"wakuMessage"`
PubsubTopic string `json:"pubsubTopic"`
MessageHash MessageHash `json:"messageHash"`
}
// NewEnvelope creates a new Envelope from a json string generated in nwaku
func NewEnvelope(jsonEventStr string) (*Envelope, error) {
tmpEnvelopeStruct := tmpEnvelopeStruct{}
err := json.Unmarshal([]byte(jsonEventStr), &tmpEnvelopeStruct)
wakuEnvelope := wakuEnvelope{}
err := json.Unmarshal([]byte(jsonEventStr), &wakuEnvelope)
if err != nil {
return nil, err
}
return &Envelope{
msg: &pb.WakuMessage{
Payload: tmpEnvelopeStruct.WakuMessage.Payload,
ContentTopic: tmpEnvelopeStruct.WakuMessage.ContentTopic,
Version: tmpEnvelopeStruct.WakuMessage.Version,
Timestamp: tmpEnvelopeStruct.WakuMessage.Timestamp,
Meta: tmpEnvelopeStruct.WakuMessage.Meta,
Ephemeral: tmpEnvelopeStruct.WakuMessage.Ephemeral,
RateLimitProof: tmpEnvelopeStruct.WakuMessage.RateLimitProof,
Payload: wakuEnvelope.WakuMessage.Payload,
ContentTopic: wakuEnvelope.WakuMessage.ContentTopic,
Version: wakuEnvelope.WakuMessage.Version,
Timestamp: wakuEnvelope.WakuMessage.Timestamp,
Meta: wakuEnvelope.WakuMessage.Meta,
Ephemeral: wakuEnvelope.WakuMessage.Ephemeral,
RateLimitProof: wakuEnvelope.WakuMessage.RateLimitProof,
},
topic: tmpEnvelopeStruct.PubsubTopic,
hash: tmpEnvelopeStruct.MessageHash,
topic: wakuEnvelope.PubsubTopic,
hash: wakuEnvelope.MessageHash,
}, nil
}

View File

@ -14,9 +14,9 @@ type StoreQueryRequest struct {
}
type StoreMessageResponse struct {
WakuMessage *tmpWakuMessageJson `json:"message"`
PubsubTopic string `json:"pubsubTopic"`
MessageHash MessageHash `json:"messageHash"`
WakuMessage *wakuMessage `json:"message"`
PubsubTopic string `json:"pubsubTopic"`
MessageHash MessageHash `json:"messageHash"`
}
type StoreQueryResponse struct {

View File

@ -484,7 +484,11 @@ func (n *WakuNode) parseMessageEvent(eventStr string) {
if err != nil {
Error("could not parse message %v", err)
}
n.MsgChan <- *envelope
select {
case n.MsgChan <- *envelope:
default:
Warn("Can't deliver message to subscription, MsgChan is full")
}
}
func (n *WakuNode) parseTopicHealthChangeEvent(eventStr string) {
@ -494,7 +498,12 @@ func (n *WakuNode) parseTopicHealthChangeEvent(eventStr string) {
if err != nil {
Error("could not parse topic health change %v", err)
}
n.TopicHealthChan <- topicHealth
select {
case n.TopicHealthChan <- topicHealth:
default:
Warn("Can't deliver topic health event, TopicHealthChan is full")
}
}
func (n *WakuNode) parseConnectionChangeEvent(eventStr string) {
@ -504,7 +513,12 @@ func (n *WakuNode) parseConnectionChangeEvent(eventStr string) {
if err != nil {
Error("could not parse connection change %v", err)
}
n.ConnectionChangeChan <- connectionChange
select {
case n.ConnectionChangeChan <- connectionChange:
default:
Warn("Can't deliver connection change event, ConnectionChangeChan is full")
}
}
func (n *WakuNode) GetNumConnectedRelayPeers(optPubsubTopic ...string) (int, error) {