try using dht if DHT_TOPIC is set in .env

This commit is contained in:
Moriz Wahl 2022-05-04 19:29:14 +02:00
parent e2efd0da9d
commit d514886728
2 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,12 @@
import DHT from '@hyperswarm/dht'
import { Connection } from '@dbTools/typeorm'
const POLLTIME = 20000
const SUCCESSTIME = 120000
const ERRORTIME = 240000
const ANNOUNCETIME = 30000
export const startDHT = async (connection: Connection, topic: string): Promise<void> => {
console.log('topic', topic, typeof topic)
// const TOPIC = DHT.hash(Buffer.from(topic))
}

View File

@ -22,6 +22,9 @@ import schema from '@/graphql/schema'
import { elopageWebhook } from '@/webhook/elopage' import { elopageWebhook } from '@/webhook/elopage'
import { Connection } from '@dbTools/typeorm' import { Connection } from '@dbTools/typeorm'
// DHT
import { startDHT } from '@/federation/index'
// TODO implement // TODO implement
// import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity"; // import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity";
@ -41,6 +44,12 @@ const createServer = async (context: any = serverContext): Promise<ServerDef> =>
throw new Error('Fatal: Database Version incorrect') throw new Error('Fatal: Database Version incorrect')
} }
// start DHT hyperswarm when DHT_TOPIC is set in .env
if (CONFIG.DHT_TOPIC) {
console.log('Starting hyperswarm DHT')
await startDHT(con, CONFIG.DHT_TOPIC)
}
// Express Server // Express Server
const app = express() const app = express()