sample-reading-blocks/transaction.cpp
2025-03-13 15:24:44 +03:00

20 lines
502 B
C++

#include <iostream>
#include "json.hpp"
#include <fstream>
#include <filesystem>
#include <vector>
using json = nlohmann::json;
namespace fs = std::filesystem;
int main(){
char* path = "blocks";
size_t length = std::distance(fs::directory_iterator(path), {});
std::vector<json> blocks = {length};
for(const auto & file : fs::directory_iterator(path))
{
std::ifstream f (file.path());
blocks.push_back(json::parse(f));
}
for(const auto & block : blocks){
std::cout<< block << std::endl;
}
}