summaryrefslogtreecommitdiff
path: root/packages/taler-util/src
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-02-09 22:44:36 +0100
committerFlorian Dold <florian@dold.me>2023-02-10 00:07:33 +0100
commit3cf2d4cba919203065f210f80f3f081948ad257a (patch)
treeb5f6e80f800cffbb59c0c7cf0b54398eb89f4b95 /packages/taler-util/src
parenta8c5a9696c1735a178158cbc9ac4f9bb4b6f013d (diff)
downloadwallet-core-3cf2d4cba919203065f210f80f3f081948ad257a.tar.gz
wallet-core-3cf2d4cba919203065f210f80f3f081948ad257a.tar.bz2
wallet-core-3cf2d4cba919203065f210f80f3f081948ad257a.zip
wallet-core: expose withdrawal progress, towards huge withdrawal test
Diffstat (limited to 'packages/taler-util/src')
-rw-r--r--packages/taler-util/src/notifications.ts2
-rw-r--r--packages/taler-util/src/twrpc-impl.node.ts24
2 files changed, 8 insertions, 18 deletions
diff --git a/packages/taler-util/src/notifications.ts b/packages/taler-util/src/notifications.ts
index c50cc72de..bc1c4b71f 100644
--- a/packages/taler-util/src/notifications.ts
+++ b/packages/taler-util/src/notifications.ts
@@ -83,6 +83,8 @@ export interface ReserveNotYetFoundNotification {
export interface CoinWithdrawnNotification {
type: NotificationType.CoinWithdrawn;
+ numWithdrawn: number;
+ numTotal: number;
}
export interface RefundStartedNotification {
diff --git a/packages/taler-util/src/twrpc-impl.node.ts b/packages/taler-util/src/twrpc-impl.node.ts
index b6333da51..30e362e5b 100644
--- a/packages/taler-util/src/twrpc-impl.node.ts
+++ b/packages/taler-util/src/twrpc-impl.node.ts
@@ -30,7 +30,6 @@ const logger = new Logger("twrpc-impl.node.ts");
function readStreamLinewise(args: ReadLinewiseArgs): void {
let chunks: Uint8Array[] = [];
args.sock.on("data", (buf: Uint8Array) => {
- logger.info(`received ${buf.length} bytes`);
// Process all newlines in the newly received buffer
while (1) {
const newlineIdx = buf.indexOf("\n".charCodeAt(0));
@@ -78,28 +77,23 @@ export async function connectRpc<T>(args: RpcConnectArgs<T>): Promise<T> {
sock: client,
onLine(line) {
const lineStr = bytesToString(line);
- logger.info(`got line from server: ${lineStr}`);
// Are we currently parsing the body of a request?
if (!parsingBody) {
const strippedLine = lineStr.trim();
if (strippedLine == "%message") {
- logger.info("got message start");
parsingBody = "message";
} else if (strippedLine == "%hello-from-server") {
- logger.info("got hello from server");
} else if (strippedLine.startsWith("%error:")) {
- logger.info("got error from server, disconnecting");
client.end();
res.onDisconnect();
} else {
- logger.info("got unknown request");
+ logger.warn("got unknown request");
client.write("%error: invalid message\n");
client.end();
}
} else if (parsingBody == "message") {
const strippedLine = lineStr.trim();
if (strippedLine == "%end") {
- logger.info("finished request");
let req = bodyChunks.join("");
let reqJson: any = undefined;
try {
@@ -109,7 +103,6 @@ export async function connectRpc<T>(args: RpcConnectArgs<T>): Promise<T> {
logger.info(`message was: ${req}`);
}
if (reqJson !== undefined) {
- logger.info(`request: ${req}`);
res.onMessage(reqJson);
} else {
client.write("%error: invalid JSON");
@@ -149,7 +142,6 @@ export async function runRpcServer(args: RpcServerArgs): Promise<void> {
let parsingBody: string | undefined = undefined;
let bodyChunks: string[] = [];
- logger.info("got new connection");
sock.write("%hello-from-server\n");
const handlers = args.onConnect({
sendResponse(message) {
@@ -161,21 +153,19 @@ export async function runRpcServer(args: RpcServerArgs): Promise<void> {
});
sock.on("error", (err) => {
- logger.info(`connection error: ${err}`);
+ logger.error(`connection error: ${err}`);
});
function processLine(line: Uint8Array) {
const lineStr = bytesToString(line);
- logger.info(`got line: ${lineStr}`);
if (!parsingBody) {
const strippedLine = lineStr.trim();
if (strippedLine == "%request") {
- logger.info("got request start");
parsingBody = "request";
} else if (strippedLine === "%hello-from-client") {
- console.log("got hello from client");
+ // Nothing to do, ignore hello
} else if (strippedLine.startsWith("%error:")) {
- console.log("got error from client");
+ logger.warn("got error from client");
sock.end();
handlers.onDisconnect();
} else {
@@ -186,7 +176,6 @@ export async function runRpcServer(args: RpcServerArgs): Promise<void> {
} else if (parsingBody == "request") {
const strippedLine = lineStr.trim();
if (strippedLine == "%end") {
- logger.info("finished request");
let req = bodyChunks.join("");
let reqJson: any = undefined;
try {
@@ -195,7 +184,6 @@ export async function runRpcServer(args: RpcServerArgs): Promise<void> {
logger.warn("JSON request from client was invalid");
}
if (reqJson !== undefined) {
- logger.info(`request: ${req}`);
handlers.onMessage(reqJson);
} else {
sock.write("%error: invalid JSON");
@@ -207,7 +195,7 @@ export async function runRpcServer(args: RpcServerArgs): Promise<void> {
bodyChunks.push(lineStr);
}
} else {
- logger.info("invalid parser state");
+ logger.error("invalid parser state");
sock.write("%error: internal error\n");
sock.end();
}
@@ -219,7 +207,7 @@ export async function runRpcServer(args: RpcServerArgs): Promise<void> {
});
sock.on("close", (hadError: boolean) => {
- logger.info(`connection closed, hadError=${hadError}`);
+ logger.trace(`connection closed, hadError=${hadError}`);
handlers.onDisconnect();
});
});