This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
sproxet
committed
Aug 29, 2019
1 parent
eee9ffd
commit b643c14
Showing
11 changed files
with
311 additions
and
1,139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Zcoind } from '../zcoind'; | ||
|
||
import { createLogger } from '../../lib/logger'; | ||
const logger = createLogger('zcoin:daemon:znodeUpdate'); | ||
|
||
// In addition to initializing the znode list, this function goes into an infinite loop refreshing the data every 5 | ||
// minutes. | ||
export async function initialize(store: any, zcoind: Zcoind) { | ||
while (true) { | ||
try { | ||
const data = await zcoind.send(null, 'initial', 'znodeList', null); | ||
logger.info("Got initial znodeList data"); | ||
|
||
if (Object.keys(data.nodes).length) { | ||
store.dispatch('Znode/setStateWithZnodeList', data.nodes); | ||
store.dispatch('Znode/setZnodeCount', data.total); | ||
|
||
if (Object.keys(data.nodes).length < data.total) { | ||
// The list still hasn't loaded yet, and is showing only our own Znodes. Refresh in 5s. | ||
await new Promise((resolve) => setTimeout(resolve, 5000)); | ||
} else { | ||
// The list has loaded. Refresh again in 5 minutes. | ||
await new Promise((resolve) => setTimeout(resolve, 5 * 60 * 1000)); | ||
} | ||
} else { | ||
store.dispatch('Znode/setZnodeCount', data.total); | ||
await new Promise((resolve) => setTimeout(resolve, 5000)); | ||
} | ||
} catch (e) { | ||
// Error -28 is "Loading block index..." | ||
if (e.error && e.error.code === -28) { | ||
logger.warn("initial/znodeList returned error -28, loading block index. Trying again in 1s."); | ||
store.dispatch('Znode/setStateWithZnodeList', {}); | ||
await new Promise((resolve) => setTimeout(resolve, 2000)); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/renderer/components/AnimatedTable/AnimatedTableZnodeActiveSince.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template> | ||
<th | ||
v-if="isHeader" | ||
class="vuetable-th-component-active-since" | ||
@click="$emit('click', rowField, $event)" | ||
v-html="title" | ||
/> | ||
<td | ||
v-else | ||
class="vuetable-td-component-active-since" | ||
:title="absoluteDateString" | ||
> | ||
<timeago | ||
v-if="date" | ||
:datetime="date" | ||
:auto-update="30" | ||
/> | ||
<span v-else> | ||
~ | ||
</span> | ||
</td> | ||
</template> | ||
|
||
<script> | ||
import VuetableFieldMixin from 'vuetable-2/src/components/VuetableFieldMixin.vue' | ||
import { format } from 'date-fns' | ||
export default { | ||
name: 'ZnodeActiveSince', | ||
mixins: [ | ||
VuetableFieldMixin | ||
], | ||
computed: { | ||
date () { | ||
return this.rowData.activeSince | ||
}, | ||
absoluteDateString () { | ||
return format(new Date(this.date), "HH:MM, D MMM YYYY") | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
48 changes: 48 additions & 0 deletions
48
src/renderer/components/AnimatedTable/AnimatedTableZnodeLastSeen.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template> | ||
<th | ||
v-if="isHeader" | ||
class="vuetable-th-component-last-seen" | ||
@click="$emit('click', rowField, $event)" | ||
v-html="title" | ||
/> | ||
<td | ||
v-else | ||
class="vuetable-td-component-last-seen" | ||
:title="absoluteDateString" | ||
> | ||
<timeago | ||
v-if="date" | ||
:datetime="date" | ||
:auto-update="30" | ||
/> | ||
<span v-else> | ||
~ | ||
</span> | ||
</td> | ||
</template> | ||
|
||
<script> | ||
import VuetableFieldMixin from 'vuetable-2/src/components/VuetableFieldMixin.vue' | ||
import { format } from 'date-fns' | ||
export default { | ||
name: 'ZnodeLastSeen', | ||
mixins: [ | ||
VuetableFieldMixin | ||
], | ||
computed: { | ||
date () { | ||
return this.rowData.lastSeen | ||
}, | ||
absoluteDateString () { | ||
return format(new Date(this.date), "HH:MM, D MMM YYYY") | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.