Permalink
Browse files

Merge latest develop and fix conflicts

  • Loading branch information...
nikolaglumac committed Jan 11, 2019
2 parents ff891a0 + 948c8a5 commit 70a8678d7f07f1d4373d517b14959e184ff0797a
@@ -7,7 +7,8 @@ Changelog
### Features

- Implemented a success message for logs download ([PR 1228](https://github.com/input-output-hk/daedalus/pull/1228))
- Added support for "frontend-only" mode ([PR 1241](https://github.com/input-output-hk/daedalus/pull/1241))
- Improve NTP check UX ([PR 1258](https://github.com/input-output-hk/daedalus/pull/1258))
- Added support for "frontend-only" mode ([PR 1241](https://github.com/input-output-hk/daedalus/pull/1241), [PR 1260](https://github.com/input-output-hk/daedalus/pull/1260))
- Improved the lock-file UX by replacing "Daedalus is already running" dialog with focusing of the already running Daedalus instance ([PR 1229](https://github.com/input-output-hk/daedalus/pull/1229))
- Replaced in-app support request with links to support page ([PR 1199](https://github.com/input-output-hk/daedalus/pull/1199))
- Improved the UX of inline editing fields (like wallet renaming) ([PR 1231](https://github.com/input-output-hk/daedalus/pull/1231))
@@ -24,7 +24,7 @@ let
(pkgs.lib.optional (systemStart != null) ".configuration.systemStart = ${toString systemStart}")
(pkgs.lib.optional (cluster == "demo") ''.configuration.key = "default"'')
(pkgs.lib.optional (fullExtraArgs != []) ''.nodeArgs += ${builtins.toJSON fullExtraArgs}'')
(pkgs.lib.optional (autoStartBackend == true) ''.frontendOnlyMode = false'')
(pkgs.lib.optional (autoStartBackend == true) ''.frontendOnlyMode = true'')
];
patchesString = pkgs.lib.concatStringsSep " | " patches;
launcherYamlWithStartTime = pkgs.runCommand "launcher-config.yaml" { buildInputs = [ pkgs.jq yaml2json ]; } ''
@@ -1,6 +1,7 @@
// @flow
import { BrowserWindow } from 'electron';
import { CardanoNode } from './CardanoNode';
import { frontendOnlyMode } from '../config';
import type { LauncherConfig } from '../config';
import { setupFrontendOnlyMode } from './setupFrontendOnlyMode';
import { setupCardanoNodeMode } from './setupCardanoNodeMode';
@@ -15,8 +16,6 @@ import { setupCardanoNodeMode } from './setupCardanoNodeMode';
export const setupCardano = (
launcherConfig: LauncherConfig, mainWindow: BrowserWindow
): ?CardanoNode => {
const { frontendOnlyMode } = launcherConfig;

if (frontendOnlyMode) {
return setupFrontendOnlyMode(mainWindow);
}
@@ -60,6 +60,12 @@ export const ALLOWED_LAUNCHER_LOGS = new RegExp(/(launcher-)(\d{14}$)/);
export const MAX_NODE_LOGS_ALLOWED = 3;
export const MAX_LAUNCHER_LOGS_ALLOWED = 3;

// We need to invert 'frontendOnlyMode' value received from the launcherConfig
// as this variable has an opposite meaning from the launcher's perspective.
// Launcher treats the 'frontendOnlyMode' set to 'true' as the case where Daedalus
// takes the responsiblity for launching and managing the cardano-node.
export const frontendOnlyMode = !launcherConfig.frontendOnlyMode;

// CardanoNode config
export const NODE_STARTUP_TIMEOUT = 5000;
export const NODE_STARTUP_MAX_RETRIES = 5;
@@ -234,7 +234,7 @@ export default class NetworkStatus extends Component<Props, State> {
</span> |&nbsp;
<button
onClick={() => onForceCheckLocalTimeDifference()}
disabled={isForceCheckingNodeTime}
disabled={isForceCheckingNodeTime || !isConnected}
>
{isForceCheckingNodeTime ? 'Checking...' : 'Check time'}
</button>
@@ -12,3 +12,4 @@ export const MAX_ALLOWED_STALL_DURATION = 2 * 60 * 1000; // 2 minutes | unit: mi
export const NETWORK_STATUS_REQUEST_TIMEOUT = 30 * 1000; // 30 seconds | unit: milliseconds
export const NETWORK_STATUS_POLL_INTERVAL = 2000; // 2 seconds | unit: milliseconds
export const NTP_FORCE_CHECK_POLL_INTERVAL = 30 * 60 * 1000; // 30 minutes | unit: milliseconds
export const NTP_IGNORE_CHECKS_GRACE_PERIOD = 30 * 1000; // 30 seconds | unit: milliseconds
@@ -10,6 +10,7 @@ import {
NETWORK_STATUS_REQUEST_TIMEOUT,
NETWORK_STATUS_POLL_INTERVAL,
NTP_FORCE_CHECK_POLL_INTERVAL,
NTP_IGNORE_CHECKS_GRACE_PERIOD,
} from '../config/timingConfig';
import { UNSYNCED_BLOCKS_ALLOWED } from '../config/numbersConfig';
import { Logger } from '../utils/logging';
@@ -75,6 +76,9 @@ export default class NetworkStatusStore extends Store {
setup() {
// ========== IPC CHANNELS =========== //

// Request node state
this._requestCardanoState();

// Request cached node status for fast bootstrapping of frontend
this._requestCardanoStatus();

@@ -88,6 +92,7 @@ export default class NetworkStatusStore extends Store {
// ========== MOBX REACTIONS =========== //

this.registerReactions([
this._updateNetworkStatusWhenConnected,
this._updateNetworkStatusWhenDisconnected,
this._updateNodeStatus,
]);
@@ -101,6 +106,13 @@ export default class NetworkStatusStore extends Store {
this._forceCheckTimeDifferencePollingInterval = setInterval(
this.forceCheckLocalTimeDifference, NTP_FORCE_CHECK_POLL_INTERVAL
);

// Ignore system time checks for the first 30 seconds:
this.ignoreSystemTimeChecks();
setTimeout(
() => this.ignoreSystemTimeChecks(false),
NTP_IGNORE_CHECKS_GRACE_PERIOD
);
}

async restartNode() {
@@ -130,6 +142,13 @@ export default class NetworkStatusStore extends Store {
if (!this.isConnected) this._updateNetworkStatus();
};

_updateNetworkStatusWhenConnected = () => {
if (this.isConnected) {
Logger.info('NetworkStatusStore: Connected, forcing NTP check now...');
this._updateNetworkStatus({ force_ntp_check: true });
}
};

_updateNodeStatus = async () => {
if (!this.isConnected) return;
try {
@@ -146,11 +165,16 @@ export default class NetworkStatusStore extends Store {
return Date.now() - this._startTime;
}

_requestCardanoState = async () => {
Logger.info('NetworkStatusStore: requesting node state.');
const state = await cardanoStateChangeChannel.request();
Logger.info(`NetworkStatusStore: handling node state <${state}>.`);
await this._handleCardanoNodeStateChange(state);
};

_requestCardanoStatus = async () => {
try {
Logger.info('NetworkStatusStore: requesting node status.');
const state = await cardanoStateChangeChannel.request();
await this._handleCardanoNodeStateChange(state);
const status = await cardanoStatusChannel.request();
Logger.info(`NetworkStatusStore: received cached node status: ${JSON.stringify(status)}`);
if (status) runInAction('assigning node status', () => Object.assign(this, status));
@@ -425,12 +449,12 @@ export default class NetworkStatusStore extends Store {
}
};

@action ignoreSystemTimeChecks = () => {
this.isSystemTimeIgnored = true;
@action ignoreSystemTimeChecks = (flag: boolean = true) => {
this.isSystemTimeIgnored = flag;
};

forceCheckLocalTimeDifference = () => {
this._updateNetworkStatus({ force_ntp_check: true });
if (this.isConnected) this._updateNetworkStatus({ force_ntp_check: true });
};

// DEFINE COMPUTED VALUES

0 comments on commit 70a8678

Please sign in to comment.