Ethereum  PoC-8
The C++ Implementation of Ethereum
BasicAuthority.h
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
24 #pragma once
25 
26 #include <libdevcrypto/Common.h>
27 #include "SealEngine.h"
28 
29 namespace dev
30 {
31 namespace eth
32 {
33 
35 {
36 public:
37  static std::string name() { return "BasicAuthority"; }
38  unsigned revision() const override { return 0; }
39  unsigned sealFields() const override { return 1; }
40  bytes sealRLP() const override { return rlp(Signature()); }
41 
42  void populateFromParent(BlockHeader&, BlockHeader const&) const override;
43  StringHashMap jsInfo(BlockHeader const& _bi) const override;
44  void verify(Strictness _s, BlockHeader const& _bi, BlockHeader const& _parent, bytesConstRef _block) const override;
45  bool shouldSeal(Interface*) override;
46  void generateSeal(BlockHeader const& _bi) override;
47 
48  static Signature sig(BlockHeader const& _bi) { return _bi.seal<Signature>(); }
49  static BlockHeader& setSig(BlockHeader& _bi, Signature const& _sig) { _bi.setSeal(_sig); return _bi; }
50  void setSecret(Secret const& _s) { m_secret = _s; }
51  static void init();
52 
53 private:
54  bool onOptionChanging(std::string const& _name, bytes const& _value) override;
55 
56  Secret m_secret;
57  AddressHash m_authorities;
58 };
59 
60 }
61 }
Definition: Address.cpp:20
StringHashMap jsInfo(BlockHeader const &_bi) const override
bytes rlp(_T _t)
Export a single item in RLP format, returning a byte array.
Definition: RLP.h:453
Encapsulation of a block header. Class to contain all of a block header&#39;s data. It is able to parse a...
Definition: BlockHeader.h:96
bytes sealRLP() const override
unsigned revision() const override
static std::string name()
unsigned sealFields() const override
T seal(unsigned _offset=0) const
Definition: BlockHeader.h:171
bool shouldSeal(Interface *) override
static BlockHeader & setSig(BlockHeader &_bi, Signature const &_sig)
void generateSeal(BlockHeader const &_bi) override
std::vector< byte > bytes
Definition: Common.h:72
void populateFromParent(BlockHeader &, BlockHeader const &) const override
Don&#39;t forget to call Super::populateFromParent when subclassing & overriding.
void setSecret(Secret const &_s)
h520 Signature
Definition: Common.h:44
std::unordered_map< std::string, std::string > StringHashMap
Definition: Common.h:139
Main API hub for interfacing with Ethereum.
Definition: Interface.h:67
void setSeal(unsigned _offset, T const &_value)
Definition: BlockHeader.h:154
void verify(Strictness _s, BlockHeader const &_bi, BlockHeader const &_parent, bytesConstRef _block) const override
Don&#39;t forget to call Super::verify when subclassing & overriding.
static Signature sig(BlockHeader const &_bi)
std::unordered_set< h160 > AddressHash
A hash set of Ethereum addresses.
Definition: Address.h:36