Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
perso-distributed-systems
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Show more breadcrumbs
xavier.perret
perso-distributed-systems
Commits
6873ed4e
Commit
6873ed4e
authored
2 years ago
by
Xavier Perret
Browse files
Options
Downloads
Patches
Plain Diff
added utilities function for cleaner code
parent
cfa22be3
No related branches found
No related tags found
1 merge request
!2
added file to separate client function from the server
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/utilities/utilities.go
+43
-0
43 additions, 0 deletions
app/utilities/utilities.go
with
43 additions
and
0 deletions
app/utilities/utilities.go
0 → 100644
+
43
−
0
View file @
6873ed4e
package
utilities
import
(
"fmt"
.
"node/types"
)
func
PrintTransaction
(
trans
Transaction
)
{
fmt
.
Println
(
"--------------------"
)
fmt
.
Println
(
"Printing transaction"
)
fmt
.
Println
(
"The id is "
,
trans
.
Id
)
fmt
.
Println
(
"The sender is "
,
trans
.
Sender
)
fmt
.
Println
(
"The receiver is "
,
trans
.
Receiver
)
fmt
.
Println
(
"The amount is "
,
trans
.
Amount
)
fmt
.
Println
(
"--------------------"
)
}
func
ListAllTransactions
(
db
Database
)
{
for
i
,
transaction
:=
range
db
{
fmt
.
Println
(
"***********INDEX N=,"
,
i
,
"****************"
)
PrintTransaction
(
transaction
)
fmt
.
Println
(
"***********************************"
)
}
}
func
PrintNeighbors
(
neighbors
[]
Neighbors
)
{
fmt
.
Println
(
"Printing neighbors"
)
for
i
,
neighbor
:=
range
neighbors
{
fmt
.
Println
(
"***********INDEX N=,"
,
i
,
"****************"
)
fmt
.
Println
(
"The id is "
,
neighbor
.
ID
)
fmt
.
Println
(
"The address is "
,
neighbor
.
Address
)
fmt
.
Println
(
"The port is "
,
neighbor
.
Port
)
fmt
.
Println
(
"***********************************"
)
}
}
func
PrintConfig
(
config
Config
)
{
fmt
.
Println
(
"Printing config"
)
fmt
.
Println
(
"The id is "
,
config
.
ID
)
fmt
.
Println
(
"The address is "
,
config
.
Address
)
fmt
.
Println
(
"The port is "
,
config
.
Port
)
PrintNeighbors
(
config
.
Neighbours
)
}
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