2024-10-15 15:48:15 -04:00
|
|
|
package missing
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"github.com/libp2p/go-libp2p/core/peer"
|
|
|
|
|
"github.com/waku-org/go-waku/waku/v2/api/common"
|
|
|
|
|
"github.com/waku-org/go-waku/waku/v2/protocol/pb"
|
|
|
|
|
"github.com/waku-org/go-waku/waku/v2/protocol/store"
|
2024-10-24 14:47:57 -04:00
|
|
|
storepb "github.com/waku-org/go-waku/waku/v2/protocol/store/pb"
|
2024-10-15 15:48:15 -04:00
|
|
|
)
|
|
|
|
|
|
2024-10-24 14:47:57 -04:00
|
|
|
func NewDefaultStorenodeRequestor(store *store.WakuStore) common.StorenodeRequestor {
|
2024-10-15 15:48:15 -04:00
|
|
|
return &defaultStorenodeRequestor{
|
|
|
|
|
store: store,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type defaultStorenodeRequestor struct {
|
|
|
|
|
store *store.WakuStore
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-13 12:15:44 -04:00
|
|
|
func (d *defaultStorenodeRequestor) GetMessagesByHash(ctx context.Context, peerInfo peer.AddrInfo, pageSize uint64, messageHashes []pb.MessageHash) (common.StoreRequestResult, error) {
|
|
|
|
|
return d.store.QueryByHash(ctx, messageHashes, store.WithPeerAddr(peerInfo.Addrs...), store.WithPaging(false, pageSize))
|
2024-10-15 15:48:15 -04:00
|
|
|
}
|
|
|
|
|
|
2025-03-13 12:15:44 -04:00
|
|
|
func (d *defaultStorenodeRequestor) Query(ctx context.Context, peerInfo peer.AddrInfo, storeQueryRequest *storepb.StoreQueryRequest) (common.StoreRequestResult, error) {
|
|
|
|
|
return d.store.RequestRaw(ctx, peerInfo, storeQueryRequest)
|
2024-10-15 15:48:15 -04:00
|
|
|
}
|