// File: /workspace/github_cpp_makefile_star2_O1/tonymuu[P]distributed-kv-store/MP2Node.cpp
// Function: MP2Node::updateTransactionMap()
void MP2Node::updateTransactionMap() {
    if (txMap.empty()) { // nothing to check here
        return;
    }
    // Go through each entry in the transaction map
    for (auto it = txMap.begin(); it != txMap.end();) {
        int txId = it->first;
        Transaction *transaction = &it->second;

        // if this transaction has enough successful replies, log success
        if (transaction->successCount >= QUORUM) { // operation successful! log success as coordinator
            switch (transaction->type) {
                case READ:
                    log->logReadSuccess(&memberNode->addr, true, txId, transaction->key, transaction->value);
                    break;
                case UPDATE:
                    log->logUpdateSuccess(&memberNode->addr, true, txId, transaction->key, transaction->value);
                    break;
                case CREATE:
                    log->logCreateSuccess(&memberNode->addr, true, txId, transaction->key, transaction->value);
                    break;
                case DELETE:
                    log->logDeleteSuccess(&memberNode->addr, true, txId, transaction->key);
                    break;
                default:
                    break;
            }
            txMap.erase(it++);
            continue;
        }
        // This transaction DOES NOT have enough success replies...
        // So we check if it has reached maximum replies, or it has timed out
        if (transaction->totalCount == TOTAL || par->getcurrtime() - transaction->timestamp > OPERATION_TIMEOUT) { // operation failed :( log failure as coordinator
            switch (transaction->type) {
                case READ:
                    log->logReadFail(&memberNode->addr, true, txId, transaction->key);
                    break;
                case UPDATE:
                    log->logUpdateFail(&memberNode->addr, true, txId, transaction->key, transaction->value);
                    break;
                case CREATE:
                    log->logCreateFail(&memberNode->addr, true, txId, transaction->key, transaction->value);
                    break;
                case DELETE:
                    log->logDeleteFail(&memberNode->addr, true, txId, transaction->key);
                    break;
                default:
                    break;
            }
            txMap.erase(it++);
            continue;
        }
        // otherwise, we don't do anything
        // since if transaction doesn't exist in the map, it's already resolved
        it++;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdi, (%rsp)
cmpq $0x0, 0xe8(%rdi)
je 0xf63f
movq (%rsp), %rax
movq 0xd8(%rax), %r15
addq $0xc8, %rax
movq %rax, 0x100(%rsp)
cmpq %rax, %r15
je 0xf63f
movq (%rsp), %rax
addq $0xc0, %rax
movq %rax, 0x78(%rsp)
leaq 0x28(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x18(%rsp), %r14
leaq 0x58(%rsp), %rbp
leaq 0x38(%rsp), %r13
movl 0x20(%r15), %ebx
cmpl $0x2, 0x28(%r15)
jl 0xf14a
movl 0x38(%r15), %eax
cmpq $0x3, %rax
ja 0xf3b7
leaq 0x9c23(%rip), %rcx      # 0x18c90
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl %ebx, %r13d
movq (%rsp), %rax
movq 0x50(%rax), %rbp
movq 0x68(%rax), %r12
leaq 0x138(%rsp), %rax
movq %rax, 0x128(%rsp)
movq 0x40(%r15), %rsi
movq 0x48(%r15), %rdx
addq %rsi, %rdx
leaq 0x128(%rsp), %r14
movq %r14, %rdi
callq 0x5a48
leaq 0xd0(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0x60(%r15), %rsi
movq 0x68(%r15), %rdx
addq %rsi, %rdx
leaq 0xc0(%rsp), %rbx
movq %rbx, %rdi
callq 0x5a48
addq $0x8, %rbp
movq %r12, %rdi
movq %rbp, %rsi
movl $0x1, %edx
movl %r13d, %ecx
movq %r14, %r8
movq %rbx, %r9
callq 0xc04c
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
leaq 0x18(%rsp), %r12
je 0xf122
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rcx
movq %rcx, %rax
cmpq %rcx, %rdi
leaq 0x58(%rsp), %rbp
leaq 0x38(%rsp), %rcx
movq %r12, %r14
jmp 0xf5b9
cmpl $0x3, 0x2c(%r15)
je 0xf16b
movq (%rsp), %rax
movq 0x58(%rax), %rdi
callq 0xc962
subl 0x34(%r15), %eax
cmpl $0x15, %eax
jl 0xf25f
movl 0x38(%r15), %eax
cmpq $0x3, %rax
ja 0xf3b7
leaq 0x9b00(%rip), %rcx      # 0x18c80
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%rsp), %rax
leaq 0x80(%rsp), %r13
movq 0x50(%rax), %rbp
movq 0x68(%rax), %r12
leaq 0x118(%rsp), %rax
movq %rax, 0x108(%rsp)
movq 0x40(%r15), %rsi
movq 0x48(%r15), %rdx
addq %rsi, %rdx
leaq 0x108(%rsp), %r14
movq %r14, %rdi
callq 0x5a48
leaq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x60(%r15), %rsi
movq 0x68(%r15), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x5a48
addq $0x8, %rbp
movq %r12, %rdi
movq %rbp, %rsi
movl $0x1, %edx
movl %ebx, %ecx
movq %r14, %r8
movq %r13, %r9
callq 0xc406
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
leaq 0x38(%rsp), %rbx
leaq 0x58(%rsp), %rbp
je 0xf236
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rcx
movq %rcx, %rax
cmpq %rcx, %rdi
leaq 0x18(%rsp), %r14
movq %rbx, %r13
jne 0xf3ac
jmp 0xf3b7
movq %r15, %rdi
callq 0x31d0
movq %rax, %r12
jmp 0xf3cf
movl %ebx, %r14d
leaq 0x148(%rsp), %r13
movq (%rsp), %rax
movq 0x50(%rax), %rbp
movq 0x68(%rax), %r12
leaq 0x158(%rsp), %rax
movq %rax, 0x148(%rsp)
movq 0x40(%r15), %rsi
movq 0x48(%r15), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x5a48
leaq 0xf0(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq 0x60(%r15), %rsi
movq 0x68(%r15), %rdx
addq %rsi, %rdx
leaq 0xe0(%rsp), %rbx
movq %rbx, %rdi
callq 0x5a48
addq $0x8, %rbp
movq %r12, %rdi
movq %rbp, %rsi
movl $0x1, %edx
movl %r14d, %ecx
movq %r13, %r8
movq %rbx, %r9
callq 0xc230
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0xf316
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rcx
movq %rcx, %rax
cmpq %rcx, %rdi
leaq 0x58(%rsp), %rbp
jmp 0xf3a0
movq %rbp, %r13
movq (%rsp), %rax
movq 0x50(%rax), %r12
movq 0x68(%rax), %rax
movq %rax, 0x10(%rsp)
addq $0x8, %r12
leaq 0x1b8(%rsp), %r14
movq %r14, 0x1a8(%rsp)
movq 0x40(%r15), %rsi
movq 0x48(%r15), %rdx
addq %rsi, %rdx
movl %ebx, %ebp
leaq 0x1a8(%rsp), %rbx
movq %rbx, %rdi
callq 0x5a48
movq 0x10(%rsp), %rdi
movq %r12, %rsi
movl $0x1, %edx
movl %ebp, %ecx
movq %rbx, %r8
callq 0xc322
movq 0x1a8(%rsp), %rdi
movq %r14, %rax
cmpq %r14, %rdi
movq %r13, %rbp
leaq 0x38(%rsp), %r13
leaq 0x18(%rsp), %r14
je 0xf3b7
movq (%rax), %rsi
incq %rsi
callq 0x32c0
movq %r15, %rdi
callq 0x31d0
movq %rax, %r12
movq 0x78(%rsp), %rdi
movq %r15, %rsi
callq 0x1351c
movq %r12, %r15
cmpq 0x100(%rsp), %r12
jne 0xf049
jmp 0xf63f
movq (%rsp), %rax
movq %r14, %r13
movq %rbp, %r14
movq 0x50(%rax), %rbp
movq 0x68(%rax), %r12
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x40(%r15), %rsi
movq 0x48(%r15), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x5a48
leaq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x60(%r15), %rsi
movq 0x68(%r15), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x5a48
addq $0x8, %rbp
movq %r12, %rdi
movq %rbp, %rsi
movl $0x1, %edx
movl %ebx, %ecx
movq %r13, %rbx
movq %r13, %r8
movq %r14, %rbp
movq %r14, %r9
callq 0xc13e
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
leaq 0x38(%rsp), %r13
je 0xf474
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rcx
movq %rcx, %rax
cmpq %rcx, %rdi
movq %rbx, %r14
jne 0xf3ac
jmp 0xf3b7
movq %r13, %r14
movq (%rsp), %rax
movq 0x50(%rax), %rbp
movq 0x68(%rax), %r12
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x40(%r15), %rsi
movq 0x48(%r15), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x5a48
leaq 0xb0(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0x60(%r15), %rsi
movq 0x68(%r15), %rdx
addq %rsi, %rdx
leaq 0xa0(%rsp), %r13
movq %r13, %rdi
callq 0x5a48
addq $0x8, %rbp
movq %r12, %rdi
movq %rbp, %rsi
movl $0x1, %edx
movl %ebx, %ecx
movq %r14, %r12
movq %r14, %r8
movq %r13, %r9
callq 0xc5dc
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
leaq 0x18(%rsp), %r14
je 0xf532
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rcx
movq %rcx, %rax
cmpq %rcx, %rdi
movq %r12, %r13
jmp 0xf62f
movq (%rsp), %rax
movq 0x50(%rax), %r12
movq 0x68(%rax), %rax
movq %rax, 0x10(%rsp)
addq $0x8, %r12
leaq 0x178(%rsp), %r14
movq %r14, 0x168(%rsp)
movq 0x40(%r15), %rsi
movq 0x48(%r15), %rdx
addq %rsi, %rdx
leaq 0x168(%rsp), %r13
movq %r13, %rdi
callq 0x5a48
movq 0x10(%rsp), %rdi
movq %r12, %rsi
movl $0x1, %edx
movl %ebx, %ecx
movq %r13, %r8
callq 0xc6ce
movq 0x168(%rsp), %rdi
movq %r14, %rax
cmpq %r14, %rdi
leaq 0x18(%rsp), %r14
leaq 0x38(%rsp), %rcx
movq %rcx, %r13
jne 0xf3ac
jmp 0xf3b7
movq (%rsp), %rax
movq 0x50(%rax), %r12
movq 0x68(%rax), %rbp
addq $0x8, %r12
leaq 0x198(%rsp), %r14
movq %r14, 0x188(%rsp)
movq 0x40(%r15), %rsi
movq 0x48(%r15), %rdx
addq %rsi, %rdx
leaq 0x188(%rsp), %r13
movq %r13, %rdi
callq 0x5a48
movq %rbp, %rdi
movq %r12, %rsi
movl $0x1, %edx
movl %ebx, %ecx
movq %r13, %r8
callq 0xc4f8
movq 0x188(%rsp), %rdi
movq %r14, %rax
cmpq %r14, %rdi
leaq 0x38(%rsp), %r13
leaq 0x18(%rsp), %r14
leaq 0x58(%rsp), %rbp
jne 0xf3ac
jmp 0xf3b7
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0xf67e
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x32c0
jmp 0xf67e
movq %rax, %rbx
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
jmp 0xf79b
movq %rax, %rbx
movq 0x188(%rsp), %rdi
jmp 0xf7c8
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0xf6d0
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x32c0
jmp 0xf6d0
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
jmp 0xf79b
movq %rax, %rbx
movq 0x168(%rsp), %rdi
jmp 0xf7c8
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0xf71c
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x32c0
jmp 0xf71c
movq %rax, %rbx
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
jmp 0xf79b
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0xf752
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32c0
jmp 0xf752
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
jmp 0xf7a0
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0xf78b
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x32c0
jmp 0xf78b
movq %rax, %rbx
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq %rax, %rdi
je 0xf7b5
movq 0x8(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x34b0
movq %rax, %rbx
movq 0x1a8(%rsp), %rdi
movq %r14, 0x8(%rsp)
cmpq %r14, %rdi
jne 0xf7a5
jmp 0xf7b5