Select Git revision
Forked from
Hugo Trentesaux / duniter-vue
Source project has a limited visibility.
-
Hugo Trentesaux authoredHugo Trentesaux authored
current_frame.rs 12.58 KiB
// Copyright (C) 2017-2019 The AXIOM TEAM Association.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Current frame : Interval of blocks taken for the calculation of the personalized difficulty.
//use crate::constants::*;
use crate::*;
extern crate num;
use crate::current_meta_datas::get_current_blockstamp_;
use current_meta_datas::CurrentMetaDataKey;
use dubp_common_doc::BlockNumber;
use durs_dbs_tools::DbError;
use durs_wot::WotId;
use num::Float;
use rkv::store::integer::IntegerStore;
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
/// Describe a member in current frame
pub struct MemberInCurrentFrame {
/// Number of blocks forged by the member in the current frame.
pub forged_blocks: usize,
/// Personal difficulty of the member.
pub difficulty: PersonalDifficulty,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
/// Personal difficulty of a member.
pub struct PersonalDifficulty {
/// Exclusion factor
pub exclusion_factor: usize,
/// handicap
pub handicap: usize,
}
impl Default for PersonalDifficulty {
fn default() -> Self {
PersonalDifficulty {
exclusion_factor: 1,
handicap: 0,
}
}
}
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
/// in frame member info data store
pub struct MemberFrameInfo {
last_personal_block_number: BlockNumber,
last_personal_members_in_frame: usize,
nb_personal_blocks_in_frame: usize,
personal_difficulty: PersonalDifficulty,
}
//impl Default for MemberFrameInfo {
// fn default() -> Self {
// MemberFrameInfo {