Get peer based on environment (#294)
* get peer based on environment * add changeset * default to prod
This commit is contained in:
parent
052154aa60
commit
b57edc9921
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@status-im/js': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
get peer based on environment
|
|
@ -1 +1,2 @@
|
||||||
PUBLIC_KEY=""
|
PUBLIC_KEY=""
|
||||||
|
ENVIRONMENT=""
|
||||||
|
|
|
@ -10,6 +10,10 @@ if (!publicKey) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const environment = process.env.ENVIRONMENT
|
||||||
|
|
||||||
export const App = () => {
|
export const App = () => {
|
||||||
return <Community publicKey={publicKey} theme="light" />
|
return (
|
||||||
|
<Community publicKey={publicKey} environment={environment} theme="light" />
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { hexToBytes } from 'ethereum-cryptography/utils'
|
import { hexToBytes } from 'ethereum-cryptography/utils'
|
||||||
import { Waku, WakuMessage } from 'js-waku'
|
import {
|
||||||
|
discovery,
|
||||||
|
getPredefinedBootstrapNodes,
|
||||||
|
Waku,
|
||||||
|
WakuMessage,
|
||||||
|
} from 'js-waku'
|
||||||
|
|
||||||
import { ApplicationMetadataMessage } from '../protos/application-metadata-message'
|
import { ApplicationMetadataMessage } from '../protos/application-metadata-message'
|
||||||
import { Account } from './account'
|
import { Account } from './account'
|
||||||
|
@ -12,7 +17,7 @@ import { handleWakuMessage } from './community/handle-waku-message'
|
||||||
|
|
||||||
export interface ClientOptions {
|
export interface ClientOptions {
|
||||||
publicKey: string
|
publicKey: string
|
||||||
env?: 'production' | 'test'
|
environment?: 'production' | 'test'
|
||||||
}
|
}
|
||||||
|
|
||||||
class Client {
|
class Client {
|
||||||
|
@ -51,13 +56,21 @@ class Client {
|
||||||
|
|
||||||
static async start(options: ClientOptions) {
|
static async start(options: ClientOptions) {
|
||||||
// Waku
|
// Waku
|
||||||
|
const fleet =
|
||||||
|
options.environment === 'test'
|
||||||
|
? discovery.predefined.Fleet.Test
|
||||||
|
: discovery.predefined.Fleet.Prod
|
||||||
|
/**
|
||||||
|
* >only connects to 1 remote node because of the limited number of nodes
|
||||||
|
* >run by Status and the limited number of connections provided by these nodes
|
||||||
|
* >
|
||||||
|
* >@see https://forum.vac.dev/t/waku-v2-scalability-studies/142/2
|
||||||
|
*/
|
||||||
|
const peers = getPredefinedBootstrapNodes(fleet)
|
||||||
const waku = await Waku.create({
|
const waku = await Waku.create({
|
||||||
bootstrap: {
|
bootstrap: {
|
||||||
default: false,
|
default: false,
|
||||||
peers: [
|
peers,
|
||||||
'/dns4/node-01.gc-us-central1-a.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmJb2e28qLXxT5kZxVUUoJt72EMzNGXB47Rxx5hw3q4YjS',
|
|
||||||
// '/dns4/node-01.do-ams3.wakuv2.test.statusim.net/tcp/8000/wss/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
relayKeepAlive: 15,
|
relayKeepAlive: 15,
|
||||||
libp2p: { config: { pubsub: { enabled: true, emitSelf: true } } },
|
libp2p: { config: { pubsub: { enabled: true, emitSelf: true } } },
|
||||||
|
|
Loading…
Reference in New Issue