Skip to content

Commit 4e977c8

Browse files
committed
Endpoint: support CLI parameters
1 parent 3b3a80b commit 4e977c8

File tree

7 files changed

+495
-185
lines changed

7 files changed

+495
-185
lines changed

charts/flashbake-endpoint/templates/deployment.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,16 @@ spec:
3939
protocol: TCP
4040
resources:
4141
{{- toYaml .Values.resources | nindent 12 }}
42-
env:
43-
- name: TEZOS_RPC_URL
44-
value: {{ .Values.tezos_rpc_url }}
42+
command:
43+
- node
44+
- app.js
45+
- start
46+
- --relay_listener_port
47+
- "{{ .Values.relay_listener_port }}"
48+
- --tezos_rpc_url
49+
- {{ .Values.tezos_rpc_url }}
50+
- --baker_listener_port
51+
- "{{ .Values.baker_listener_port }}"
4552
{{- with .Values.nodeSelector }}
4653
nodeSelector:
4754
{{- toYaml . | nindent 8 }}

charts/flashbake-endpoint/values.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# URL to talk to Tezos RPC API
22
tezos_rpc_url: http://localhost:8732
33

4+
# port where endpoint listens to relay connections
5+
relay_listener_port: 11732
6+
7+
# port where endpoint listens to connections from the
8+
# baker. --operations-pool argument of the baker should
9+
# target this endpoint.
10+
baker_listener_port: 12732
11+
12+
413
replicaCount: 1
514

615
image:

flashbake-endpoint-values-0.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
tezos_rpc_url: http://flashbake-baker-0:8732/
2+
relay_listener_port: 11732
3+
baker_listener_port: 12732
4+
25
image:
36
repository: localhost/flashbake
47
pullPolicy: IfNotPresent

flashbake-endpoint-values-1.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
tezos_rpc_url: http://flashbake-baker-1:8732/
2+
relay_listener_port: 11732
3+
baker_listener_port: 12732
4+
25
image:
36
repository: localhost/flashbake
47
pullPolicy: IfNotPresent

flashbake/app.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import express from 'express';
22
import { Mempool, InMemoryMempool } from "@flashbake/relay";
33
import { HttpBakerEndpoint } from '@flashbake/baker-endpoint';
4-
4+
import yargs, { Argv } from "yargs";
55

66
function startBakerEndpoint(relayListenerPort: number, bakerListenerPort: number, rpcApiUrl: string): HttpBakerEndpoint {
77
const relayFacingApp = express();
@@ -19,13 +19,25 @@ function startBakerEndpoint(relayListenerPort: number, bakerListenerPort: number
1919
return baker;
2020
}
2121

22-
function main() {
23-
const relayListenerPort = 11732;
24-
const bakerListenerPort = 12732;
25-
const rpcApiUrl = process.env["TEZOS_RPC_URL"] || '';
22+
async function main() {
23+
let argv = await yargs
24+
.command('start', "Start flashbake-endpoint.", (yargs: Argv) => {
25+
return yargs.option('relay_listener_port', {
26+
describe: "Relay listener port",
27+
type: "number",
28+
demandOption: true,
29+
}).option('tezos_rpc_url', {
30+
describe: "Tezos node RPC API URL",
31+
type: "string",
32+
demandOption: true,
33+
}).option('baker_listener_port', {
34+
describe: "Baker listener port",
35+
type: "number",
36+
demandOption: true,
37+
})
38+
}).argv;
2639

27-
console.debug(`Using RPC API URL ${rpcApiUrl}`);
28-
startBakerEndpoint(relayListenerPort, bakerListenerPort, rpcApiUrl);
40+
startBakerEndpoint(argv.relay_listener_port, argv.baker_listener_port, argv.tezos_rpc_url);
2941
}
3042

3143
main();

0 commit comments

Comments
 (0)