Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
codrush committed Jun 9, 2018
1 parent 1283e46 commit f2c1fd8
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 41 deletions.
8 changes: 4 additions & 4 deletions include/tinychain/blockchain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class blockchain
blockchain(uint16_t id = 3721):id_(id) {
id_ = id;
}
blockchain(const blockchain&) noexcept = default;
blockchain(blockchain&&) noexcept = default;
blockchain& operator=(blockchain&&) noexcept = default;
blockchain& operator=(const blockchain&) noexcept = default;
blockchain(const blockchain&) = default;
blockchain(blockchain&&) = default;
blockchain& operator=(blockchain&&) = default;
blockchain& operator=(const blockchain&) = default;

void print(){ std::cout<<"class blockchain"<<std::endl; }
void test();
Expand Down
35 changes: 18 additions & 17 deletions include/tinychain/database.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#pragma once
#include <tinychain/tinychain.hpp>
#include <queue>
#include <metaverse/mgbubble/utility/Queue.hpp>

namespace tinychain
{

class database
{
public:
database() noexcept {};
database(const database&) noexcept = default;
database(database&&) noexcept = default;
database& operator=(database&&) noexcept = default;
database& operator=(const database&) noexcept = default;
database() {};
database(const database&) = default;
database(database&&) = default;
database& operator=(database&&) = default;
database& operator=(const database&) = default;

virtual void print(){ std::cout<<"class database"<<std::endl; }
virtual void test();
Expand All @@ -26,13 +26,14 @@ class database
class chain_database
{
public:
typedef std::queue<block> chain_database_t;
// thread safty
typedef Queue<block> chain_database_t;

chain_database() noexcept {};
chain_database(const chain_database&) noexcept = default;
chain_database(chain_database&&) noexcept = default;
chain_database& operator=(chain_database&&) noexcept = default;
chain_database& operator=(const chain_database&) noexcept = default;
chain_database() {};
chain_database(const chain_database&) = default;
chain_database(chain_database&&) = default;
chain_database& operator=(chain_database&&) = default;
chain_database& operator=(const chain_database&) = default;

void print(){ std::cout<<"class chain_database"<<std::endl; }
void test();
Expand All @@ -46,11 +47,11 @@ class key_pair_database
public:
typedef std::vector<key_pair> key_pair_database_t;

key_pair_database() noexcept {};
key_pair_database(const key_pair_database&) noexcept = default;
key_pair_database(key_pair_database&&) noexcept = default;
key_pair_database& operator=(key_pair_database&&) noexcept = default;
key_pair_database& operator=(const key_pair_database&) noexcept = default;
key_pair_database() {};
key_pair_database(const key_pair_database&) = default;
key_pair_database(key_pair_database&&) = default;
key_pair_database& operator=(key_pair_database&&) = default;
key_pair_database& operator=(const key_pair_database&) = default;

void print(){ std::cout<<"class key_pair_database"<<std::endl; }
void test();
Expand Down
10 changes: 5 additions & 5 deletions include/tinychain/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ namespace tinychain
class node
{
public:
node() noexcept {
node() noexcept {
// bind
auto& conn = rest_server_.bind("0.0.0.0:8000");
// init for websocket and seesion control
mg_set_protocol_http_websocket(&conn);
mg_set_timer(&conn, mg_time() + mgbubble::RestServ::session_check_interval);
}
node(const node&) noexcept = default;
node(node&&) noexcept = default;
node& operator=(node&&) noexcept = default;
node& operator=(const node&) noexcept = default;
node(const node&) = default;
node(node&&) = default;
node& operator=(node&&) = default;
node& operator=(const node&) = default;

void print(){ std::cout<<"class node"<<std::endl; }
void test();
Expand Down
31 changes: 16 additions & 15 deletions include/tinychain/tinychain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ class key_pair
return distribution(device);
}

key_pair() noexcept {
key_pair() {
private_key_ = pseudo_random();
public_key_ = sha256(std::to_string(private_key_));
}
key_pair(const key_pair& rk) noexcept {
key_pair(const key_pair& rk) {
private_key_ = rk.private_key();
public_key_ = rk.public_key();
}
key_pair(key_pair&&) noexcept = default;
key_pair& operator=(key_pair&&) noexcept = default;
key_pair& operator=(const key_pair&) noexcept = default;
key_pair(key_pair&&) = default;
key_pair& operator=(key_pair&&) = default;
key_pair& operator=(const key_pair&) = default;

void print(){ std::cout<<"class key_pair"<<std::endl; }
void test();
Expand All @@ -53,11 +53,11 @@ class tx
typedef std::vector<tx_item_t> input_t;
typedef std::vector<tx_item_t> output_t;

tx() noexcept = default;
tx(const tx&) noexcept = default;
tx(tx&&) noexcept = default;
tx& operator=(tx&&) noexcept = default;
tx& operator=(const tx&) noexcept = default;
tx() = default;
tx(const tx&) = default;
tx(tx&&) = default;
tx& operator=(tx&&) = default;
tx& operator=(const tx&) = default;

void print(){ std::cout<<"class tx"<<std::endl; }
void test();
Expand All @@ -72,11 +72,11 @@ class block
public:
typedef std::vector<tx> tx_list_t;

block() noexcept = default;
block(const block&) noexcept = default;
block(block&&) noexcept = default;
block& operator=(block&&) noexcept = default;
block& operator=(const block&) noexcept = default;
block() = default;
block(const block&) = default;
block(block&&) = default;
block& operator=(block&&) = default;
block& operator=(const block&) = default;

void print(){ std::cout<<"class block"<<std::endl; }
void test();
Expand All @@ -86,6 +86,7 @@ class block
uint64_t height{0};
uint64_t timestamp{0};
uint64_t tx_count{0};
uint64_t target{0};
sha256_t hash;
sha256_t merkel_root_hash; //TODO
sha256_t prev_hash;
Expand Down

0 comments on commit f2c1fd8

Please sign in to comment.