[−][src]Struct sn_farming::calculation::StorageRewards
Cost of, and rewards for, storage.
Implementations
impl StorageRewards
[src]
Trait Implementations
impl Clone for StorageRewards
[src]
fn clone(&self) -> StorageRewards
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl RewardAlgo for StorageRewards
[src]
Explanation A unit of Work is defined as, and registered, based on what ever scheme the implementing layer decides.
New rewards are paid proportionally to Work performed.
Implications of StorageRewards design
StorageRewards
does not define Work, and thus what
increases the participants registered Work.
It could be that p.work += rewards[p.id]
it could also be that p.work += 1
for everytime they get a(ny) reward.
But it could actually be anything.
The current implementation in accumulation.rs
uses p.work += 1
for every reward received (any amount).
The implications of this, is that no matter how small your reward is,
your contribution is recorded as equal to any other. This means, that we are defining a WorkUnit
as a measurement of time participating
.
In our context, that means that we decide how much the value of you storing
x bytes
is, depending on for how long you have been around doing that - relative to everyone else.
Receiving some data when new, is not as appreciated as after having been there relatively long. Because, after all, maybe you're just disappearing shortly, and introducing a lot of work to the others to replicate the data you were supposed to hold. Still though, it is rewarded higher to receive more data, than less data, regardless of how new/old you are, which reflects in the total rewards being higher for more data. In other words: even though the newer participant's share is still smaller relatively to the others, it is higher absolutely, compared to if they'd all be receiving less data.
This is the rationale and reasoning behind accumulation.rs
defining a WorkUnit
as having received data (no matter how much).
The WorkUnit
is closely related to NodeAge
, and is a way to capture the higher level design decision of
rewards being proportional to NodeAge
, while decoupling it from the actual implementation of NodeAge
(which is low granular).
Another implementation of RewardAlgo
, might want to use something else than NodeAge
, and thus use another way
to account for Work
; another definition of a WorkUnit
.
fn set(&mut self, base_cost: Money)
[src]
Use this to update the base cost, as per any desired formula and frequency.
fn work_cost(&self, num_bytes: u64) -> Money
[src]
Here, reward units are the number of bytes to store.
fn total_reward(&self, factor: f64, work_cost: Money) -> Money
[src]
Use the factor to scale the reward per any desired function of parameters relevant to the implementing layer. In SAFE Network context, the factor could be the output of a function of node count, section count, percent filled etc. etc.
fn distribute(
&self,
total_reward: Money,
accounts_work: HashMap<AccountId, Work>
) -> HashMap<AccountId, Money>
[src]
&self,
total_reward: Money,
accounts_work: HashMap<AccountId, Work>
) -> HashMap<AccountId, Money>
Distribute the reward according to the accumulated work associated with the ids. Also returns those who got 0 reward (when their work or total_reward wasn't high enough).
Auto Trait Implementations
impl RefUnwindSafe for StorageRewards
impl Send for StorageRewards
impl Sync for StorageRewards
impl Unpin for StorageRewards
impl UnwindSafe for StorageRewards
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,