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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xavier.perret
perso-distributed-systems
Commits
4a913086
Commit
4a913086
authored
2 years ago
by
Xavier Perret
Browse files
Options
Downloads
Patches
Plain Diff
fake
parent
eba6b368
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/command-line/userinput.go
+21
-9
21 additions, 9 deletions
app/command-line/userinput.go
with
21 additions
and
9 deletions
app/command-line/userinput.go
+
21
−
9
View file @
4a913086
...
...
@@ -72,10 +72,13 @@ func ServerUserInputLoop(config Config, isAlsoServer bool, objectStorage Blob) {
switch
operation
{
case
"1"
:
fmt
.
Println
(
"You chose to fabricate a fake transaction"
)
fmt
.
Println
(
"You chose to fake a transaction"
)
fmt
.
Println
(
"by giving us the id or index of the transaction you wish to modify (=fake)"
)
fmt
.
Println
(
"we will first look for a transaction with the given id then try the index"
)
database
=
ObjectStorageAPI
.
ReadDatabaseFromBlobStorage
(
objectStorage
)
utilities
.
PrintingDatabaseToConsole
(
database
)
fmt
.
Print
(
"
\n
Please enter the index of the transaction you want to overwrite by faking:"
)
fmt
.
Print
(
"
\n
Please enter the index or id of the transaction you want to overwrite by faking:"
)
database
=
ObjectStorageAPI
.
ReadDatabaseFromBlobStorage
(
objectStorage
)
var
transID
string
_
,
err
:=
fmt
.
Scanln
(
&
transID
)
...
...
@@ -83,17 +86,26 @@ func ServerUserInputLoop(config Config, isAlsoServer bool, objectStorage Blob) {
fmt
.
Println
(
"error :"
,
err
.
Error
())
os
.
Exit
(
1
)
}
trans
:=
Transaction
{
Id
:
transID
,
Sender
:
""
,
Receiver
:
""
,
Amount
:
""
,
}
trans
=
ObjectStorageAPI
.
GetTransactionInDatabaseById
(
objectStorage
,
trans
)
if
trans
.
Id
==
""
{
transIDInt
,
err
:=
strconv
.
ParseInt
(
transID
,
10
,
64
)
if
err
!=
nil
{
fmt
.
Println
(
"error :"
,
err
.
Error
())
os
.
Exit
(
1
)
}
trans
=
database
[
transIDInt
]
}
tmpFakeTrans
:=
userCreatedTransaction
(
config
)
database
=
ObjectStorageAPI
.
ReadDatabaseFromBlobStorage
(
objectStorage
)
database
=
ObjectStorageAPI
.
FakeTransaction
(
database
[
transIDInt
],
tmpFakeTrans
,
database
)
database
=
ObjectStorageAPI
.
FakeTransaction
(
trans
,
tmpFakeTrans
,
database
)
ObjectStorageAPI
.
WriteDatabaseToBlobStorage
(
database
,
objectStorage
)
database
=
ObjectStorageAPI
.
ReadDatabaseFromBlobStorage
(
objectStorage
)
fmt
.
Println
(
"Database after faking:"
)
utilities
.
PrintingDatabaseToConsole
(
database
)
...
...
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