BitShares-Core  5.0.0
BitShares blockchain implementation and command-line interface software
block.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cryptonomex, Inc., and contributors.
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #pragma once
26 
27 namespace graphene { namespace protocol {
28 
30  {
31  public:
32  digest_type digest()const;
34  uint32_t block_num()const { return num_from_id(previous) + 1; }
36  witness_id_type witness;
38  // Note: when we need to add data to `extensions`, remember to review `database::_generate_block()`.
39  // More info in https://github.com/bitshares/bitshares-core/issues/1136
41 
42  static uint32_t num_from_id(const block_id_type& id);
43  };
44 
46  {
47  public:
48  const block_id_type& id()const;
49  const fc::ecc::public_key& signee()const;
50  void sign( const fc::ecc::private_key& signer );
51  bool validate_signee( const fc::ecc::public_key& expected_signee )const;
52 
54  protected:
57  };
58 
60  {
61  public:
62  const checksum_type& calculate_merkle_root()const;
63  vector<processed_transaction> transactions;
64  protected:
66  };
67 
68 } } // graphene::protocol
69 
71 FC_REFLECT_DERIVED( graphene::protocol::signed_block_header, (graphene::protocol::block_header), (witness_signature) )
72 FC_REFLECT_DERIVED( graphene::protocol::signed_block, (graphene::protocol::signed_block_header), (transactions) )
73 
74 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::block_header)
75 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::signed_block_header)
76 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::signed_block)
future_extensions::flat_set_type extensions_type
Definition: base.hpp:141
fc::time_point_sec timestamp
Definition: block.hpp:35
static uint32_t num_from_id(const block_id_type &id)
Definition: block.cpp:36
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:386
Definition: api.cpp:56
FC_REFLECT_DERIVED(graphene::app::extended_asset_object,(graphene::chain::asset_object),(total_in_collateral)(total_backing_collateral))
checksum_type transaction_merkle_root
Definition: block.hpp:37
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:73
contains only the public point of an elliptic curve key.
Definition: elliptic.hpp:35
extensions_type extensions
Definition: block.hpp:40
checksum_type _calculated_merkle_root
Definition: block.hpp:65
uint32_t block_num() const
Definition: block.hpp:34
digest_type digest() const
Definition: block.cpp:31
an elliptic curve private key.
Definition: elliptic.hpp:89
vector< processed_transaction > transactions
Definition: block.hpp:63