Commit 64cb4446 authored by Kevin Villanueva's avatar Kevin Villanueva
Browse files

fdasf

parent a68e8eb7
......@@ -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]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment