Skip to content

Commit

Permalink
Fix build error
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhaixian1984 committed Jul 8, 2024
1 parent 32d9597 commit ece71c4
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions src/tasks/pull-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import BigNumber from 'bignumber.js';
import { FileRecord, FileStatus } from '../types/database';
import { PullingStrategy } from '../types/smanager-config';
import IpfsHttpClient from 'ipfs-http-client';
import { bytesToMb, formatError } from '../utils';
import { Dayjs } from '../utils/datetime';
import { BlockAndTime, estimateTimeAtBlock } from '../utils/chain-math';
import { formatError } from '../utils';
//import { Dayjs } from '../utils/datetime';
import { BlockAndTime } from '../utils/chain-math';
import { AppContext } from '../types/context';
import seedrandom from 'seedrandom';
//import seedrandom from 'seedrandom';
import _ from 'lodash';

Check warning on line 10 in src/tasks/pull-utils.ts

View workflow job for this annotation

GitHub Actions / build

'_' is defined but never used

Check warning on line 10 in src/tasks/pull-utils.ts

View workflow job for this annotation

GitHub Actions / build

'_' is defined but never used
import SworkerApi from '../sworker';
import { Logger } from 'winston';
import { logger } from '../utils/logger';
//import { logger } from '../utils/logger';

const CID = (IpfsHttpClient as any).CID; // eslint-disable-line
export const SysMinFreeSpace = 50 * 1024; // 50 * 1024 MB
Expand All @@ -37,12 +37,12 @@ type FilterFileResult =
| 'pendingForReplica';

// treat file as invalid if no replicas for at most 10 days
const MaxNoReplicaDuration = Dayjs.duration({
days: 10,
});
const MinLifeTime = Dayjs.duration({
months: 4,
});
// const MaxNoReplicaDuration = Dayjs.duration({
// days: 10,
// });
// const MinLifeTime = Dayjs.duration({
// months: 4,
// });

// TODO: add some tests
export async function filterFile(
Expand Down Expand Up @@ -148,29 +148,29 @@ export function estimateIpfsPinTimeout(size: number /** in bytes */): number {
return BasePinTimeout + (size / 1024 / 200) * 1000;
}

function probabilityFilter(context: AppContext, maxReplicas: number): boolean {
if (!context.nodeInfo) {
return false;
}
// Base probability
let pTake = 0.0;
const nodeCount = context.nodeInfo.nodeCount;
if (nodeCount === 0) {
pTake = 0.0;
} else {
pTake = maxReplicas / nodeCount;
}

const memberCount = _.max([1, context.groupInfo.totalMembers]);
pTake = pTake * memberCount;

return pTake > rdm(context.config.chain.account);
}

function rdm(seed: string): number {
const rng = seedrandom(seed, { entropy: true });
return rng();
}
// // function probabilityFilter(context: AppContext, maxReplicas: number): boolean {
// // if (!context.nodeInfo) {
// // return false;
// // }
// // // Base probability
// // let pTake = 0.0;
// // const nodeCount = context.nodeInfo.nodeCount;
// // if (nodeCount === 0) {
// // pTake = 0.0;
// // } else {
// // pTake = maxReplicas / nodeCount;
// // }

// // const memberCount = _.max([1, context.groupInfo.totalMembers]);
// // pTake = pTake * memberCount;

// // return pTake > rdm(context.config.chain.account);
// // }

// function rdm(seed: string): number {
// const rng = seedrandom(seed, { entropy: true });
// return rng();
// }

export async function isSealDone(
cid: string,
Expand Down

0 comments on commit ece71c4

Please sign in to comment.