-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(store): allow using a specific node #2192
base: master
Are you sure you want to change the base?
Changes from all commits
c01da40
728b3c5
b6339f7
5674b0e
9c98cc4
35a8de3
83acb84
cfb397a
b9221d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,10 @@ export type IBaseProtocolSDK = { | |
readonly numPeersToUse: number; | ||
}; | ||
|
||
export type StoreProtocolOptions = { | ||
peer: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only use one peer for Store, unlike LightPush and Filter. When use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @danisharora099 , let's make it a follow up feature to not overcomplicate this PR. |
||
}; | ||
|
||
export type NetworkConfig = StaticSharding | AutoSharding; | ||
|
||
//TODO: merge this with ProtocolCreateOptions or establish distinction: https://github.com/waku-org/js-waku/issues/2048 | ||
|
@@ -106,6 +110,10 @@ export type ProtocolCreateOptions = { | |
* List of peers to use to bootstrap the node. Ignored if defaultBootstrap is set to true. | ||
*/ | ||
bootstrapPeers?: string[]; | ||
/** | ||
* Options for the Store protocol. | ||
*/ | ||
store?: Partial<StoreProtocolOptions>; | ||
}; | ||
|
||
export type Callback<T extends IDecodedMessage> = ( | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -1,7 +1,7 @@ | ||||
import type { Stream } from "@libp2p/interface"; | ||||
import { isPeerId, PeerId } from "@libp2p/interface"; | ||||
import { multiaddr, Multiaddr, MultiaddrInput } from "@multiformats/multiaddr"; | ||||
import { ConnectionManager, getHealthManager } from "@waku/core"; | ||||
import { ConnectionManager, getHealthManager, StoreCodec } from "@waku/core"; | ||||
import type { | ||||
IFilter, | ||||
IHealthManager, | ||||
|
@@ -10,6 +10,7 @@ import type { | |||
IStore, | ||||
IWaku, | ||||
Libp2p, | ||||
PeerIdStr, | ||||
ProtocolCreateOptions, | ||||
PubsubTopic | ||||
} from "@waku/interfaces"; | ||||
|
@@ -106,7 +107,16 @@ export class WakuNode implements IWaku { | |||
this.health = getHealthManager(); | ||||
|
||||
if (protocolsEnabled.store) { | ||||
const store = wakuStore(this.connectionManager); | ||||
let peerIdStr: PeerIdStr | undefined; | ||||
if (options.store?.peer) { | ||||
this.connectionManager | ||||
.dialPeer(options.store.peer, [StoreCodec]) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's not introduce this function and use js-waku/packages/sdk/src/waku/waku.ts Line 143 in 88e33a9
which does the same as I see |
||||
.catch((e) => { | ||||
log.error("Failed to dial store peer", e); | ||||
}); | ||||
} | ||||
|
||||
const store = wakuStore(this.connectionManager, { peer: peerIdStr }); | ||||
this.store = store(libp2p); | ||||
} | ||||
|
||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be a type for it in
multiaddr
packageThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danisharora099, were you able to find a type in the lib or we need to intro a new one?