// File: /workspace/github_cpp_makefile_star2_O1/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 %rbx
subq $0xf0, %rsp
leaq 0x60(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x3451(%rip), %rsi      # 0x6041
leaq 0x3456(%rip), %rdx      # 0x604d
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
callq 0x376e
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
movl $0xc70f6907, %edx       # imm = 0xC70F6907
callq 0x2060
leaq 0x30(%rsp), %rdi
movq %rax, %rsi
callq 0x2442
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c39
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0x20(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x3405(%rip), %rsi      # 0x604e
leaq 0x340b(%rip), %rdx      # 0x605b
leaq 0x10(%rsp), %rdi
callq 0x376e
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0xc70f6907, %edx       # imm = 0xC70F6907
callq 0x2060
leaq 0x40(%rsp), %rdi
movq %rax, %rsi
callq 0x2442
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c92
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0x3c7(%rip), %rdx       # 0x3060
leaq 0x70(%rsp), %rdi
movss 0x335e(%rip), %xmm0     # 0x6004
movl $0x2, %esi
callq 0x30de
movq 0x38(%rsp), %rbx
movq 0x48(%rsp), %rax
xorl %r15d, %r15d
leaq 0xc8(%rsp), %r14
movq %r15, 0x18(%r14)
movq %rbx, (%r14)
movq %rax, 0x8(%r14)
movl $0x447a0000, 0x10(%r14) # imm = 0x447A0000
callq 0x2200
movq %rax, 0x18(%r14)
movq %r15, 0x20(%r14)
movq 0x30(%rsp), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x31d6
leaq 0x70(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x335c
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x340a
movq 0x62b2(%rip), %rbx      # 0x8fd0
movq %r14, %r15
movq (%r15), %r15
cmpq %r14, %r15
je 0x2d37
leaq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0x34f6
jmp 0x2d21
movq 0x6292(%rip), %rdi      # 0x8fd0
leaq 0x3317(%rip), %rsi      # 0x605c
movl $0x12, %edx
callq 0x21c0
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
callq 0x3602
movzbl %al, %esi
movq 0x626a(%rip), %rdi      # 0x8fd0
callq 0x2270
movq 0x625e(%rip), %rdi      # 0x8fd0
leaq 0x32f6(%rip), %rsi      # 0x606f
movl $0xf, %edx
callq 0x21c0
movq 0x70(%rsp), %r15
cmpq %rbx, %r15
je 0x2dc2
movq 0x48(%rsp), %r14
xorps %xmm0, %xmm0
movss %xmm0, 0xc(%rsp)
leaq 0x10(%r15), %rdi
movq %r14, %rsi
callq 0x5ad0
movss 0xc(%rsp), %xmm1
addss %xmm0, %xmm1
movaps %xmm1, %xmm0
movq (%r15), %r15
cmpq %rbx, %r15
jne 0x2d95
cvtss2sd %xmm0, %xmm0
jmp 0x2dc5
xorps %xmm0, %xmm0
movq 0x6204(%rip), %rdi      # 0x8fd0
callq 0x2250
movq 0x61f8(%rip), %rdi      # 0x8fd0
leaq 0x32a0(%rip), %rsi      # 0x607f
movl $0xe, %edx
callq 0x21c0
movq 0x70(%rsp), %r15
cmpq %rbx, %r15
je 0x2e28
movq 0x38(%rsp), %r14
xorps %xmm0, %xmm0
movss %xmm0, 0xc(%rsp)
leaq 0x10(%r15), %rdi
movq %r14, %rsi
callq 0x5ad0
movss 0xc(%rsp), %xmm1
addss %xmm0, %xmm1
movaps %xmm1, %xmm0
movq (%r15), %r15
cmpq %rbx, %r15
jne 0x2dfb
cvtss2sd %xmm0, %xmm0
jmp 0x2e2b
xorps %xmm0, %xmm0
movq 0x619e(%rip), %rdi      # 0x8fd0
callq 0x2250
leaq 0x88(%rsp), %rdi
callq 0x36e6
leaq 0x70(%rsp), %rdi
callq 0x3736
xorl %eax, %eax
addq $0xf0, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x2ebc
movq 0x20(%rsp), %rsi
jmp 0x2e8a
jmp 0x2e94
movq %rax, %rbx
jmp 0x2ebc
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x2ebc
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0x2ebc
movq %rax, %rdi
callq 0x3660
jmp 0x2ea2
jmp 0x2ea2
jmp 0x2ea2
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x36e6
leaq 0x70(%rsp), %rdi
callq 0x3736
movq %rbx, %rdi
callq 0x22a0