mirror of
https://github.com/status-im/status-go.git
synced 2025-01-09 06:12:55 +00:00
40359f9c1b
* Adding wakunode module * Adding wakuv2 fleet files * Add waku fleets to update-fleet-config script * Adding config items for waku v2 * Conditionally start waku v2 node depending on config * Adapting common code to use go-waku * Setting log level to info * update dependencies * update fleet config to use WakuNodes instead of BootNodes * send and receive messages * use hash returned when publishing a message * add waku store protocol * trigger signal after receiving store messages * exclude linting rule SA1019 to check deprecated packages
61 lines
2.0 KiB
Go
61 lines
2.0 KiB
Go
package gethbridge
|
|
|
|
import (
|
|
"github.com/status-im/status-go/eth-node/types"
|
|
"github.com/status-im/status-go/waku"
|
|
"github.com/status-im/status-go/wakuv2"
|
|
|
|
wakucommon "github.com/status-im/status-go/waku/common"
|
|
wakuv2common "github.com/status-im/status-go/wakuv2/common"
|
|
)
|
|
|
|
// NewWakuEnvelopeEventWrapper returns a types.EnvelopeEvent object that mimics Geth's EnvelopeEvent
|
|
func NewWakuEnvelopeEventWrapper(envelopeEvent *wakucommon.EnvelopeEvent) *types.EnvelopeEvent {
|
|
if envelopeEvent == nil {
|
|
panic("envelopeEvent should not be nil")
|
|
}
|
|
|
|
wrappedData := envelopeEvent.Data
|
|
switch data := envelopeEvent.Data.(type) {
|
|
case []wakucommon.EnvelopeError:
|
|
wrappedData := make([]types.EnvelopeError, len(data))
|
|
for index := range data {
|
|
wrappedData[index] = *NewWakuEnvelopeErrorWrapper(&data[index])
|
|
}
|
|
case *waku.MailServerResponse:
|
|
wrappedData = NewWakuMailServerResponseWrapper(data)
|
|
}
|
|
return &types.EnvelopeEvent{
|
|
Event: types.EventType(envelopeEvent.Event),
|
|
Hash: types.Hash(envelopeEvent.Hash),
|
|
Batch: types.Hash(envelopeEvent.Batch),
|
|
Peer: types.EnodeID(envelopeEvent.Peer),
|
|
Data: wrappedData,
|
|
}
|
|
}
|
|
|
|
// NewWakuV2EnvelopeEventWrapper returns a types.EnvelopeEvent object that mimics Geth's EnvelopeEvent
|
|
func NewWakuV2EnvelopeEventWrapper(envelopeEvent *wakuv2common.EnvelopeEvent) *types.EnvelopeEvent {
|
|
if envelopeEvent == nil {
|
|
panic("envelopeEvent should not be nil")
|
|
}
|
|
|
|
wrappedData := envelopeEvent.Data
|
|
switch data := envelopeEvent.Data.(type) {
|
|
case []wakuv2common.EnvelopeError:
|
|
wrappedData := make([]types.EnvelopeError, len(data))
|
|
for index := range data {
|
|
wrappedData[index] = *NewWakuV2EnvelopeErrorWrapper(&data[index])
|
|
}
|
|
case *wakuv2.MailServerResponse:
|
|
wrappedData = NewWakuV2MailServerResponseWrapper(data)
|
|
}
|
|
return &types.EnvelopeEvent{
|
|
Event: types.EventType(envelopeEvent.Event),
|
|
Hash: types.Hash(envelopeEvent.Hash),
|
|
Batch: types.Hash(envelopeEvent.Batch),
|
|
Peer: types.EnodeID(envelopeEvent.Peer),
|
|
Data: wrappedData,
|
|
}
|
|
}
|