diff --git a/eth-node/bridge/geth/public_waku_api.go b/eth-node/bridge/geth/public_waku_api.go index 8ff725b8e..6d04b6f47 100644 --- a/eth-node/bridge/geth/public_waku_api.go +++ b/eth-node/bridge/geth/public_waku_api.go @@ -59,6 +59,10 @@ func (w *gethPublicWakuAPIWrapper) NewMessageFilter(req types.Criteria) (string, return w.api.NewMessageFilter(criteria) } +func (w *gethPublicWakuAPIWrapper) BloomFilter() []byte { + return w.api.BloomFilter() +} + // GetFilterMessages returns the messages that match the filter criteria and // are received between the last poll and now. func (w *gethPublicWakuAPIWrapper) GetFilterMessages(id string) ([]*types.Message, error) { diff --git a/eth-node/bridge/geth/public_wakuv2_api.go b/eth-node/bridge/geth/public_wakuv2_api.go index e76527336..e3c2b2cf4 100644 --- a/eth-node/bridge/geth/public_wakuv2_api.go +++ b/eth-node/bridge/geth/public_wakuv2_api.go @@ -40,6 +40,10 @@ func (w *gethPublicWakuV2APIWrapper) DeleteKeyPair(ctx context.Context, key stri return w.api.DeleteKeyPair(ctx, key) } +func (w *gethPublicWakuV2APIWrapper) BloomFilter() []byte { + return w.api.BloomFilter() +} + // NewMessageFilter creates a new filter that can be used to poll for // (new) messages that satisfy the given criteria. func (w *gethPublicWakuV2APIWrapper) NewMessageFilter(req types.Criteria) (string, error) { diff --git a/eth-node/types/rpc.go b/eth-node/types/rpc.go index 3ee868804..650ee671c 100644 --- a/eth-node/types/rpc.go +++ b/eth-node/types/rpc.go @@ -62,6 +62,8 @@ type PublicWhisperAPI interface { // GetFilterMessages returns the messages that match the filter criteria and // are received between the last poll and now. GetFilterMessages(id string) ([]*Message, error) + // BloomFilter returns the current bloomfilter of the node + BloomFilter() []byte } // PublicWakuAPI provides the waku RPC service that can be @@ -84,4 +86,6 @@ type PublicWakuAPI interface { // GetFilterMessages returns the messages that match the filter criteria and // are received between the last poll and now. GetFilterMessages(id string) ([]*Message, error) + + BloomFilter() []byte } diff --git a/protocol/messenger.go b/protocol/messenger.go index 1b055b1e8..f363d920f 100644 --- a/protocol/messenger.go +++ b/protocol/messenger.go @@ -4405,3 +4405,7 @@ func (m *Messenger) getOrBuildContactFromMessage(msg *common.Message) (*Contact, m.allContacts.Store(msg.From, c) return c, nil } + +func (m *Messenger) BloomFilter() []byte { + return m.transport.BloomFilter() +} diff --git a/protocol/transport/transport.go b/protocol/transport/transport.go index 188944021..f3058ff5c 100644 --- a/protocol/transport/transport.go +++ b/protocol/transport/transport.go @@ -578,6 +578,10 @@ func (t *Transport) ClearProcessedMessageIDsCache() error { return t.cache.Clear() } +func (t *Transport) BloomFilter() []byte { + return t.api.BloomFilter() +} + func PubkeyToHex(key *ecdsa.PublicKey) string { return types.EncodeHex(crypto.FromECDSAPub(key)) } diff --git a/services/ext/api.go b/services/ext/api.go index 22ce5a91b..12e83d086 100644 --- a/services/ext/api.go +++ b/services/ext/api.go @@ -8,6 +8,7 @@ import ( "math/big" "time" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/rlp" @@ -879,6 +880,11 @@ func (api *PublicAPI) SyncChatFromSyncedFrom(chatID string) (uint32, error) { return api.service.messenger.SyncChatFromSyncedFrom(chatID) } +// BloomFilter returns the current bloom filter bytes +func (api *PublicAPI) BloomFilter() string { + return hexutil.Encode(api.service.messenger.BloomFilter()) +} + // ----- // HELPER // ----- diff --git a/waku/api.go b/waku/api.go index dee7d1251..3f8226051 100644 --- a/waku/api.go +++ b/waku/api.go @@ -97,6 +97,10 @@ func (api *PublicWakuAPI) SetBloomFilter(ctx context.Context, bloom hexutil.Byte return true, api.w.SetBloomFilter(bloom) } +func (api *PublicWakuAPI) BloomFilter() []byte { + return api.w.BloomFilter() +} + // MarkTrustedPeer marks a peer trusted, which will allow it to send historic (expired) messages. // Note: This function is not adding new nodes, the node needs to exists as a peer. func (api *PublicWakuAPI) MarkTrustedPeer(ctx context.Context, url string) (bool, error) { diff --git a/wakuv2/api.go b/wakuv2/api.go index 5173e0ac2..b1cf3aa7e 100644 --- a/wakuv2/api.go +++ b/wakuv2/api.go @@ -164,6 +164,10 @@ func (api *PublicWakuAPI) DeleteSymKey(ctx context.Context, id string) bool { return api.w.DeleteSymKey(id) } +func (api *PublicWakuAPI) BloomFilter() []byte { + return nil +} + //go:generate gencodec -type NewMessage -field-override newMessageOverride -out gen_newmessage_json.go // NewMessage represents a new waku message that is posted through the RPC.