[][src]Struct sn_farming::calculation::StorageRewards

pub struct StorageRewards { /* fields omitted */ }

Cost of, and rewards for, storage.

Implementations

impl StorageRewards[src]

pub fn new(base_cost: Money) -> Self[src]

Passed in is the base cost for buying a unit of work.

Trait Implementations

impl Clone for StorageRewards[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]

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,