Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/discovery-platform/db.schema
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ T registered_nodes (
chain_id integer
hoprd_api_endpoint
hoprd_api_token
(exit_node_pub_key)
(exit_app_pub_key)
(exit_app_target)
Comment thread
esterlus marked this conversation as resolved.
native_address character
timestamps
);
Expand Down Expand Up @@ -198,4 +199,4 @@ T webhook_logs (
event_type (example: subscription/created)
event_data (JSONB of entire payload)
created_at
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable camelcase */

exports.up = (pgm) => {
pgm.addColumn('registered_nodes', {
exit_app_target: { type: 'varchar(255)' },
});
pgm.renameColumn('registered_nodes', 'exit_node_pub_key', 'exit_app_pub_key');
};

exports.down = (pgm) => {
pgm.renameColumn('registered_nodes', 'exit_app_pub_key', 'exit_node_pub_key');
pgm.dropColumns('registered_nodes', ['exit_app_target']);
};
10 changes: 5 additions & 5 deletions apps/discovery-platform/src/node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ describe('node', function () {

const nodes = [
'insert into registered_nodes',
'(id, is_exit_node, chain_id, hoprd_api_endpoint, hoprd_api_token, exit_node_pub_key, native_address)',
"values (gen_random_uuid(), false, 100, 'http://endpoint1', 'token1', 'pubkey1', 'address1'),",
"(gen_random_uuid(), false, 100, 'http://endpoint2', 'token2', 'pubkey2', 'address2'),",
"(gen_random_uuid(), true, 100, 'http://endpoint3', 'token3', 'pubkey3', 'address3'),",
"(gen_random_uuid(), true, 100, 'http://endpoint4', 'token4', 'pubkey4', 'address4')",
'(id, is_exit_node, chain_id, hoprd_api_endpoint, hoprd_api_token, exit_app_pub_key, exit_app_target, native_address)',
"values (gen_random_uuid(), false, 100, 'http://endpoint1', 'token1', 'pubkey1', 'pubtarget1:1234', 'address1'),",
"(gen_random_uuid(), false, 100, 'http://endpoint2', 'token2', 'pubkey2', 'pubtarget2:1234', 'address2'),",
"(gen_random_uuid(), true, 100, 'http://endpoint3', 'token3', 'pubkey3', 'pubtarget3:1234', 'address3'),",
"(gen_random_uuid(), true, 100, 'http://endpoint4', 'token4', 'pubkey4', 'pubtarget4:1234', 'address4')",
].join(' ');
const users = "insert into users (id, name) values (gen_random_uuid(), 'user1')";
const clients = [
Expand Down
9 changes: 6 additions & 3 deletions apps/discovery-platform/src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type EntryNode = {
export type ExitNode = {
id: string;
pubKey: string;
target: string;
};

type DBPairing = {
Expand All @@ -32,7 +33,8 @@ type DBEntryNode = {

type DBExitNode = {
id: string;
exit_node_pub_key: string;
exit_app_pub_key: string;
exit_app_target: string;
};

export function createToken(dbPool: Pool, nodeId: string): Promise<{ accessToken: string }[]> {
Expand Down Expand Up @@ -62,7 +64,7 @@ export function listExitNodes(dbPool: Pool, nodeIds: Iterable<string>): Promise<
const qIds = Array.from(nodeIds)
.map((i) => `'${i}'`)
.join(',');
const q = `select id, exit_node_pub_key from registered_nodes where id in (${qIds})`;
const q = `select id, exit_app_pub_key, exit_app_target from registered_nodes where id in (${qIds})`;
return dbPool.query(q).then((r) => r.rows.map(exitNodeFromDB));
}

Expand Down Expand Up @@ -118,7 +120,8 @@ function entryNodeFromDB(db: DBEntryNode): EntryNode {
function exitNodeFromDB(db: DBExitNode): ExitNode {
return {
id: db.id,
pubKey: db.exit_node_pub_key,
pubKey: db.exit_app_pub_key,
target: db.exit_app_target,
};
}

Expand Down