Skip to content

Commit

Permalink
fixes for validators that have not yet been activated, loading screen…
Browse files Browse the repository at this point in the history
… fixes on block tab
  • Loading branch information
manuelsc committed Nov 2, 2022
1 parent 4e6db30 commit 00eb597
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 35 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "in.beaconcha.mobile"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 81
versionName "4.0.1"
versionCode 82
versionName "4.0.2"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
17 changes: 9 additions & 8 deletions src/app/controllers/OverviewController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default class OverviewController {
return cur.data.activationepoch <= currentEpoch.epoch ? cur.data.effectivebalance : new BigNumber(0)
});
const investedBalance = this.sumBigIntBalanceRpl(validators, cur => {
return cur.data.activationepoch <= currentEpoch.epoch ? new BigNumber(cur.data.effectivebalance.toString()) : new BigNumber(0)
return new BigNumber(cur.data.effectivebalance.toString())
});

const aprPerformance31dConsensus = sumBigInt(validators, cur => cur.data.performance31d);
Expand Down Expand Up @@ -158,12 +158,13 @@ export default class OverviewController {
total: consensusPerf.total.plus(executionPerf.total),
}

var attrEffectiveness = -1
attrEffectiveness = sumBigInt(validators, cur => cur.attrEffectiveness ? new BigNumber(cur.attrEffectiveness.toString()): new BigNumber(0))
var attrEffectiveness = 0
if (activeValidators.length > 0) {
attrEffectiveness = sumBigInt(validators, cur => cur.attrEffectiveness ? new BigNumber(cur.attrEffectiveness.toString()): new BigNumber(0))
.dividedBy(activeValidators.length)
.decimalPlaces(1).toNumber();
}


const bestRank = findLowest(validators, cur => cur.data.rank7d)
const worstRank = findHighest(validators, cur => cur.data.rank7d)
const rocketpoolValiCount = sumBigInt(validators, cur => cur.rocketpool ? new BigNumber(1) : new BigNumber(0))
Expand Down Expand Up @@ -296,7 +297,6 @@ export default class OverviewController {

const aprConsensus = this.getAPRFromMonth(effectiveBalanceActive, aprPerformance31dConsensus)

console.log("stuff", performance365d.toString(), total.toString())
return {
performance1d: performance1d,
performance31d: performance31d,
Expand Down Expand Up @@ -331,10 +331,11 @@ export default class OverviewController {
sumBigIntBalanceRpl<T>(validators: Validator[], field: (cur: Validator) => BigNumber): BigNumber {

return sumBigInt(validators, cur => {
if (!cur.rocketpool) return field(cur).multipliedBy(new BigNumber(cur.share == null ? 1 : cur.share))
if (!cur.rocketpool.node_address) return field(cur).multipliedBy(new BigNumber(cur.share == null ? 1 : cur.share))
const fieldVal = field(cur)
if (!cur.rocketpool) return fieldVal.multipliedBy(new BigNumber(cur.share == null ? 1 : cur.share))
if (!cur.rocketpool.node_address) return fieldVal.multipliedBy(new BigNumber(cur.share == null ? 1 : cur.share))

const rewards = new BigNumber(field(cur).toString()).minus(cur.data.effectivebalance)
const rewards = new BigNumber(fieldVal.toString()).minus(cur.data.effectivebalance)
const nodeOperatorRewards = new BigNumber(rewards).multipliedBy(new BigNumber("1").plus(new BigNumber(cur.rocketpool.minipool_node_fee.toString()))).dividedBy("2")
const wholeBalance = new BigNumber("16000000000").plus(nodeOperatorRewards)
return wholeBalance.multipliedBy(new BigNumber(cur.share == null ? 1 : cur.share))
Expand Down
6 changes: 3 additions & 3 deletions src/app/tab-blocks/tab-blocks.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
</ion-refresher>

<p class="next-block-hint" *ngIf="nextBlockEstimate">
<span *ngIf="!(nextBlockEstimate | timeago).includes('ago')">Next block estimated to arrive in</span>
<span *ngIf="(nextBlockEstimate| timeago).includes('ago')">Next block was estimated to arrive</span>
<span *ngIf="!(nextBlockEstimate | timeago).includes('ago')">On average next block expected in</span>
<span *ngIf="(nextBlockEstimate| timeago).includes('ago')">On average next block was expected</span>
<br/>
<span style="font-style: normal;">~{{ nextBlockEstimate | timeago }}
</span>
Expand Down Expand Up @@ -58,7 +58,7 @@ <h2 >No Blocks so far</h2>
<ion-label>Your proposed blocks will show up here.</ion-label>
</div>

<div id="container" *ngIf="loading" class="fadein fadeout">
<div id="container" *ngIf="loading && !initialized" class="fadein fadeout">
<div class="center">
<ion-spinner class="status-icon loading-spinner"></ion-spinner>
</div>
Expand Down
20 changes: 2 additions & 18 deletions src/app/tab-blocks/tab-blocks.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class TabBlocksPage implements OnInit {
let blocks = await this.blockUtils.getMyBlocks(initial ? 0 : this.items.length)
if (initial) {
this.items = blocks
this.initialized = true
} else {
this.items = this.items.concat(blocks)
}
Expand All @@ -104,24 +105,7 @@ export class TabBlocksPage implements OnInit {
}

private setLoading(loading: boolean) {
if (loading) {
// Reasoning: Don't show loading indicator if it takes less than 400ms (already cached locally but storage is slow-ish so we adjust for that)
setTimeout(() => {
if (!this.items || this.items.length <= 0) {
this.loading = true
}
}, 200)
} else {
if (this.loading) {
setTimeout(() => {
this.initialized = true
this.loading = false
}, 350)
} else {
this.initialized = true
this.loading = false
}
}
this.loading = loading
}

async clickBlock(item: BlockResponse) {
Expand Down
8 changes: 4 additions & 4 deletions src/app/utils/BlockUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ export class BlockUtils extends CacheModule {
return WEEK
} else if (diff < MONTH) {
return MONTH
} else if (diff < SIXWEEKS && blocksPer30d <= 2.2) {
} else if (diff < SIXWEEKS && blocksPer30d <= 2.25) {
return SIXWEEKS
} else if (diff < TWOEMONTH && blocksPer30d <= 1.6) {
} else if (diff < TWOEMONTH && blocksPer30d <= 1.65) {
return TWOEMONTH
} else if (diff < THREEMONTH && blocksPer30d <= 0.95) {
} else if (diff < THREEMONTH && blocksPer30d <= 0.97) {
return THREEMONTH
} else if (diff < FOURMONTH && blocksPer30d <= 0.55) {
} else if (diff < FOURMONTH && blocksPer30d <= 0.60) {
return FOURMONTH
}

Expand Down

0 comments on commit 00eb597

Please sign in to comment.