// File: /workspace/github_cpp_makefile_star2_O2/ra101[P]Generic-BlockChain-container-cpp/main.cpp
// Function: main
int main()
{
  ra::rsa_key_pair k1("127.0.0.1:80");
  ra::rsa_key_pair k2("189.0.2.47:52");

  ra::block_chain<custom_transaction, std::hash<std::string>> ra_coin(MED_DIFFICULTY, ra::verify, 50);
  // ra::block_chain<custom_transaction, std::hash<std::string>> ra_coin(MAX_DIFFICULTY, ra::verify);

  custom_transaction t1(k1.get_public_key(), k2.get_public_key(), 1000);

  /*
    Update the line below in the following manner to get the following exceptions
    comment it -> Invalid Transaction Error
    duplicate it -> Resign Exception
    replace k1 with k2 -> Mismatch
  */
  t1.sign_transaction<ra::rsa_key_pair>(k1);

  ra_coin.add_transaction(t1);

  ra_coin.mine_pending_transactions(k1.get_public_key());

  for (ra::block_chain<custom_transaction, std::hash<std::string>>::iterator abc = ra_coin.begin(); abc != ra_coin.end(); abc++)
  {
    std::cout << *abc;
  }
  std::cout << "\n\nIs Chain Valid: " << ra_coin.is_chain_valid();

  std::cout << "\n\nk2 balance : " << ra_coin.get_balance(k2.get_public_key());
  std::cout << "\nk1 balance : " << ra_coin.get_balance(k1.get_public_key());
  return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe0, %rsp
leaq 0x274c(%rip), %rsi      # 0x6031
leaq 0x40(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0x3c38
movq %rsp, %rdi
leaq 0x40(%rsp), %rsi
callq 0x357a
leaq 0x40(%rsp), %rdi
callq 0x30f0
leaq 0x272c(%rip), %rsi      # 0x603e
leaq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0x3c38
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x357a
leaq 0x10(%rsp), %rdi
callq 0x30f0
leaq 0x332(%rip), %rdx       # 0x3c73
leaq 0x60(%rsp), %rdi
pushq $0x2
popq %rsi
movss 0x26b3(%rip), %xmm0     # 0x6004
callq 0x3cae
movq 0x8(%rsp), %rbx
movq 0x38(%rsp), %r14
leaq 0xb8(%rsp), %r15
movq %rbx, (%r15)
movq %r14, 0x8(%r15)
movl $0x447a0000, 0x10(%r15) # imm = 0x447A0000
callq 0x3260
movq %rax, 0x18(%r15)
andq $0x0, 0x20(%r15)
movq (%rsp), %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x3d8e
leaq 0x60(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x3ece
leaq 0x60(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3f64
movq 0x6613(%rip), %r12      # 0x9fd0
movq %r15, %r13
movq (%r13), %r13
cmpq %r15, %r13
je 0x39d7
leaq 0x10(%r13), %rsi
movq %r12, %rdi
callq 0x403c
jmp 0x39c0
movq 0x65f2(%rip), %rdi      # 0x9fd0
leaq 0x2667(%rip), %rsi      # 0x604c
callq 0x31b0
movq %rax, %r15
leaq 0x60(%rsp), %rdi
callq 0x411e
movzbl %al, %esi
movq %r15, %rdi
callq 0x32d0
movq 0x65c7(%rip), %rdi      # 0x9fd0
leaq 0x264f(%rip), %rsi      # 0x605f
callq 0x31b0
movq %rax, %r15
leaq 0x60(%rsp), %rdi
movq %r14, %rsi
callq 0x417c
movq %r15, %rdi
callq 0x3160
movq 0x659c(%rip), %rdi      # 0x9fd0
leaq 0x2634(%rip), %rsi      # 0x606f
callq 0x31b0
movq %rax, %r14
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x417c
movq %r14, %rdi
callq 0x3160
leaq 0x60(%rsp), %rdi
callq 0x41ce
xorl %eax, %eax
addq $0xe0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
jmp 0x3a89
jmp 0x3a90
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x30f0
jmp 0x3aa4
movq %rax, %rbx
jmp 0x3aa4
jmp 0x3a97
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x41ce
movq %rbx, %rdi
callq 0x3300