diff --git a/src/entities/Round.ts b/src/entities/Round.ts deleted file mode 100644 index c3f4b14..0000000 --- a/src/entities/Round.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { BaseEntity, Column, Entity, PrimaryColumn } from "typeorm"; - -@Entity() -export class Round extends BaseEntity { - @PrimaryColumn("int") - public id: number; - - @Column("varchar") - public topDelegates: string; - - @Column("bigint") - public forged: number; - - @Column("bigint") - public removed: number; - - @Column("bigint") - public staked: number; - - @Column("bigint") - public released: number; -} diff --git a/src/entities/Stake.ts b/src/entities/Stake.ts deleted file mode 100644 index 3bf9402..0000000 --- a/src/entities/Stake.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { BaseEntity, Column, Entity, PrimaryGeneratedColumn } from "typeorm"; - -@Entity() -export class Stake extends BaseEntity { - @PrimaryGeneratedColumn() - public id: number; - - @Column("varchar", { length: 64 }) - public stakeKey: string; - - @Column("varchar", { - length: 34, - }) - public address: string; - - @Column("int") - public redeemableTimestamp: number; -} diff --git a/src/entities/index.ts b/src/entities/index.ts index bd7064b..4a01eb1 100644 --- a/src/entities/index.ts +++ b/src/entities/index.ts @@ -1,3 +1 @@ -export * from "./Stake"; export * from "./Statistic"; -export * from "./Round"; diff --git a/src/plugin.ts b/src/plugin.ts deleted file mode 100644 index 33dcd08..0000000 --- a/src/plugin.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { app } from "@arkecosystem/core-container"; -import { Container, Logger } from "@arkecosystem/core-interfaces"; -import { Managers } from "@arkecosystem/crypto"; -import * as path from "path"; -// TypeORM imports -import "reflect-metadata"; -import { createConnection, getConnection } from "typeorm"; -import { defaults } from "./defaults"; -import { startServer } from "./server"; - -// Queue -import queue from "queue"; -const qp = queue(); -qp.concurrency = 1; - -// Entities -import { Round, Stake, Statistic } from "./entities"; - -// Core plugins -const logger = app.resolvePlugin("logger"); -const network = Managers.configManager.get("network"); -const dbPath = path.resolve(__dirname, `../../storage/databases/${network.name}.sqlite`); - -// Queue job plug-in, all functions that write to db should be wrapped in this. -qp.autostart = true; -export const q = async fn => { - qp.push(fn); -}; - -export const plugin: Container.IPluginDescriptor = { - pkg: require("../package.json"), - defaults, - alias: "storage", - async register(container: Container.IContainer, options) { - logger.info(`Registering Storage Plug-in.`); - logger.info(`Storage Plug-in Database Path: ${dbPath}`); - - await createConnection({ - type: "sqlite", - database: dbPath, - // Import entities to connection - entities: [Stake, Statistic, Round], - synchronize: true, - }); - - startServer({ host: "0.0.0.0", port: 8000 }); - }, - async deregister(container: Container.IContainer, options) { - logger.info(`Deregistering Storage Plug-in.`); - await getConnection().close(); - }, -}; diff --git a/src/server.ts b/src/server.ts index 620bb40..bb065bd 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,6 +1,6 @@ import { createServer, mountServer } from "@arkecosystem/core-http-utils"; import { notFound } from "@hapi/boom"; -import { Round, Statistic } from "./entities"; +import { Statistic } from "./entities"; export const startServer = async config => { const server = await createServer({ @@ -8,23 +8,6 @@ export const startServer = async config => { port: config.port, }); - // Round Data - server.route({ - method: "GET", - path: "/round/{id}", - async handler(request, h) { - const id: number = Number(request.params.id); - const round = await Round.findOne({ id }); - const response: any = round; - if (round) { - response.topDelegates = round.topDelegates.split(","); - return response; - } else { - return notFound(); - } - }, - }); - // Statistics server.route({ method: "GET", diff --git a/src/storage.ts b/src/storage.ts index 756020a..f6e36c9 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -14,7 +14,7 @@ const qp = queue(); qp.concurrency = 1; // Entities -import { Round, Stake, Statistic } from "./entities"; +import { Statistic } from "./entities"; // Core plugins const logger = app.resolvePlugin("logger"); @@ -39,7 +39,7 @@ export const plugin: Container.IPluginDescriptor = { type: "sqlite", database: dbPath, // Import entities to connection - entities: [Stake, Statistic, Round], + entities: [Statistic], synchronize: true, });