BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet 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:
68  vector<processed_transaction> transactions;
69  protected:
71  };
72 
73 } } // graphene::protocol
74 
75 FC_REFLECT( graphene::protocol::block_header, (previous)(timestamp)(witness)(transaction_merkle_root)(extensions) )
78 
graphene::protocol::block_header::transaction_merkle_root
checksum_type transaction_merkle_root
Definition: block.hpp:37
graphene::protocol::block_header::extensions
extensions_type extensions
Definition: block.hpp:40
graphene::protocol::signed_block_header::signed_block_header
signed_block_header(const block_header &header)
Definition: block.hpp:58
graphene::protocol::signed_block::calculate_merkle_root
const checksum_type & calculate_merkle_root() const
Definition: block.cpp:70
graphene::protocol::signed_block_header::_signee
fc::ecc::public_key _signee
Definition: block.hpp:60
fc::sha256
Definition: sha256.hpp:10
graphene::protocol::block_header::~block_header
virtual ~block_header()=default
fc::zero_initialized_array
Definition: zeroed_array.hpp:30
fc::ecc::public_key
contains only the public point of an elliptic curve key.
Definition: elliptic.hpp:35
graphene::protocol::block_header::previous
block_id_type previous
Definition: block.hpp:33
graphene::protocol::signed_block::_calculated_merkle_root
checksum_type _calculated_merkle_root
Definition: block.hpp:70
graphene::protocol::block_header::witness
witness_id_type witness
Definition: block.hpp:36
graphene::protocol::block_header::block_num
uint32_t block_num() const
Definition: block.hpp:34
fc::ecc::private_key
an elliptic curve private key.
Definition: elliptic.hpp:89
graphene::protocol::signed_block_header::signee
const fc::ecc::public_key & signee() const
Definition: block.cpp:53
graphene::protocol::signed_block_header::_block_id
block_id_type _block_id
Definition: block.hpp:61
FC_REFLECT_DERIVED
#define FC_REFLECT_DERIVED(TYPE, INHERITS, MEMBERS)
Specializes fc::reflector for TYPE where type inherits other reflected classes.
Definition: reflect.hpp:305
fc::time_point_sec
Definition: time.hpp:74
graphene::protocol::block_header::digest
digest_type digest() const
Definition: block.cpp:31
transaction.hpp
graphene::protocol::signed_block::transactions
vector< processed_transaction > transactions
Definition: block.hpp:68
graphene::protocol::signed_block_header::signed_block_header
signed_block_header()=default
fc::ripemd160
Definition: ripemd160.hpp:11
GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:85
graphene::protocol::block_header::timestamp
fc::time_point_sec timestamp
Definition: block.hpp:35
graphene::protocol::signed_block_header::witness_signature
signature_type witness_signature
Definition: block.hpp:55
graphene::protocol::block_header::num_from_id
static uint32_t num_from_id(const block_id_type &id)
Definition: block.cpp:36
graphene::protocol::signed_block_header::validate_signee
bool validate_signee(const fc::ecc::public_key &expected_signee) const
Definition: block.cpp:65
graphene::protocol::signed_block_header
Definition: block.hpp:47
FC_REFLECT
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:388
graphene::protocol::signed_block_header::sign
void sign(const fc::ecc::private_key &signer)
Definition: block.cpp:60
graphene::protocol::signed_block_header::id
const block_id_type & id() const
Definition: block.cpp:41
graphene::protocol::signed_block
Definition: block.hpp:64
graphene
Definition: api.cpp:48
graphene::protocol::extensions_type
future_extensions::flat_set_type extensions_type
Definition: base.hpp:156
graphene::protocol::block_header
Definition: block.hpp:29