Skip to content

Commit

Permalink
Patch for v0.1.0-pre.alpha.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rustyspottedcatt committed Feb 9, 2025
1 parent bffb17e commit 6927ee2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/core/consensus/consensus.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::core::consensus::block::produce_block;
use crate::core::consensus::model::ConsensusEngine;
use crate::core::consensus::validator::select_next_validator;
use crate::core::staking::StakingModule;
use crate::core::staking::distribute_rewards;

use ed25519_dalek::{SigningKey, VerifyingKey};
use tokio::time::{sleep, Duration, Instant};
use hex;
use nebula::core::staking::StakingModule;
use crate::core::staking::distribute_rewards;

pub async fn run_consensus_loop(
consensus_engine: &mut ConsensusEngine,
Expand Down
7 changes: 4 additions & 3 deletions src/core/governance/voting.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use std::sync::{Arc};
use ed25519_dalek::SigningKey;
use nebula::core::consensus::math::voting_power;
use crate::core::consensus::math::voting_power;
use crate::core::types::{Vote, VotingNeuron, VotingStatus};
use crate::core::governance::governance::Governance;

use std::sync::{Arc};
use ed25519_dalek::SigningKey;

pub fn vote(
governance: &Governance,
caller: &SigningKey,
Expand Down
6 changes: 4 additions & 2 deletions src/core/staking/rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ pub fn distribute_rewards(
annual_yield_percent: f64,
) {
let mut neurons = staking_module.neurons.lock().unwrap_or_else(|e| e.into_inner());
let total_staked = neurons.values().map(|n| n.staked_amount).sum();
let total_staked: u64 = neurons.values().map(|n| n.staked_amount).sum();

if total_staked == 0 {
return;
}

let total_staked_f64 = total_staked as f64;

for neuron in neurons.values_mut() {
let ratio = neuron.staked_amount as f64 / total_staked as f64;
let ratio = neuron.staked_amount as f64 / total_staked_f64;
let maturity_bonus = 1.0 + (neuron.maturity as f64 / 100.0);
let pool_reward = (reward_pool as f64 * ratio) * maturity_bonus;

Expand Down

0 comments on commit 6927ee2

Please sign in to comment.