GithubHelp home page GithubHelp logo

realitian / blockchain Goto Github PK

View Code? Open in Web Editor NEW

This project forked from louishenrifranc/blockchain

0.0 1.0 0.0 17.82 MB

Implementation of a Blockchain as a school project

C++ 93.81% Makefile 0.63% C 0.72% Shell 1.02% Batchfile 0.13% Assembly 3.69%

blockchain's Introduction

Blockchain

  • Implement a blockchain for a school project.
  • Simpler version of the blockchain: register domain name in the blockchain
  • Only CPP code

Requirements

  • cryptocpp
  • boost

Implementation

The project was to build a functionnal blockchain. I wasn't able to code the network part in the short period of time, so only the cores function of the blockchain works (some network class have been start, but nothing finished).
In this blockchain implementation, you can:

  • Identify as a new user, and create a transaction
Identite id("Franc Louis Henri", "Jerome");
cout << id.getNom() << " " << id.getPrenom() << endl;
KeyPair p = id.getKeyPair(); // Get key

string nomDeDomaine = "facebook.com";
string information = "69.63.176.13";
Transaction t(id, nomDeDomaine, information);
  • Add this transaction to the blockchain

BlockChain blockchain; // Create a blockchain
Block genesis(0); // Create first block
std::shared_ptr<Block> ptr0 = std::make_shared<Block>(genesis);
blockchain.push_back(genesis)

// create some transactions
vector<Transaction> transactions_block1{ t1,t,t2,t22,t3,t4 };

// create a new block referencing the previous one
Block block1(ptr0, transactions_block1);

// Compute the proof of work
block1.solveProofofWork();

// add it to the blockhain
blockchain.push_back(block1)
  • I also implemented a database from scratch, and not used any other implementation (because the goal was to understand and practise by coding). Probably not optimal, still cool to code. The database is used to save all traduction domaine name -> IP + informations.
DataBase database;

// Get all transaction of a block
vector all_transaction = std::get<2>(block1).get_Transactions_List()

// Get the entry of the last transaction in the database
database.get(all_transaction.back())

// push a transaction database.push_back(transaction)
// push a all block database.update(block)

blockchain's People

Contributors

louishenrifranc avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.