Merge remote-tracking branch 'origin/2650-feature-federation-harmonize-and-sync-modules-of-federation' into 2501-feature-federation-implement-a-graphql-client-to-request-getpublickey

This commit is contained in:
Claus-Peter Hübner 2023-02-13 21:13:44 +01:00
commit e3284f4659
2 changed files with 5 additions and 11 deletions

View File

@ -44,11 +44,10 @@ const lookupResultMock = {
token: Buffer.from(TEST_TOPIC),
from: {
id: Buffer.from('somone'),
foreign: true,
host: '188.95.53.5',
port: 63561,
},
to: { id: null, foreign: true, host: '83.53.31.27', port: 55723 },
to: { id: null, host: '83.53.31.27', port: 55723 },
peers: [
{
publicKey: Buffer.from('some-public-key'),

View File

@ -189,11 +189,9 @@ export const startDHT = async (topic: string): Promise<void> => {
}
async function writeHomeCommunityEnries(pubKey: any): Promise<CommunityApi[]> {
const homeApiVersions: CommunityApi[] = Object.values(ApiVersionType).map(function (
apiEnum,
idx,
) {
const port = Number.parseInt(CONFIG.FEDERATION_COMMUNITY_API_PORT) + idx + 1
const homeApiVersions: CommunityApi[] = Object.values(ApiVersionType).map(function (apiEnum) {
const port =
Number.parseInt(CONFIG.FEDERATION_COMMUNITY_API_PORT) + Number(apiEnum.replace('_', ''))
const comApi: CommunityApi = {
api: apiEnum,
url: CONFIG.FEDERATION_COMMUNITY_URL + ':' + port.toString() + '/api/',
@ -202,10 +200,7 @@ async function writeHomeCommunityEnries(pubKey: any): Promise<CommunityApi[]> {
})
try {
// first remove privious existing homeCommunity entries
const homeComs = await DbCommunity.find({ foreign: false })
if (homeComs.length > 0) {
await DbCommunity.remove(homeComs)
}
DbCommunity.createQueryBuilder().delete().where({ foreign: false }).execute()
homeApiVersions.forEach(async function (homeApi) {
const homeCom = new DbCommunity()