// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
subq $0xe8, %rsp
leaq 0x48(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x346b(%rip), %rsi      # 0x6061
leaq 0x3470(%rip), %rdx      # 0x606d
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0x3778
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
movl $0xc70f6907, %edx       # imm = 0xC70F6907
callq 0x2060
leaq 0x28(%rsp), %rdi
movq %rax, %rsi
callq 0x2442
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c3f
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x341f(%rip), %rsi      # 0x606e
leaq 0x3425(%rip), %rdx      # 0x607b
leaq 0x8(%rsp), %rdi
callq 0x3778
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl $0xc70f6907, %edx       # imm = 0xC70F6907
callq 0x2060
leaq 0x58(%rsp), %rdi
movq %rax, %rsi
callq 0x2442
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c98
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0x3c1(%rip), %rdx       # 0x3060
leaq 0x68(%rsp), %rdi
movss 0x3358(%rip), %xmm0     # 0x6004
movl $0x2, %esi
callq 0x30de
movq 0x30(%rsp), %r14
movq 0x60(%rsp), %rbx
leaq 0xc0(%rsp), %r15
movq %r14, (%r15)
movq %rbx, 0x8(%r15)
movl $0x447a0000, 0x10(%r15) # imm = 0x447A0000
callq 0x2200
movq %rax, 0x18(%r15)
movq $0x0, 0x20(%r15)
movq 0x28(%rsp), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x31c8
leaq 0x68(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x336c
leaq 0x68(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x3418
movq 0x62af(%rip), %r14      # 0x8fd0
movq %r15, %r12
movq (%r12), %r12
cmpq %r15, %r12
je 0x2d3c
leaq 0x10(%r12), %rsi
movq %r14, %rdi
callq 0x3500
jmp 0x2d24
movq 0x628d(%rip), %rdi      # 0x8fd0
leaq 0x3332(%rip), %rsi      # 0x607c
movl $0x12, %edx
callq 0x21c0
leaq 0x68(%rsp), %r14
movq %r14, %rdi
callq 0x360c
movzbl %al, %esi
movq 0x6265(%rip), %rdi      # 0x8fd0
callq 0x2270
movq 0x6259(%rip), %rdi      # 0x8fd0
leaq 0x3311(%rip), %rsi      # 0x608f
movl $0xf, %edx
callq 0x21c0
movq 0x68(%rsp), %r15
cmpq %r14, %r15
je 0x2dc2
xorps %xmm0, %xmm0
movss %xmm0, 0x4(%rsp)
leaq 0x10(%r15), %rdi
movq %rbx, %rsi
callq 0x5afc
movss 0x4(%rsp), %xmm1
addss %xmm0, %xmm1
movaps %xmm1, %xmm0
movq (%r15), %r15
cmpq %r14, %r15
jne 0x2d95
cvtss2sd %xmm0, %xmm0
jmp 0x2dc5
xorps %xmm0, %xmm0
movq 0x6204(%rip), %rdi      # 0x8fd0
callq 0x2250
movq 0x61f8(%rip), %rdi      # 0x8fd0
leaq 0x32c0(%rip), %rsi      # 0x609f
movl $0xe, %edx
callq 0x21c0
movq 0x68(%rsp), %r15
cmpq %r14, %r15
je 0x2e28
movq 0x30(%rsp), %rbx
xorps %xmm0, %xmm0
movss %xmm0, 0x4(%rsp)
leaq 0x10(%r15), %rdi
movq %rbx, %rsi
callq 0x5afc
movss 0x4(%rsp), %xmm1
addss %xmm0, %xmm1
movaps %xmm1, %xmm0
movq (%r15), %r15
cmpq %r14, %r15
jne 0x2dfb
cvtss2sd %xmm0, %xmm0
jmp 0x2e2b
xorps %xmm0, %xmm0
movq 0x619e(%rip), %rdi      # 0x8fd0
callq 0x2250
leaq 0x80(%rsp), %rdi
callq 0x36f0
leaq 0x68(%rsp), %rdi
callq 0x3740
xorl %eax, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x2ebe
movq 0x18(%rsp), %rsi
jmp 0x2e8c
jmp 0x2e96
movq %rax, %rbx
jmp 0x2ebe
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x2ebe
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0x2ebe
movq %rax, %rdi
callq 0x366a
jmp 0x2ea4
jmp 0x2ea4
jmp 0x2ea4
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x36f0
leaq 0x68(%rsp), %rdi
callq 0x3740
movq %rbx, %rdi
callq 0x22a0