Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
djq2
ECE 428 - Distributed Systems
Commits
64cb4446
Commit
64cb4446
authored
May 02, 2022
by
Kevin Villanueva
Browse files
fdasf
parent
a68e8eb7
Changes
1
Hide whitespace changes
Inline
Side-by-side
mp3/src/servers/coordinator.go
View file @
64cb4446
...
...
@@ -288,6 +288,8 @@ func (host *Server) Coordinator(name string) {
if
msg
.
Command
==
"ABORT"
{
fmt
.
Println
(
"Started Abort."
)
host
.
abort
()
client_out
:=
Client_resp
{
Success
:
true
,
Msg
:
"ABORTED"
}
host
.
client_write
(
client_out
)
return
}
if
msg
.
Command
==
"COMMIT"
{
...
...
@@ -723,6 +725,14 @@ func (host *Server) abort() {
// - Careful about timing with threads, make sure all updates are done
func
(
host
*
Server
)
commit
()
{
// Iterate Local Transaction
for
_
,
data
:=
range
host
.
Tr
.
Accounts
{
if
data
.
Balance
<
0
{
host
.
abort
()
client_out
:=
Client_resp
{
Success
:
false
,
Msg
:
"ABORTED"
}
host
.
client_write
(
client_out
)
return
}
}
for
acc
,
data
:=
range
host
.
Tr
.
Accounts
{
div
:=
strings
.
Split
(
acc
,
"."
)
acc_name
:=
div
[
1
]
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment