Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dunitrust
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
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is archived. Its data is
read-only
.
Show more breadcrumbs
nodes
rust
Dunitrust
Commits
cf7481b3
Commit
cf7481b3
authored
May 4, 2019
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[feat] blockchain: manage amount base change
parent
de4b5098
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!144
Elois/fix gt sync
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/blockchain/blockchain-dal/src/entities/sources.rs
+20
-6
20 additions, 6 deletions
...modules/blockchain/blockchain-dal/src/entities/sources.rs
with
20 additions
and
6 deletions
lib/modules/blockchain/blockchain-dal/src/entities/sources.rs
+
20
−
6
View file @
cf7481b3
...
...
@@ -44,22 +44,36 @@ impl Ord for SourceAmount {
impl
Add
for
SourceAmount
{
type
Output
=
SourceAmount
;
fn
add
(
self
,
s2
:
SourceAmount
)
->
Self
::
Output
{
if
self
.1
==
s2
.1
{
SourceAmount
(
self
.0
+
s2
.0
,
self
.1
)
let
(
mut
s_min
,
s_max
)
=
if
self
.1
>
s2
.1
{
(
s2
,
self
)
}
else
{
fatal_error!
(
"Source change base not yet supported !"
)
(
self
,
s2
)
};
while
s_min
.1
<
s_max
.1
{
(
s_min
.0
)
.0
/=
10
;
(
s_min
.1
)
.0
+=
1
;
}
SourceAmount
(
s_min
.0
+
s_max
.0
,
s_max
.1
)
}
}
impl
Sub
for
SourceAmount
{
type
Output
=
SourceAmount
;
fn
sub
(
self
,
s2
:
SourceAmount
)
->
Self
::
Output
{
if
self
.1
==
s2
.1
{
SourceAmount
(
self
.0
-
s2
.0
,
self
.1
)
let
(
mut
s_min
,
s_max
)
=
if
self
.1
>
s2
.1
{
(
s2
,
self
)
}
else
{
fatal_error!
(
"Source change base not yet supported !"
)
(
self
,
s2
)
};
while
s_min
.1
<
s_max
.1
{
(
s_min
.0
)
.0
/=
10
;
(
s_min
.1
)
.0
+=
1
;
}
SourceAmount
(
s_min
.0
-
s_max
.0
,
s_max
.1
)
}
}
...
...
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
sign in
to comment