Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
Duniter v2S
Commits
925f0938
Commit
925f0938
authored
3 years ago
by
Pascal Engélibert
Committed by
Éloïs
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
opti(ud): mul instead of adds for creating UD
parent
c98260f5
No related branches found
No related tags found
1 merge request
!8
opti(ud): mul instead of adds for creating UD
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pallets/universal-dividend/src/lib.rs
+3
-4
3 additions, 4 deletions
pallets/universal-dividend/src/lib.rs
with
3 additions
and
4 deletions
pallets/universal-dividend/src/lib.rs
+
3
−
4
View file @
925f0938
...
@@ -202,15 +202,14 @@ pub mod pallet {
...
@@ -202,15 +202,14 @@ pub mod pallet {
let
total_weight
:
Weight
=
0
;
let
total_weight
:
Weight
=
0
;
let
ud_amount
=
<
CurrentUdStorage
<
T
>>
::
try_get
()
.expect
(
"corrupted storage"
);
let
ud_amount
=
<
CurrentUdStorage
<
T
>>
::
try_get
()
.expect
(
"corrupted storage"
);
let
mut
monetary_mass
=
<
MonetaryMassStorage
<
T
>>
::
try_get
()
.expect
(
"corrupted storage"
);
let
monetary_mass
=
<
MonetaryMassStorage
<
T
>>
::
try_get
()
.expect
(
"corrupted storage"
);
for
account_id
in
T
::
MembersIds
::
get
()
{
for
account_id
in
T
::
MembersIds
::
get
()
{
T
::
Currency
::
deposit_creating
(
&
account_id
,
ud_amount
);
T
::
Currency
::
deposit_creating
(
&
account_id
,
ud_amount
);
monetary_mass
+=
ud_amount
;
Self
::
write_ud_history
(
n
,
account_id
,
ud_amount
);
Self
::
write_ud_history
(
n
,
account_id
,
ud_amount
);
}
}
<
MonetaryMassStorage
<
T
>>
::
put
(
monetary_mass
);
<
MonetaryMassStorage
<
T
>>
::
put
(
monetary_mass
+
(
ud_amount
*
members_count
)
);
Self
::
deposit_event
(
Event
::
NewUdCreated
(
ud_amount
,
members_count
));
Self
::
deposit_event
(
Event
::
NewUdCreated
(
ud_amount
,
members_count
));
total_weight
total_weight
...
@@ -271,7 +270,7 @@ pub mod pallet {
...
@@ -271,7 +270,7 @@ pub mod pallet {
}
}
// UD(t+1) = UD(t) + c² (M(t+1) / N(t+1)) / (dt/udFrequency)
// UD(t+1) = UD(t) + c² (M(t+1) / N(t+1)) / (dt/udFrequency)
ud_t
+
c_square
*
monetary_mass
/
(
members_count
*
count_uds_beetween_two_reevals
)
ud_t
+
(
c_square
*
monetary_mass
)
/
(
members_count
*
count_uds_beetween_two_reevals
)
}
}
fn
write_ud_history
(
n
:
T
::
BlockNumber
,
account_id
:
T
::
AccountId
,
ud_amount
:
BalanceOf
<
T
>
)
{
fn
write_ud_history
(
n
:
T
::
BlockNumber
,
account_id
:
T
::
AccountId
,
ud_amount
:
BalanceOf
<
T
>
)
{
let
mut
key
=
Vec
::
with_capacity
(
57
);
let
mut
key
=
Vec
::
with_capacity
(
57
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment