Skip to content
Permalink
Browse files

[DDW-589] Retrieve Epoch from cardanoexplorer - WIP

  • Loading branch information...
daniloprates committed Mar 14, 2019
1 parent a4f81bd commit 56ab7192836a8b793caa6580fcee78a655e733ce
@@ -23,6 +23,7 @@ import { createAddress } from './addresses/requests/createAddress';
import { applyNodeUpdate } from './nodes/requests/applyNodeUpdate';
import { getNodeInfo } from './nodes/requests/getNodeInfo';
import { getNodeSettings } from './nodes/requests/getNodeSettings';
import { getCurrentEpoch } from './nodes/requests/getCurrentEpoch';
import { getNextNodeUpdate } from './nodes/requests/getNextNodeUpdate';
import { postponeNodeUpdate } from './nodes/requests/postponeNodeUpdate';

@@ -977,6 +978,16 @@ export default class AdaApi {
}
};

getCurrentEpochFallback = async () => {
try {
const pages = await getCurrentEpoch();
console.info('pages', pages);
return pages;
} catch (err) {
console.info('err', err);
}
};

setCardanoNodeFault = async (fault: FaultInjectionIpcRequest) => {
await cardanoFaultInjectionChannel.send(fault);
};
@@ -0,0 +1,15 @@
// @flow
// import type { RequestConfig } from '../../common/types';
import type { NodeSettingsResponse } from '../types';
import { request } from '../../utils/request';

