This repository was archived by the owner on Aug 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPoolWidget.js
More file actions
112 lines (105 loc) · 2.66 KB
/
PoolWidget.js
File metadata and controls
112 lines (105 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import React, { Component } from 'react';
import axios from 'axios';
import {round, devide} from 'lodash';
import {
View,
Text,
StyleSheet,
} from 'react-native';
export default class PoolWidget extends Component {
state = {
pool: this.props.pool,
loaded: false,
}
componentDidMount() {
this.getEthPoolData();
}
getEthPoolData = () => {
const {pool: {minerAddress, poolUrl}} = this.state
axios.get(`${poolUrl}/miner/${minerAddress}/currentStats`)
.then((response) => {
this.setState({
poolData: response.data.data,
loaded: true,
})
})
.catch((error) => {
console.log(error);
});
}
render() {
if (!this.state.loaded) {
return (
<View>
<Text>
Loading...
</Text>
</View>
)
}
const {pool: {poolName, minerAddress}, poolData} =this.state
const {reportedHashrate, currentHashrate, averageHashrate, validShares, unpaid} = poolData
const reportedHashRateRound = round((reportedHashrate / 1000000), 2)
const currentHashrateRound = round((currentHashrate / 1000000), 2)
const averageHashrateRound = round((averageHashrate / 1000000), 2)
const unpaidSumRounded = unpaid / 1000000000000000000
console.log(unpaidSumRounded)
return (
<View style={styles.container}>
<Text style={styles.poolTitle}>
{poolName}
</Text>
<Text style={styles.poolAddress}>
{minerAddress}
</Text>
<View style={styles.poolStats}>
{poolData &&
<View>
<View style={styles.hashRates}>
<Text>Reported hashrate: {reportedHashRateRound} MH/s</Text>
<Text>Current hashrate: {currentHashrateRound} MH/s</Text>
<Text>Average hashRates: {averageHashrateRound} MH/s</Text>
</View>
<View style={styles.workersStat}>
<Text>Valid shares in last 1h: {validShares}</Text>
<Text>Upaid ballance: {unpaidSumRounded} </Text>
</View>
</View>
}
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
//flex: 1,
borderWidth: 1,
padding: 10,
borderRadius: 3,
marginBottom: 10,
},
poolTitle: {
textAlign: "center",
fontSize: 30,
color: '#555',
marginBottom: 10,
},
poolAddress: {
textAlign: 'center',
marginBottom: 10,
},
hashRates: {
flex: 1,
},
hashRates: {
paddingTop: 10,
borderTopWidth: 1,
paddingBottom: 10,
},
workersStat: {
paddingTop: 10,
borderTopWidth: 1,
paddingBottom: 10,
}
});