Skip to content

Commit

Permalink
fix: improved logging
Browse files Browse the repository at this point in the history
  • Loading branch information
troykessler committed Oct 19, 2023
1 parent 32a8b58 commit 4f4071a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 2 additions & 2 deletions common/protocol/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {
isStorageBalanceLow,
} from "./methods";
import { ICacheProvider, IMetrics, IRuntime } from "./types";
import { REFRESH_TIME, sleep, standardizeError } from "./utils";
import { IDLE_TIME, sleep, standardizeError } from "./utils";
import { SupportedChains } from "@kyvejs/sdk/dist/constants";
import { storageProviderFactory } from "./reactors/storageProviders";
import { compressionFactory } from "./reactors/compression";
Expand Down Expand Up @@ -319,7 +319,7 @@ export class Validator {

// until data is not available we wait and idle
while (!(await this.isDataAvailable())) {
await sleep(REFRESH_TIME);
await sleep(IDLE_TIME);
}

if (!(await this.isDataAvailable())) {
Expand Down
8 changes: 2 additions & 6 deletions common/protocol/src/methods/checks/isDataAvailable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ import { Validator, standardizeError } from "../..";
* @return {Promise<boolean>}
*/
export async function isDataAvailable(this: Validator): Promise<boolean> {
let nextKey: string = "";

try {
// log debug method
if (this.pool.data!.current_key) {
this.logger.debug(`this.runtime.nextKey(${this.pool.data!.current_key})`);
}

// get the next key to node has to fetch
nextKey = this.pool.data!.current_key
const nextKey = this.pool.data!.current_key
? await this.runtime.nextKey(this, this.pool.data!.current_key)
: this.pool.data!.start_key;

Expand All @@ -47,9 +45,7 @@ export async function isDataAvailable(this: Validator): Promise<boolean> {

return true;
} catch (err) {
this.logger.warn(
`Data not available for next key: ${nextKey}: Retrying in 10s ...`
);
this.logger.warn(`Data not available for next key. Retrying in 60s ...`);
this.logger.debug(standardizeError(err));

return false;
Expand Down

0 comments on commit 4f4071a

Please sign in to comment.