Giter Site home page Giter Site logo

ubu-block's Introduction

ubu-block

Uchaguzi bila Ubaguzi Blockchain

Features

  1. Immutable: You can't make changes only append so no fungua server and other shenanigans.
  2. Distributed: No single point of data storage.
  3. Accessible: Runs on sqlite which is well supported in most platforms.
  4. Community driven: Dynamic number of signatories

Getting Started

git clone <repo> ubu-block
cd ubu-block

If you want to run binaries without installing rust:

  1. Get the latest binary from the releases page.
  2. Replace cargo run with ubu-block
  3. Download the relevant files see Setup initial files

Setup initial files

mkdir data

# Create the db files
cp src/sql/empty.db data/blockchain.db
cp src/sql/empty.db data/private.db

Initialize a Blockchain

cargo run init --creator "Njuguna Mureithi"

You should get:

INFO  ubu_block] Blockchain was successfully initialized!

Add some blocks

Currently ubu-block has very limited dummy data, but this should change as soon as IEBC publishes the voter register

For testing purposes, I used limited data from previous by elections. See src/sql/main_db.sql

cargo run insert --station 022113056303301 --candidate 1 --votes 66
cargo run insert --station 022113056303301 --candidate 2 --votes 21

You should get:

INFO ubu_block] Block was added successfully!

Validate our blockchain

cargo run validate

You should get:

INFO ubu_block] Blockchain is valid!

Querying

cargo run query -q "Select
  c.name as candidate,
   SUM(votes) as votes,
  ward_name as ward,
  constituency_name as constituency,
  county_name as county,
  parties.title as party
from
  results
  INNER JOIN stations ON stations.id = results.station_id
  INNER JOIN candidates c ON c.id = results.candidate_id
  INNER JOIN wards on stations.ward_code = wards.ward_code
  INNER JOIN parties ON parties.id = c.party_id
  INNER JOIN constituencies ON wards.constituency_code = constituencies.constituency_code
  INNER JOIN counties ON constituencies.county_code = counties.county_code
WHERE
  position_type = 'Mp'  and constituency = 'Juja' GROUP BY candidate ;"

NOTE: Currently each query has to return the following columns to work: candidate, votes, ward, constituency, county, party. This is just a temporary issue and should fixed in the next release

You should get:

+--------+--------------+----------+-----------+-------+-------+
| county | constituency |   ward   | candidate | party | votes |
+--------+--------------+----------+-----------+-------+-------+
| Kiambu |     Juja     | Kalimoni |   Omosh   |  ODM  |  21   |
+--------+--------------+----------+-----------+-------+-------+
| Kiambu |     Juja     | Kalimoni |   Mwas    |  PNU  |  66   |
+--------+--------------+----------+-----------+-------+-------+

Trying to steal the election for Omosh

Since immutability is one of our main goal, lets try to edit votes for Omosh and see if we can get away with it

Open blockchain.db with your favourite sqlite editor and run a query that updates the results:

UPDATE "results" SET "votes"= 71 WHERE _rowid_ =1

Running query again we get:

+--------+--------------+----------+-----------+-------+-------+
| county | constituency |   ward   | candidate | party | votes |
+--------+--------------+----------+-----------+-------+-------+
| Kiambu |     Juja     | Kalimoni |   Omosh   |  ODM  |  71   |
+--------+--------------+----------+-----------+-------+-------+
| Kiambu |     Juja     | Kalimoni |   Mwas    |  PNU  |  66   |
+--------+--------------+----------+-----------+-------+-------+

Wow congrats to Omosh!

Hold on, Hold on

There is a petition, lets try validating our blockchain

cargo run validate

thread 'main' panicked at 'Could not verify block, found 0e70cebe0ab3bd8c3606a08d26483d092534eea4ccdb7816fc2692aee5ed3109, block: Block {... CandidateResult { station_id: 22113056303301, candidate_id: 1, votes: 71 }]......', src/db.rs:189:17

How about that? No fungua servers and everything is public and sql friendly

Free Public Servers

Below are the servers you are using for free, it may change along the time. If you are not close to one of these, your network may be slow.

Location Vendor Specification
France Vultr 1 VCPU / 1GB RAM

NOTE: This will be accessible when p2p is ready (hopefully in the next release).

Roadmap

v 0.3

  • Http API
  • Mobile and Web apps

v 0.2

  • P2p - ability to add nodes
  • Fill regional data
  • Views to simplify quering
  • Setup triggers to Before Insert to prevent adding unmatching data
  • Rigourous testing
  • Tabling of sql results

v 0.1

  • Clap
  • Database, sqlite
  • Blockchain
  • CI/CD

References

Do you need a blockchain?

Daisy

Credits

Free Stock Images from Pexels

ubu-block's People

Contributors

geofmureithi avatar josephridge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ubu-block's Issues

Project Documentation & Tutorial

Rust language is a fairly complex tool , & building blockchain applications on native Rust is an even more complex ordeal. To enable other contributors to understand the concepts employed in the project, I suggest development of documentation that will enable new users(who at least understand concepts in Rust & blockchain) to be able to run through & understand the project's overview.
Tasks:

  • Develop a glossary of reference for absolute beginners to get into blockchain & Rust development.
  • Develop documentation for the project that defines the data structures & functions implemented.
  • Develop a video-based docu-series that covers on the logical program flow for the code base.

Read me update :relaxed:

1.Request to Update Current images used in the documentation, due to usage rights. The proposed, public domain images, replacements are :
- Photo by Ketut Subiyanto
- Photo by cottonbro

  1. Request to correct typo in the Getting Started section :
    -If dont you want to do run binaries without installing rust replaced to If you want to run binaries without installing rust

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.