lisk-framework
Version:
Lisk blockchain application platform
36 lines • 1.65 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.MainchainInteroperabilityInternalMethod = void 0;
const base_interoperability_internal_methods_1 = require("../base_interoperability_internal_methods");
const constants_1 = require("../constants");
const own_chain_account_1 = require("../stores/own_chain_account");
const chain_account_1 = require("../stores/chain_account");
const state_machine_1 = require("../../../state_machine");
class MainchainInteroperabilityInternalMethod extends base_interoperability_internal_methods_1.BaseInteroperabilityInternalMethod {
async isLive(context, chainID, timestamp) {
const ownChainAccount = await this.stores.get(own_chain_account_1.OwnChainAccountStore).get(context, constants_1.EMPTY_BYTES);
if (chainID.equals(ownChainAccount.chainID)) {
return true;
}
try {
const chainAccount = await this.stores.get(chain_account_1.ChainAccountStore).get(context, chainID);
if (chainAccount.status === 2) {
return false;
}
if (chainAccount.status === 1) {
if (timestamp - chainAccount.lastCertificate.timestamp > constants_1.LIVENESS_LIMIT) {
return false;
}
}
return true;
}
catch (error) {
if (!(error instanceof state_machine_1.NotFoundError)) {
throw error;
}
return false;
}
}
}
exports.MainchainInteroperabilityInternalMethod = MainchainInteroperabilityInternalMethod;
//# sourceMappingURL=internal_method.js.map
;