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 }
dev::eth::BasicAuthority
Definition: BasicAuthority.h:35
dev::Signature
h520 Signature
Definition: Common.h:48
dev::vector_ref< byte const >
dev::eth::BlockHeader
Encapsulation of a block header. Class to contain all of a block header's data. It is able to parse a...
Definition: BlockHeader.h:97
dev::eth::BlockHeader::setSeal
void setSeal(unsigned _offset, T const &_value)
Definition: BlockHeader.h:154
dev::SecureFixedHash< 32 >
dev::eth::SealEngineBase
Definition: SealEngine.h:104
Common.h
dev::eth::BasicAuthority::jsInfo
StringHashMap jsInfo(BlockHeader const &_bi) const override
Definition: BasicAuthority.cpp:38
dev::rlp
bytes rlp(_T _t)
Export a single item in RLP format, returning a byte array.
Definition: RLP.h:453
dev::eth::BasicAuthority::setSig
static BlockHeader & setSig(BlockHeader &_bi, Signature const &_sig)
Definition: BasicAuthority.h:49
dev::FixedHash
Definition: FixedHash.h:47
dev::eth::BlockHeader::seal
T seal(unsigned _offset=0) const
Definition: BlockHeader.h:171
dev::eth::BasicAuthority::populateFromParent
void populateFromParent(BlockHeader &, BlockHeader const &) const override
Don't forget to call Super::populateFromParent when subclassing & overriding.
Definition: BasicAuthority.cpp:72
dev::AddressHash
std::unordered_set< h160 > AddressHash
A hash set of Ethereum addresses.
Definition: Address.h:36
dev::eth::BasicAuthority::verify
void verify(Strictness _s, BlockHeader const &_bi, BlockHeader const &_parent, bytesConstRef _block) const override
Don't forget to call Super::verify when subclassing & overriding.
Definition: BasicAuthority.cpp:79
dev::eth::BasicAuthority::name
static std::string name()
Definition: BasicAuthority.h:37
dev::bytes
std::vector< byte > bytes
Definition: Common.h:72
SealEngine.h
dev::eth::BasicAuthority::shouldSeal
bool shouldSeal(Interface *) override
Definition: BasicAuthority.cpp:43
dev::eth::Interface
Main API hub for interfacing with Ethereum.
Definition: Interface.h:68
dev::eth::BasicAuthority::sig
static Signature sig(BlockHeader const &_bi)
Definition: BasicAuthority.h:48
dev::eth::BasicAuthority::revision
unsigned revision() const override
Definition: BasicAuthority.h:38
dev::eth::BasicAuthority::generateSeal
void generateSeal(BlockHeader const &_bi) override
Definition: BasicAuthority.cpp:48
dev::eth::BasicAuthority::sealRLP
bytes sealRLP() const override
Definition: BasicAuthority.h:40
dev::eth::BasicAuthority::setSecret
void setSecret(Secret const &_s)
Definition: BasicAuthority.h:50
dev
Definition: Address.cpp:21
dev::eth::BasicAuthority::init
static void init()
Definition: BasicAuthority.cpp:33
dev::eth::BasicAuthority::sealFields
unsigned sealFields() const override
Definition: BasicAuthority.h:39
dev::StringHashMap
std::unordered_map< std::string, std::string > StringHashMap
Definition: Common.h:139
dev::eth::Strictness
Strictness
Definition: BlockHeader.h:47