feat: Waku v2 bridge

Issue #12610
This commit is contained in:
Michal Iskierko
2023-11-12 13:29:38 +01:00
parent 56e7bd01ca
commit 6d31343205
6716 changed files with 1982502 additions and 5891 deletions
+25
View File
@@ -0,0 +1,25 @@
package wakuv2ext
import (
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/services/ext"
)
// PublicAPI extends waku public API.
type PublicAPI struct {
*ext.PublicAPI
service *Service
publicAPI types.PublicWakuAPI
log log.Logger
}
// NewPublicAPI returns instance of the public API.
func NewPublicAPI(s *Service) *PublicAPI {
return &PublicAPI{
PublicAPI: ext.NewPublicAPI(s.Service, s.w),
service: s,
publicAPI: s.w.PublicWakuAPI(),
log: log.New("package", "status-go/services/wakuext.PublicAPI"),
}
}
+50
View File
@@ -0,0 +1,50 @@
package wakuv2ext
import (
"github.com/syndtr/goleveldb/leveldb"
gethrpc "github.com/ethereum/go-ethereum/rpc"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/params"
"github.com/status-im/status-go/rpc"
"github.com/status-im/status-go/services/ext"
)
type Service struct {
*ext.Service
w types.Waku
}
func New(config params.NodeConfig, n types.Node, rpcClient *rpc.Client, handler ext.EnvelopeEventsHandler, ldb *leveldb.DB) *Service {
w, err := n.GetWakuV2(nil)
if err != nil {
panic(err)
}
delay := ext.DefaultRequestsDelay
if config.ShhextConfig.RequestsDelay != 0 {
delay = config.ShhextConfig.RequestsDelay
}
requestsRegistry := ext.NewRequestsRegistry(delay)
mailMonitor := ext.NewMailRequestMonitor(w, handler, requestsRegistry)
return &Service{
Service: ext.New(config, n, rpcClient, ldb, mailMonitor, w),
w: w,
}
}
func (s *Service) PublicWakuAPI() types.PublicWakuAPI {
return s.w.PublicWakuAPI()
}
// APIs returns a list of new APIs.
func (s *Service) APIs() []gethrpc.API {
apis := []gethrpc.API{
{
Namespace: "wakuext",
Version: "1.0",
Service: NewPublicAPI(s),
Public: false,
},
}
return apis
}