Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: export core-blockchain types #1943

Merged
merged 1 commit into from
Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/core-blockchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"Brian Faust <[email protected]>"
],
"license": "MIT",
"main": "dist/index.js",
"main": "dist/index",
"types": "dist/index",
"files": [
"dist"
],
Expand Down
17 changes: 2 additions & 15 deletions packages/core-blockchain/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,2 @@
import get from "lodash/get";

class Config {
private config: any;

public init(options: any): void {
this.config = options;
}

public get(key: string, defaultValue: any = null): any {
return get(this.config, key, defaultValue);
}
}

export const config = new Config();
import { Shared } from "@arkecosystem/core-interfaces";
export const config = new Shared.Config();
43 changes: 5 additions & 38 deletions packages/core-blockchain/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,5 @@
import { Container } from "@arkecosystem/core-interfaces";
import { asValue } from "awilix";
import { Blockchain } from "./blockchain";
import { config } from "./config";
import { defaults } from "./defaults";
import { stateStorage } from "./state-storage";

/**
* The struct used by the plugin container.
* @type {Object}
*/
export const plugin: Container.PluginDescriptor = {
pkg: require("../package.json"),
defaults,
alias: "blockchain",
async register(container: Container.IContainer, options) {
const blockchain = new Blockchain(options);

config.init(options);

container.register("state", asValue(stateStorage));

if (!process.env.ARK_SKIP_BLOCKCHAIN) {
await blockchain.start();
}

return blockchain;
},
async deregister(container: Container.IContainer, options) {
await container.resolvePlugin<Blockchain>("blockchain").stop();
},
};

/**
* Access to the state.
* @type {IStateStorage}
*/
export { stateStorage };
export * from "./defaults";
export * from "./config";
export * from "./blockchain";
export * from "./state-storage";
export * from "./plugin";
32 changes: 32 additions & 0 deletions packages/core-blockchain/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Container } from "@arkecosystem/core-interfaces";
import { asValue } from "awilix";
import { Blockchain } from "./blockchain";
import { config } from "./config";
import { defaults } from "./defaults";
import { stateStorage } from "./state-storage";

/**
* The struct used by the plugin container.
* @type {Object}
*/
export const plugin: Container.PluginDescriptor = {
pkg: require("../package.json"),
defaults,
alias: "blockchain",
async register(container: Container.IContainer, options) {
const blockchain = new Blockchain(options);

config.init(options);

container.register("state", asValue(stateStorage));

if (!process.env.ARK_SKIP_BLOCKCHAIN) {
await blockchain.start();
}

return blockchain;
},
async deregister(container: Container.IContainer, options) {
await container.resolvePlugin<Blockchain>("blockchain").stop();
},
};
2 changes: 1 addition & 1 deletion packages/core-interfaces/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"Alex Barnsley <[email protected]>"
],
"license": "MIT",
"main": "",
"main": "dist/index",
"types": "dist/index",
"files": [
"dist"
Expand Down
21 changes: 2 additions & 19 deletions packages/core-p2p/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
import get from "lodash/get";
import set from "lodash/set";
import { Shared } from "@arkecosystem/core-interfaces";

class Config {
private config: any;

public init(options: any): void {
this.config = options;
}

public get(key: string, defaultValue: any = null): any {
return get(this.config, key, defaultValue);
}

public set(key: string, value: any): void {
set(this.config, key, value);
}
}

export const config = new Config();
export const config = new Shared.Config();
22 changes: 2 additions & 20 deletions packages/core-transaction-pool/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,2 @@
import get from "lodash/get";
import set from "lodash/set";

class Config {
private config: any;

public init(options: any): void {
this.config = options;
}

public get(key: string, defaultValue: any = null): any {
return get(this.config, key, defaultValue);
}

public set(key: string, value: any): void {
set(this.config, key, value);
}
}

export const config = new Config();
import { Shared } from "@arkecosystem/core-interfaces";
export const config = new Shared.Config();
1 change: 0 additions & 1 deletion packages/core/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { app } from "@arkecosystem/core-container";

export function buildPeerOptions(options) {
const config = {
Expand Down