Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecot committed Jan 16, 2025
1 parent 0b1477e commit f889afc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 43 deletions.
1 change: 1 addition & 0 deletions PUBLICAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Returns list of all active validators (addresses only)
#### `/lava_chain_restakers`

- Returns current and monthly unique staker counts
- only delegation of active providers are taken into account
- Response format:

```json
Expand Down
2 changes: 1 addition & 1 deletion src/indexer/restrpc_agregators/AprMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class APRMonitorClass {
try {
const batchData = Array.from(aprValues.entries()).map(([provider, value]) => ({
address: provider,
value: value.toString(),
value: Number(value).toFixed(18),
timestamp: new Date(),
type: caller
}));
Expand Down
7 changes: 6 additions & 1 deletion src/restRpc/lavaRpcPeriodicEndpointCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { QueryLavaRPC } from '@jsinfo/restRpc/lavaRpc';
import { RedisCache } from '@jsinfo/redis/classes/RedisCache';
import { TruncateError } from '@jsinfo/utils/fmt';
import { IsMeaningfulText } from '@jsinfo/utils/fmt';
import { ActiveProvidersService } from '@jsinfo/redis/resources/index/ActiveProvidersResource';

const REDIS_KEYS = {
PROVIDERS: 'providers',
Expand Down Expand Up @@ -306,9 +307,13 @@ class RpcPeriodicEndpointCacheClass {
}

public async GetUniqueDelegatorCount(from?: number, includeEmptyProviders: boolean = false): Promise<number> {
const providers = await this.GetAllProvidersFromRpc();
const providers = await ActiveProvidersService.fetch();
const uniqueDelegators = new Set<string>();

if (!providers) {
return 0;
}

for (const provider of providers) {
const delegations = await this.getProviderDelegations(provider);
if (!delegations) {
Expand Down
42 changes: 1 addition & 41 deletions src/schemas/jsinfoSchema/jsinfoSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,44 +400,4 @@ export const aprFullInfo = pgTable('apr_full_info', {
});

export type AprFullInfo = typeof aprFullInfo.$inferSelect;
export type InsertAprFullInfo = typeof aprFullInfo.$inferInsert;

// export const consumerOptimizerMetricsAgg = pgTable('consumer_optimizer_metrics_agg', {
// id: serial('id'),
// created_at: timestamp('created_at', { withTimezone: true }),
// timestamp: timestamp('timestamp', { withTimezone: true }),
// consumer: text('consumer'),
// chain_id: text('chain_id'),
// latency_score: numeric('latency_score'),
// availability_score: numeric('availability_score'),
// sync_score: numeric('sync_score'),
// node_error_rate: numeric('node_error_rate'),
// provider: text('provider'),
// provider_stake: bigint('provider_stake', { mode: 'number' }),
// entry_index: numeric('entry_index'),
// consumer_hostname: text('consumer_hostname'),
// generic_score: numeric('generic_score'),
// epoch: bigint('epoch', { mode: 'number' })
// }, (table) => {
// return {
// consumerIdx: index("consumer_optimizer_metrics_agg_consumer_idx").on(table.consumer),
// hostnameIdx: index("consumer_optimizer_metrics_agg_hostname_idx").on(table.consumer_hostname),
// chainIdx: index("consumer_optimizer_metrics_agg_chain_idx").on(table.chain_id),
// providerIdx: index("consumer_optimizer_metrics_agg_provider_idx").on(table.provider),
// uniqueConstraint: uniqueIndex('consumer_optimizer_metrics_agg_unique_idx')
// .on(table.timestamp, table.consumer, table.chain_id,
// table.provider, table.consumer_hostname)
// };
// });
// export type ConsumerOptimizerMetricsAgg = typeof consumerOptimizerMetricsAgg.$inferSelect
// export type InsertConsumerOptimizerMetricsAgg = typeof consumerOptimizerMetricsAgg.$inferInsert

// export const consumerOptimizerMetricsAggTimes = pgTable('consumer_optimizer_metrics_agg_times', {
// id: serial('id').primaryKey(),
// last_from: timestamp('last_from', { withTimezone: true }),
// last_to: timestamp('last_to', { withTimezone: true }),
// created_at: timestamp('created_at', { withTimezone: true })
// });

// export type ConsumerOptimizerMetricsAggTimes = typeof consumerOptimizerMetricsAggTimes.$inferSelect
// export type InsertConsumerOptimizerMetricsAggTimes = typeof consumerOptimizerMetricsAggTimes.$inferInsert
export type InsertAprFullInfo = typeof aprFullInfo.$inferInsert;

0 comments on commit f889afc

Please sign in to comment.