Skip to content

Commit

Permalink
chore_: remove waku api wrappers
Browse files Browse the repository at this point in the history
Removed waku api wrappers and duplicated types, also cleaned up unused
code.
  • Loading branch information
osmaczko committed Jan 10, 2025
1 parent 6dc3ce7 commit 08823a4
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 342 deletions.
110 changes: 0 additions & 110 deletions eth-node/bridge/geth/public_waku_api.go

This file was deleted.

106 changes: 0 additions & 106 deletions eth-node/bridge/geth/public_wakuv2_api.go

This file was deleted.

2 changes: 1 addition & 1 deletion eth-node/bridge/geth/waku.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func GetGethWakuFrom(m wakuinterface.Waku) *waku.Waku {
}

func (w *GethWakuWrapper) PublicWakuAPI() wakuinterface.API {
return NewGethPublicWakuAPIWrapper(waku.NewPublicWakuAPI(w.waku))
return waku.NewPublicWakuAPI(w.waku)
}

func (w *GethWakuWrapper) Version() uint {
Expand Down
2 changes: 1 addition & 1 deletion eth-node/bridge/geth/wakuv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func GetGethWakuV2From(m wakuinterface.Waku) *wakuv2.Waku {
}

func (w *gethWakuV2Wrapper) PublicWakuAPI() wakuinterface.API {
return NewGethPublicWakuV2APIWrapper(wakuv2.NewPublicWakuAPI(w.waku))
return wakuv2.NewPublicWakuAPI(w.waku)
}

func (w *gethWakuV2Wrapper) Version() uint {
Expand Down
25 changes: 12 additions & 13 deletions protocol/messenger_waku_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ import (
type testWakuWrapper struct {
*gethbridge.GethWakuWrapper

publicWakuAPIWrapper *testPublicWakuAPIWrapper
api *testAPI
}

func newTestWaku(w *waku.Waku) wakuinterface.Waku {
wrapper := gethbridge.NewGethWakuWrapper(w)
return &testWakuWrapper{
GethWakuWrapper: wrapper.(*gethbridge.GethWakuWrapper),
publicWakuAPIWrapper: newTestPublicWakuAPI(waku.NewPublicWakuAPI(w)).(*testPublicWakuAPIWrapper),
GethWakuWrapper: wrapper.(*gethbridge.GethWakuWrapper),
api: newTestAPI(waku.NewPublicWakuAPI(w)),
}
}

func (tw *testWakuWrapper) PublicWakuAPI() wakuinterface.API {
return tw.publicWakuAPIWrapper
return tw.api
}

func (tw *testWakuWrapper) SubscribePostEvents() chan *PostMessageSubscription {
subscription := make(chan *PostMessageSubscription, 100)
tw.publicWakuAPIWrapper.postSubscriptions = append(tw.publicWakuAPIWrapper.postSubscriptions, subscription)
tw.api.postSubscriptions = append(tw.api.postSubscriptions, subscription)
return subscription
}

Expand All @@ -39,21 +39,20 @@ type PostMessageSubscription struct {
msg *wakuinterface.NewMessage
}

type testPublicWakuAPIWrapper struct {
*gethbridge.GethPublicWakuAPIWrapper
type testAPI struct {
*waku.PublicWakuAPI

postSubscriptions []chan *PostMessageSubscription
}

func newTestPublicWakuAPI(api *waku.PublicWakuAPI) wakuinterface.API {
wrapper := gethbridge.NewGethPublicWakuAPIWrapper(api)
return &testPublicWakuAPIWrapper{
GethPublicWakuAPIWrapper: wrapper.(*gethbridge.GethPublicWakuAPIWrapper),
func newTestAPI(api *waku.PublicWakuAPI) *testAPI {
return &testAPI{
PublicWakuAPI: api,
}
}

func (tp *testPublicWakuAPIWrapper) Post(ctx context.Context, req wakuinterface.NewMessage) ([]byte, error) {
id, err := tp.GethPublicWakuAPIWrapper.Post(ctx, req)
func (tp *testAPI) Post(ctx context.Context, req wakuinterface.NewMessage) ([]byte, error) {
id, err := tp.PublicWakuAPI.Post(ctx, req)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 08823a4

Please sign in to comment.