BtcExplorer/main.cpp
2021-05-06 16:58:11 +03:00

40 lines
1023 B
C++

#include <iostream>
#include <fstream>
#include <memory>
#include <vector>
#include "Models/Block.h"
int main() {
std::string path = "/Users/selim/Documents/blk00000.dat";
std::fstream file(path);
std::vector<Block> blocks;
PreBlockHeader header{};
size_t index = 0;
while (true) {
file.read((char*)&header, sizeof(header));
header.magic = (BlockMagic)__builtin_bswap32(header.magic);
if(file.eof()) {
break;
}
auto blockData = std::make_unique<std::byte[]>(header.blockSize);
file.read((char*)blockData.get(), header.blockSize);
Block block(blockData.get(), header.blockSize);
blocks.push_back(block);
//std::cout << "Parsed new block " << index++ << " with size: " << header.blockSize << std::endl;
}
std::cout << "Blocks found: " << blocks.size() << std::endl;
// for(size_t i = 0; i < 100; ++i) {
// std::cout << "version: " << blocks[i].time() << std::endl;
// }
return 0;
}