fix avergae not calculated correctly

This commit is contained in:
Jonathan Rainville 2018-09-04 11:17:02 -04:00 committed by Pascal Precht
parent 592ce4773c
commit 7fa186b636
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
2 changed files with 7 additions and 2 deletions

View File

@ -34,7 +34,7 @@ class GasStation extends Component {
}).map(gasPrice => { }).map(gasPrice => {
totalWait += this.props.gasOracleStats[gasPrice].totalWait; totalWait += this.props.gasOracleStats[gasPrice].totalWait;
totalTxs += this.props.gasOracleStats[gasPrice].nbTxs; totalTxs += this.props.gasOracleStats[gasPrice].nbTxs;
totalGasPrice = gasPrice * this.props.gasOracleStats[gasPrice].nbTxs; totalGasPrice += gasPrice * this.props.gasOracleStats[gasPrice].nbTxs;
return { return {
gasPrice, gasPrice,
wait: this.props.gasOracleStats[gasPrice].averageWait >= 0.1 ? this.props.gasOracleStats[gasPrice].averageWait : 0.1 wait: this.props.gasOracleStats[gasPrice].averageWait >= 0.1 ? this.props.gasOracleStats[gasPrice].averageWait : 0.1

View File

@ -28,7 +28,12 @@ class TransactionTracker {
} }
block.transactions.forEach(transaction => { block.transactions.forEach(transaction => {
if (this.transactions[transaction.hash]) { if (this.transactions[transaction.hash]) {
Object.assign(this.transactions[transaction.hash], transaction, {endTimestamp: block.timestamp, wait: block.timestamp - this.transactions[transaction.hash].startTimestamp}); let wait = block.timestamp - this.transactions[transaction.hash].startTimestamp;
if (wait < 0.1) {
wait = 0.1;
}
Object.assign(this.transactions[transaction.hash],
{endTimestamp: block.timestamp, wait, gasPrice: transaction.gasPrice});
} }
}); });
this.events.emit('blockchain:gas:oracle:new'); this.events.emit('blockchain:gas:oracle:new');