Skip to content
Snippets Groups Projects
Commit 64cb4446 authored by Kevin Villanueva's avatar Kevin Villanueva
Browse files

fdasf

parent a68e8eb7
No related branches found
No related tags found
No related merge requests found
...@@ -288,6 +288,8 @@ func (host *Server) Coordinator(name string) { ...@@ -288,6 +288,8 @@ func (host *Server) Coordinator(name string) {
if msg.Command == "ABORT" { if msg.Command == "ABORT" {
fmt.Println("Started Abort.") fmt.Println("Started Abort.")
host.abort() host.abort()
client_out := Client_resp{Success: true, Msg: "ABORTED"}
host.client_write(client_out)
return return
} }
if msg.Command == "COMMIT" { if msg.Command == "COMMIT" {
...@@ -723,6 +725,14 @@ func (host *Server) abort() { ...@@ -723,6 +725,14 @@ func (host *Server) abort() {
// - Careful about timing with threads, make sure all updates are done // - Careful about timing with threads, make sure all updates are done
func (host *Server) commit() { func (host *Server) commit() {
// Iterate Local Transaction // 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 { for acc, data := range host.Tr.Accounts {
div := strings.Split(acc, ".") div := strings.Split(acc, ".")
acc_name := div[1] acc_name := div[1]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment