Add audit replication success logging

This commit is contained in:
Mononaut 2023-07-14 16:48:11 +09:00
parent e59a9d38ff
commit 1abd2a23cc
No known key found for this signature in database
GPG key ID: A3F058E41374C04E
2 changed files with 3 additions and 2 deletions

View file

@ -66,6 +66,7 @@ class AuditReplication {
if (syncResult) {
if (syncResult.data?.template?.length) {
await this.$saveAuditData(hash, syncResult.data);
logger.info(`Imported audit data from ${syncResult.server} for block ${syncResult.data.height} (${hash})`);
success = true;
}
if (!syncResult.data && !syncResult.exists) {

View file

@ -4,7 +4,7 @@ import axios, { AxiosResponse } from 'axios';
import { SocksProxyAgent } from 'socks-proxy-agent';
import * as https from 'https';
export async function $sync(path): Promise<{ data?: any, exists: boolean }> {
export async function $sync(path): Promise<{ data?: any, exists: boolean, server?: string }> {
// start with a random server so load is uniformly spread
let allMissing = true;
const offset = Math.floor(Math.random() * config.REPLICATION.SERVERS.length);
@ -18,7 +18,7 @@ export async function $sync(path): Promise<{ data?: any, exists: boolean }> {
try {
const result = await query(`https://${server}${path}`);
if (result) {
return { data: result, exists: true };
return { data: result, exists: true, server };
}
} catch (e: any) {
if (e?.response?.status === 404) {