move light node config to own json node
This commit is contained in:
parent
1d1a6abe55
commit
6cc3528f80
4
app.js
4
app.js
|
@ -184,9 +184,9 @@ const initLightNode = async () => {
|
|||
blocksToKeep,
|
||||
} = conf;
|
||||
const database = new Database();
|
||||
await database.init(databaseURL, databaseName, lightNode, blocksToKeep);
|
||||
await database.init(databaseURL, databaseName, lightNode.enabled, blocksToKeep);
|
||||
|
||||
if (!lightNode) {
|
||||
if (!lightNode.enabled) {
|
||||
// check if was previously a light node
|
||||
const wasLightNode = await database.wasLightNodeBefore();
|
||||
if (wasLightNode) {
|
||||
|
|
|
@ -16,10 +16,12 @@
|
|||
"genesisHiveBlock": 41967000,
|
||||
"witnessEnabled": true,
|
||||
"defaultLogLevel": "warn",
|
||||
"lightNode": false,
|
||||
"blocksToKeep": 864000,
|
||||
"lightNodeCleanupInterval": 600000,
|
||||
"domain" : "",
|
||||
"lightNode": {
|
||||
"enabled": false,
|
||||
"blocksToKeep": 864000,
|
||||
"cleanupInterval": 600000
|
||||
},
|
||||
"rpcConfig" : {
|
||||
"maxLimit" : 1000,
|
||||
"maxOffset" : -1,
|
||||
|
|
|
@ -126,7 +126,7 @@ async function findDivergentBlock() {
|
|||
}
|
||||
} else {
|
||||
let low = 0;
|
||||
if (lightNode) {
|
||||
if (lightNode.enabled) {
|
||||
const firstBlock = await chain.findOne({ blockNumber: { $gt: 0 } });
|
||||
if (firstBlock) {
|
||||
low = firstBlock.blockNumber;
|
||||
|
|
|
@ -56,9 +56,9 @@ async function generateStatus() {
|
|||
result.chainId = config.chainId;
|
||||
|
||||
// get light node config of the SSC node
|
||||
result.lightNode = config.lightNode;
|
||||
if (config.lightNode) {
|
||||
result.blocksToKeep = config.blocksToKeep;
|
||||
result.lightNode = config.lightNode.enabled;
|
||||
if (result.lightNode) {
|
||||
result.blocksToKeep = config.lightNode.blocksToKeep;
|
||||
}
|
||||
|
||||
// first block currently stored by light node
|
||||
|
|
|
@ -22,18 +22,16 @@ const manageLightNode = async (cleanupInterval) => {
|
|||
const init = async (conf, callback) => {
|
||||
const {
|
||||
lightNode,
|
||||
lightNodeCleanupInterval,
|
||||
blocksToKeep,
|
||||
databaseURL,
|
||||
databaseName,
|
||||
} = conf;
|
||||
|
||||
if (!lightNode) {
|
||||
if (!lightNode.enabled) {
|
||||
console.log('LightNode not started as it is not enabled in the config.json file');
|
||||
} else {
|
||||
database = new Database();
|
||||
await database.init(databaseURL, databaseName, lightNode, blocksToKeep);
|
||||
manageLightNode(lightNodeCleanupInterval ? lightNodeCleanupInterval : 600000);
|
||||
await database.init(databaseURL, databaseName, lightNode.enabled, lightNode.blocksToKeep);
|
||||
manageLightNode(lightNode.cleanupInterval ? lightNode.cleanupInterval : 600000);
|
||||
}
|
||||
callback(null);
|
||||
};
|
||||
|
|
|
@ -259,7 +259,7 @@ async function restorePartial() {
|
|||
lightNode,
|
||||
} = conf;
|
||||
|
||||
if (lightNode && !drop) {
|
||||
if (lightNode.enabled && !drop) {
|
||||
console.log('Restoring a light node database is not supported. Please add the \'-d\' flag to completely restore your db.');
|
||||
return;
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ async function restorePartial() {
|
|||
|
||||
let divergentBlockNum = Number.MAX_SAFE_INTEGER;
|
||||
if (!drop) {
|
||||
divergentBlockNum = await findDivergentBlock(chain, lightNode);
|
||||
divergentBlockNum = await findDivergentBlock(chain, lightNode.enabled);
|
||||
if (divergentBlockNum === -1) {
|
||||
console.log('ok');
|
||||
await database.close();
|
||||
|
|
Loading…
Reference in New Issue