export const getCurrentEpoch = (): // config: RequestConfig
Promise<NodeSettingsResponse> =>
request({
host: 'cardanoexplorer.com',
href: 'https://cardanoexplorer.com/api/blocks/pages',
origin: 'https://cardanoexplorer.com',
path: '/api/blocks/pages',
protocol: 'https:',
method: 'GET',
});
@@ -102,7 +102,9 @@ function typedRequest<Response>(

const parsedBody = JSON.parse(body);
const status = get(parsedBody, 'status', false);
if (status) {
if (options.host.indexOf('cardanoexplorer') > -1) {
resolve(parsedBody);
} else if (status) {
if (status === 'success') {
resolve(returnMeta ? parsedBody : parsedBody.data);
} else if (status === 'error' || status === 'fail') {
@@ -15,6 +15,7 @@
right: 0;
text-align: center;
top: 0;
z-index: 1;

.icon {
margin-bottom: 36px;
@@ -1309,153 +1309,153 @@
"description": "Title of \"Block consolidation status\" page.",
"end": {
"column": 3,
"line": 17
"line": 18
},
"file": "source/renderer/app/components/status/BlockConsolidationStatus.js",
"id": "blockConsolidationStatus.title",
"start": {
"column": 9,
"line": 13
"line": 14
}
},
{
"defaultMessage": "!!!Block storage is being consolidated.",
"description": "Description 1 of \"Block consolidation status\" page.",
"end": {
"column": 3,
"line": 22
"line": 23
},
"file": "source/renderer/app/components/status/BlockConsolidationStatus.js",
"id": "blockConsolidationStatus.description1",
"start": {
"column": 16,
"line": 18
"line": 19
}
},
{
"defaultMessage": "!!!Blocks for the current epoch <b>({currentEpoch})</b> and the previous epoch <b>({currentEpochBehind})</b> are stored as one file per block. All previous epochs will be consolidated to two files per epoch.",
"description": "Description 2 of \"Block consolidation status\" page.",
"end": {
"column": 3,
"line": 28
"line": 29
},
"file": "source/renderer/app/components/status/BlockConsolidationStatus.js",
"id": "blockConsolidationStatus.description2",
"start": {
"column": 16,
"line": 23
"line": 24
}
},
{
"defaultMessage": "!!!This reduces the number of files and the amount of hard drive space required to store the blockchain on your machine.",
"description": "Description 3 of \"Block consolidation status\" page.",
"end": {
"column": 3,
"line": 34
"line": 35
},
"file": "source/renderer/app/components/status/BlockConsolidationStatus.js",
"id": "blockConsolidationStatus.description3",
"start": {
"column": 16,
"line": 29
"line": 30
}
},
{
"defaultMessage": "!!!<b>{consolidated}</b> <em>of</em> <b>{downloaded}</b> epochs consolidated",
"description": "Epochs Consolidated Of Total on \"Block consolidation status\" page.",
"end": {
"column": 3,
"line": 41
"line": 42
},
"file": "source/renderer/app/components/status/BlockConsolidationStatus.js",
"id": "blockConsolidationStatus.epochsConsolidatedOfTotal",
"start": {
"column": 29,
"line": 35
"line": 36
}
},
{
"defaultMessage": "!!!epoch",
"description": "Singular Epoch on \"Block consolidation status\" page.",
"end": {
"column": 3,
"line": 46
"line": 47
},
"file": "source/renderer/app/components/status/BlockConsolidationStatus.js",
"id": "blockConsolidationStatus.epoch",
"start": {
"column": 9,
"line": 42
"line": 43
}
},
{
"defaultMessage": "!!!epochs",
"description": "Plural Epochs on \"Block consolidation status\" page.",
"end": {
"column": 3,
"line": 51
"line": 52
},
"file": "source/renderer/app/components/status/BlockConsolidationStatus.js",
"id": "blockConsolidationStatus.epochs",
"start": {
"column": 10,
"line": 47
"line": 48
}
},
{
"defaultMessage": "!!!epochs consolidated",
"description": "Epochs consolidated on \"Block consolidation status\" page.",
"end": {
"column": 3,
"line": 56
"line": 57
},
"file": "source/renderer/app/components/status/BlockConsolidationStatus.js",
"id": "blockConsolidationStatus.epochsConsolidated",
"start": {
"column": 22,
"line": 52
"line": 53
}
},
{
"defaultMessage": "!!!{epochsSynced}% blocks synced",
"description": "synced on \"Block consolidation status\" page.",
"end": {
"column": 3,
"line": 61
"line": 62
},
"file": "source/renderer/app/components/status/BlockConsolidationStatus.js",
"id": "blockConsolidationStatus.synced",
"start": {
"column": 10,
"line": 57
"line": 58
}
},
{
"defaultMessage": "!!!Support",
"description": "Support Button on \"Block consolidation status\" page.",
"end": {
"column": 3,
"line": 66
"line": 67
},
"file": "source/renderer/app/components/status/BlockConsolidationStatus.js",
"id": "blockConsolidationStatus.supportButton",
"start": {
"column": 17,
"line": 62
"line": 63
}
},
{
"defaultMessage": "!!!https://iohk.zendesk.com/hc/en-us/articles/360016060314",
"description": "URL of Support Button on \"Block consolidation status\" page.",
"end": {
"column": 3,
"line": 72
"line": 73
},
"file": "source/renderer/app/components/status/BlockConsolidationStatus.js",
"id": "blockConsolidationStatus.supportButtonURL",
"start": {
"column": 20,
"line": 67
"line": 68
}
}
],
@@ -94,6 +94,10 @@ export default class NetworkStatusStore extends Store {
this.api.ada.getNetworkStatus
);
@observable
getCurrentEpochFallbackRequest: Request<GetNetworkStatusResponse> = new Request(
this.api.ada.getCurrentEpochFallback
);
@observable
forceCheckTimeDifferenceRequest: Request<GetNetworkStatusResponse> = new Request(
this.api.ada.getNetworkStatus
);
@@ -424,7 +428,7 @@ export default class NetworkStatusStore extends Store {

// Update sync progress
runInAction('update currentEpoch', () => {
this.currentEpoch = slotId.epoch;
// this.currentEpoch = slotId.epoch;
});

runInAction('update block heights', () => {
@@ -552,6 +556,11 @@ export default class NetworkStatusStore extends Store {
}
};

@action _getCurrentEpochFallback = async () => {
const pages = await this.getCurrentEpochFallbackRequest.execute().promise;
console.log('pages store', pages);
};

@action _setDisconnected = (wasConnected: boolean) => {
this.isNodeResponding = false;
this.isNodeSubscribed = false;

0 comments on commit 56ab719

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.