// File: ArthoPacini[P]blockchaincpp/./Blockchain.hpp
// Function: Blockchain::validate()
bool validate() 
    {
        std::vector<Block>::iterator it;
        for(it = chain.begin(); it != chain.end(); ++it)
        {
            Block & currentBlock = *it;
            if(it == (chain.end() - 1))
                continue;

            if(!currentBlock.validate())
                {
                    std::cout << "Block " << currentBlock << " is invalid\n";
                    return false;
                }

            if(chain.size() > 1 && it != chain.begin())
            {
                Block previousBlock = *(it-1);
                if(currentBlock.previousHash() != previousBlock.calculateHash())
                {
                    std::cout << "Block " << currentBlock << " is invalid\n";
                    return false;
                }
            }
            
        }

        return true;
    }

// Assembly:
subq $0x178, %rsp            # imm = 0x178
movq %rdi, 0x168(%rsp)
movq 0x168(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x255e0
movq 0x18(%rsp), %rdi
addq $0x8, %rdi
callq 0x9240
movq %rax, 0x158(%rsp)
movq 0x158(%rsp), %rax
movq %rax, 0x160(%rsp)
movq 0x18(%rsp), %rdi
addq $0x8, %rdi
callq 0x8ea0
movq %rax, 0x150(%rsp)
leaq 0x160(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x25600
testb $0x1, %al
jne 0x83e3
jmp 0x8644
leaq 0x160(%rsp), %rdi
callq 0x97e0
movq 0x18(%rsp), %rdi
movq %rax, 0x148(%rsp)
addq $0x8, %rdi
callq 0x8ea0
movq %rax, 0x138(%rsp)
leaq 0x138(%rsp), %rdi
movl $0x1, %esi
callq 0x9790
movq %rax, 0x140(%rsp)
leaq 0x160(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x25640
testb $0x1, %al
jne 0x8443
jmp 0x8448
jmp 0x8632
movq 0x148(%rsp), %rdi
callq 0x25680
testb $0x1, %al
jne 0x8498
movq 0x4fb70(%rip), %rdi     # 0x57fd0
leaq 0x34775(%rip), %rsi     # 0x3cbdc
callq 0x54a0
movq %rax, %rdi
movq 0x148(%rsp), %rsi
callq 0x256d0
movq %rax, %rdi
leaq 0x37a91(%rip), %rsi     # 0x3ff17
callq 0x54a0
movb $0x0, 0x177(%rsp)
jmp 0x864c
movq 0x18(%rsp), %rdi
addq $0x8, %rdi
callq 0x9380
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x1, %rcx
movb %al, 0x17(%rsp)
jbe 0x84e4
movq 0x18(%rsp), %rdi
addq $0x8, %rdi
callq 0x9240
movq %rax, 0x130(%rsp)
leaq 0x160(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x25600
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x84f1
jmp 0x8630
leaq 0x160(%rsp), %rdi
movl $0x1, %esi
callq 0x9790
movq %rax, 0x78(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x97e0
movq %rax, %rsi
leaq 0x80(%rsp), %rdi
callq 0x25700
movq 0x148(%rsp), %rsi
leaq 0x58(%rsp), %rdi
callq 0x25870
jmp 0x8536
leaq 0x28(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0xaa90
jmp 0x854a
leaq 0x58(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x25840
movb %al, 0x16(%rsp)
leaq 0x28(%rsp), %rdi
callq 0x5320
leaq 0x58(%rsp), %rdi
callq 0x5320
movb 0x16(%rsp), %al
testb $0x1, %al
jne 0x857e
jmp 0x85fe
movq 0x4fa4b(%rip), %rdi     # 0x57fd0
leaq 0x34650(%rip), %rsi     # 0x3cbdc
callq 0x54a0
movq %rax, 0x8(%rsp)
jmp 0x8598
movq 0x8(%rsp), %rdi
movq 0x148(%rsp), %rsi
callq 0x256d0
movq %rax, (%rsp)
jmp 0x85b0
movq (%rsp), %rdi
leaq 0x3795c(%rip), %rsi     # 0x3ff17
callq 0x54a0
jmp 0x85c2
movb $0x0, 0x177(%rsp)
movl $0x1, 0x24(%rsp)
jmp 0x8606
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0x8621
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x5320
jmp 0x8621
movl $0x0, 0x24(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x8ae0
movl 0x24(%rsp), %eax
testl %eax, %eax
je 0x861f
jmp 0x861d
jmp 0x864c
jmp 0x8630
leaq 0x80(%rsp), %rdi
callq 0x8ae0
jmp 0x865d
jmp 0x8632
leaq 0x160(%rsp), %rdi
callq 0x258a0
jmp 0x83af
movb $0x1, 0x177(%rsp)
movb 0x177(%rsp), %al
andb $0x1, %al
addq $0x178, %rsp            # imm = 0x178
retq
movq 0x50(%rsp), %rdi
callq 0x5790
nopw (%rax,%rax)