Skip to content

Commit

Permalink
Endpoint: support CLI parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasochem committed Jul 1, 2022
1 parent 3b3a80b commit 4e977c8
Show file tree
Hide file tree
Showing 7 changed files with 495 additions and 185 deletions.
13 changes: 10 additions & 3 deletions charts/flashbake-endpoint/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,16 @@ spec:
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: TEZOS_RPC_URL
value: {{ .Values.tezos_rpc_url }}
command:
- node
- app.js
- start
- --relay_listener_port
- "{{ .Values.relay_listener_port }}"
- --tezos_rpc_url
- {{ .Values.tezos_rpc_url }}
- --baker_listener_port
- "{{ .Values.baker_listener_port }}"
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
9 changes: 9 additions & 0 deletions charts/flashbake-endpoint/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# URL to talk to Tezos RPC API
tezos_rpc_url: http://localhost:8732

# port where endpoint listens to relay connections
relay_listener_port: 11732

# port where endpoint listens to connections from the
# baker. --operations-pool argument of the baker should
# target this endpoint.
baker_listener_port: 12732


replicaCount: 1

image:
Expand Down
3 changes: 3 additions & 0 deletions flashbake-endpoint-values-0.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
tezos_rpc_url: http://flashbake-baker-0:8732/
relay_listener_port: 11732
baker_listener_port: 12732

image:
repository: localhost/flashbake
pullPolicy: IfNotPresent
Expand Down
3 changes: 3 additions & 0 deletions flashbake-endpoint-values-1.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
tezos_rpc_url: http://flashbake-baker-1:8732/
relay_listener_port: 11732
baker_listener_port: 12732

image:
repository: localhost/flashbake
pullPolicy: IfNotPresent
Expand Down
26 changes: 19 additions & 7 deletions flashbake/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import express from 'express';
import { Mempool, InMemoryMempool } from "@flashbake/relay";
import { HttpBakerEndpoint } from '@flashbake/baker-endpoint';

import yargs, { Argv } from "yargs";

function startBakerEndpoint(relayListenerPort: number, bakerListenerPort: number, rpcApiUrl: string): HttpBakerEndpoint {
const relayFacingApp = express();
Expand All @@ -19,13 +19,25 @@ function startBakerEndpoint(relayListenerPort: number, bakerListenerPort: number
return baker;
}

function main() {
const relayListenerPort = 11732;
const bakerListenerPort = 12732;
const rpcApiUrl = process.env["TEZOS_RPC_URL"] || '';
async function main() {
let argv = await yargs
.command('start', "Start flashbake-endpoint.", (yargs: Argv) => {
return yargs.option('relay_listener_port', {
describe: "Relay listener port",
type: "number",
demandOption: true,
}).option('tezos_rpc_url', {
describe: "Tezos node RPC API URL",
type: "string",
demandOption: true,
}).option('baker_listener_port', {
describe: "Baker listener port",
type: "number",
demandOption: true,
})
}).argv;

console.debug(`Using RPC API URL ${rpcApiUrl}`);
startBakerEndpoint(relayListenerPort, bakerListenerPort, rpcApiUrl);
startBakerEndpoint(argv.relay_listener_port, argv.baker_listener_port, argv.tezos_rpc_url);
}

main();
Loading

0 comments on commit 4e977c8

Please sign in to comment.