2023-01-06 12:21:14 +00:00
|
|
|
package pairing
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2023-02-28 12:32:45 +00:00
|
|
|
"github.com/status-im/status-go/protocol/protobuf"
|
|
|
|
|
2023-01-06 12:21:14 +00:00
|
|
|
"github.com/status-im/status-go/protocol/common"
|
|
|
|
)
|
|
|
|
|
|
|
|
type RawMessageCollector struct {
|
|
|
|
rawMessages []*common.RawMessage
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RawMessageCollector) dispatchMessage(_ context.Context, rawMessage common.RawMessage) (common.RawMessage, error) {
|
|
|
|
r.rawMessages = append(r.rawMessages, &rawMessage)
|
|
|
|
return rawMessage, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RawMessageCollector) getRawMessages() []*common.RawMessage {
|
|
|
|
return r.rawMessages
|
|
|
|
}
|
2023-02-28 12:32:45 +00:00
|
|
|
|
|
|
|
func (r *RawMessageCollector) convertToSyncRawMessage() *protobuf.SyncRawMessage {
|
|
|
|
syncRawMessage := new(protobuf.SyncRawMessage)
|
|
|
|
for _, m := range r.getRawMessages() {
|
|
|
|
rawMessage := new(protobuf.RawMessage)
|
|
|
|
rawMessage.Payload = m.Payload
|
|
|
|
rawMessage.MessageType = m.MessageType
|
|
|
|
syncRawMessage.RawMessages = append(syncRawMessage.RawMessages, rawMessage)
|
|
|
|
}
|
|
|
|
return syncRawMessage
|
|
|
|
}
|