123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- import { CacheEvent } from "./types";
- export const sum = (a: number[]) =>
- a.reduce((s: number, i: number) => s + i, 0);
- export const getPercent = (value1: number, value2: number): number => {
- if (value1 === 0) return value2 > 0 ? Infinity : 0;
- return Number(((value2 * 100) / value1 - 100).toFixed(2));
- };
- export const momentToString = (timestamp: number) =>
- new Date(timestamp).toLocaleDateString("en-US");
- export const eventStats = (blockEventsCache: Map<number, CacheEvent[]>) => {
- let sections: {
- [key: string]: { [key: string]: [{ key: number; data: any }] };
- } = {};
- for (let [key, blockEvents] of blockEventsCache) {
- blockEvents.forEach(({ section, method, data }) => {
- if (!sections[section]) sections[section] = {};
- if (sections[section][method])
- sections[section][method].push({ key, data });
- else sections[section][method] = [{ key, data }];
- });
- }
- console.log(`Events:`);
- Object.keys(sections).map((section: string) =>
- Object.keys(sections[section]).map((method: string) =>
- console.log(` ${section}.${method}: ${sections[section][method].length}`)
- )
- );
- };
- export {
- connectApi,
- getBlock,
- getBlockHash,
- getHead,
- getBestHash,
- getTimestamp,
- getIssuance,
- getEvents,
- getEra,
- getEraStake,
- getCouncils,
- getCouncilRound,
- getCouncilStage,
- getCouncilElectionStage,
- getCouncilTermEnd,
- getCouncilElectionStatus,
- getCouncilSize,
- getCouncilApplicants,
- getCouncilCommitments,
- getCouncilPayoutInterval,
- getCouncilPayout,
- getCouncilElectionDurations,
- getNextWorker,
- getWorker,
- getWorkers,
- getStake,
- getAccounts,
- getAccount,
- getNextMember,
- getMember,
- getMemberIdByAccount,
- getMemberHandle,
- getMemberHandleByAccount,
- getNextPost,
- getNextThread,
- getNextCategory,
- getCategory,
- getThread,
- getPost,
- getActiveProposals,
- getProposalCount,
- getProposalInfo,
- getProposalDetails,
- getProposalType,
- getProposal,
- getProposalVotes,
- getProposalPost,
- getProposalPosts,
- getProposalPostCount,
- getProposalThreadCount,
- getValidatorCount,
- getValidators,
- } from "./api";
- export {
- getChannel,
- getChannelCategory,
- getCuratorGroup,
- getVideo,
- getVideoCategory,
- getNextChannel,
- getNextChannelCategory,
- getNextCuratorGroup,
- getNextPerson,
- getNextPlaylist,
- getNextSeries,
- getNextVideo,
- getNextVideoCategory,
- } from "./content";
- export {
- feePerMegabyte,
- maxStorageBucketsPerBag,
- maxDistributionBucketsPerBag,
- maxStorageBucketObjects,
- maxStorageBucketSize,
- uploadingBlocked,
- getBlacklist,
- getBlacklistSize,
- getDynamicBagPolicy,
- getNextDataObject,
- getNextStorageBucket,
- getNextDistributionFamily,
- getBag,
- getBags,
- getObject,
- getBagObjects,
- getStorageBucket,
- getStorageBuckets,
- getDistributionFamily,
- getDistributionFamilies,
- getDistributionFamilyNumber,
- getDistributionFamilyBucket,
- getDistributionFamilyBuckets,
- } from "./storage";
|