Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter-squid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
duniter-squid
Merge requests
!27
add balance to accounts
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
add balance to accounts
account-balance
into
main
Overview
34
Commits
10
Pipelines
0
Changes
3
Open
poka
requested to merge
account-balance
into
main
2 months ago
Overview
7
Commits
10
Pipelines
0
Changes
3
Expand
close
#11
Edited
2 months ago
by
poka
0
0
Merge request reports
Viewing commit
b973edb0
Show latest version
3 files
+
246
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
b973edb0
add balances events
· b973edb0
poka
authored
2 months ago
src/data_handler.ts
+
63
−
0
Options
@@ -113,6 +113,68 @@ export class DataHandler {
await
this
.
updateAccountBalance
(
ctx
,
transfer
.
to
,
transfer
.
amount
);
}
// Process deposits
for
(
const
deposit
of
newData
.
deposits
)
{
ctx
.
log
.
info
(
`New deposit:
${
deposit
.
address
}
received
${
deposit
.
amount
}
tokens`
);
await
this
.
updateAccountBalance
(
ctx
,
deposit
.
address
,
deposit
.
amount
);
}
// Process withdraws
for
(
const
withdraw
of
newData
.
withdraws
)
{
ctx
.
log
.
info
(
`New withdraw:
${
withdraw
.
address
}
withdrew
${
withdraw
.
amount
}
tokens`
);
await
this
.
updateAccountBalance
(
ctx
,
withdraw
.
address
,
-
withdraw
.
amount
);
}
// Process reserved amounts
for
(
const
reserved
of
newData
.
reserved
)
{
ctx
.
log
.
info
(
`New reserve:
${
reserved
.
address
}
reserved
${
reserved
.
amount
}
tokens`
);
await
this
.
updateAccountBalance
(
ctx
,
reserved
.
address
,
-
reserved
.
amount
);
}
// Process unreserved amounts
for
(
const
unreserved
of
newData
.
unreserved
)
{
ctx
.
log
.
info
(
`New unreserve:
${
unreserved
.
address
}
unreserved
${
unreserved
.
amount
}
tokens`
);
await
this
.
updateAccountBalance
(
ctx
,
unreserved
.
address
,
unreserved
.
amount
);
}
// Process endowed accounts
for
(
const
endowed
of
newData
.
endowed
)
{
ctx
.
log
.
info
(
`New endowed account:
${
endowed
.
address
}
received initial balance of
${
endowed
.
amount
}
tokens`
);
const
account
=
await
this
.
getOrCreateAccount
(
ctx
,
endowed
.
address
);
account
.
createdOn
=
endowed
.
blockNumber
;
account
.
balance
=
endowed
.
amount
;
this
.
data
.
accounts
.
set
(
endowed
.
address
,
account
);
}
// Process dust lost accounts
for
(
const
dustLost
of
newData
.
dustLost
)
{
ctx
.
log
.
info
(
`Dust lost:
${
dustLost
.
address
}
lost
${
dustLost
.
amount
}
tokens due to falling below existential deposit`
);
const
account
=
await
this
.
getAccountByAddressOrFail
(
ctx
,
dustLost
.
address
);
account
.
balance
=
0
n
;
account
.
isActive
=
false
;
this
.
data
.
accounts
.
set
(
dustLost
.
address
,
account
);
}
// Process slashed accounts
for
(
const
slashed
of
newData
.
slashed
)
{
ctx
.
log
.
info
(
`Account slashed:
${
slashed
.
address
}
lost
${
slashed
.
amount
}
tokens due to misbehavior`
);
await
this
.
updateAccountBalance
(
ctx
,
slashed
.
address
,
-
slashed
.
amount
);
}
// Process comments
for
(
const
commentEvt
of
newData
.
comments
)
{
const
sender
=
await
this
.
getAccountByAddressOrFail
(
ctx
,
commentEvt
.
sender
);
@@ -650,7+712,7 @@
await
ctx
.
store
.
insert
(
identities
);
await
ctx
.
store
.
commit
();
}
/// store prepared data into database
async
storeData
(
ctx
:
Ctx
)
{
// UPSERT = update or insert if not existing
@@ -687,7+749,7 @@
// we need to create it
account
=
new
Account
({
id
,
createdOn
:
ctx
.
blocks
[
0
].
header
.
height
,
isActive
:
true
,
balance
:
0
n
});
Loading