feat: add function to obtain bloomfilter (#2334)
This commit is contained in:
parent
fe086b2fdd
commit
842ba229df
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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
|
||||
// -----
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue