Fabcoin Core  0.16.2
P2P Digital Currency
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 "SealEngine.h"
27 
28 namespace dev
29 {
30 namespace eth
31 {
32 
34 {
35 public:
36  std::string name() const override { return "BasicAuthority"; }
37  unsigned revision() const override { return 0; }
38  unsigned sealFields() const override { return 1; }
39  bytes sealRLP() const override { return rlp(Signature()); }
40 
41  void populateFromParent(BlockHeader&, BlockHeader const&) const override;
42  StringHashMap jsInfo(BlockHeader const& _bi) const override;
43  void verify(Strictness _s, BlockHeader const& _bi, BlockHeader const& _parent, bytesConstRef _block) const override;
44  bool shouldSeal(Interface*) override;
45  void generateSeal(BlockHeader const& _bi) override;
46 
47  static Signature sig(BlockHeader const& _bi) { return _bi.seal<Signature>(); }
48  static BlockHeader& setSig(BlockHeader& _bi, Signature const& _sig) { _bi.setSeal(_sig); return _bi; }
49  void setSecret(Secret const& _s) { m_secret = _s; }
50  static void init();
51 
52 private:
53  bool onOptionChanging(std::string const& _name, bytes const& _value) override;
54 
57 };
58 
59 }
60 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
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:467
Encapsulation of a block header.
Definition: BlockHeader.h:95
bytes sealRLP() const override
unsigned revision() const override
unsigned sealFields() const override
std::string name() const override
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:75
Fixed-size raw-byte array container type, with an API optimised for storing hashes.
Definition: FixedHash.h:47
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
A signature: 65 bytes: r: [0, 32), s: [32, 64), v: 64.
Definition: Common.h:43
std::unordered_map< std::string, std::string > StringHashMap
Definition: Common.h:143
Main API hub for interfacing with Ethereum.
Definition: Interface.h:67
bool onOptionChanging(std::string const &_name, bytes const &_value) override
void setSeal(unsigned _offset, T const &_value)
Definition: BlockHeader.h:151
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.
T seal(unsigned _offset=0) const
Definition: BlockHeader.h:167
static Signature sig(BlockHeader const &_bi)
std::unordered_set< h160 > AddressHash
A hash set of Ethereum addresses.
Definition: Common.h:71