BitShares-Core  6.1.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  virtual ~block_header() = default;
43 
44  static uint32_t num_from_id(const block_id_type& id);
45  };
46 
48  {
49  public:
50  const block_id_type& id()const;
51  const fc::ecc::public_key& signee()const;
52  void sign( const fc::ecc::private_key& signer );
53  bool validate_signee( const fc::ecc::public_key& expected_signee )const;
54 
56 
57  signed_block_header() = default;
58  explicit signed_block_header( const block_header& header ) : block_header( header ) {}
59  protected:
62  };
63 
65  {
66  public:
67  const checksum_type& calculate_merkle_root()const;
68  vector<processed_transaction> transactions;
69  protected:
71  };
72 
73 } } // graphene::protocol
74 
78 
future_extensions::flat_set_type extensions_type
Definition: base.hpp:156
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:388
Definition: api.cpp:48
uint32_t block_num() const
Definition: block.hpp:34
checksum_type transaction_merkle_root
Definition: block.hpp:37
signed_block_header(const block_header &header)
Definition: block.hpp:58
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:85
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:70
#define FC_REFLECT_DERIVED(TYPE, INHERITS, MEMBERS)
Specializes fc::reflector for TYPE where type inherits other reflected classes.
Definition: reflect.hpp:305
an elliptic curve private key.
Definition: elliptic.hpp:89
vector< processed_transaction > transactions
Definition: block.hpp:68
digest_type digest() const
Definition: block.cpp:31