Fabcoin Core  0.16.2
P2P Digital Currency
SealEngine.cpp
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 */
22 #include "SealEngine.h"
23 #include "Transaction.h"
24 #include <libevm/ExtVMFace.h>
25 using namespace std;
26 using namespace dev;
27 using namespace eth;
28 
29 SealEngineRegistrar* SealEngineRegistrar::s_this = nullptr;
30 
31 void NoProof::init()
32 {
34 }
35 
36 void SealEngineFace::verify(Strictness _s, BlockHeader const& _bi, BlockHeader const& _parent, bytesConstRef _block) const
37 {
38  _bi.verify(_s, _parent, _block);
39 }
40 
41 void SealEngineFace::populateFromParent(BlockHeader& _bi, BlockHeader const& _parent) const
42 {
43  _bi.populateFromParent(_parent);
44 }
45 
46 void SealEngineFace::verifyTransaction(ImportRequirements::value _ir, TransactionBase const& _t, BlockHeader const&) const
47 {
48  if (_ir & ImportRequirements::TransactionSignatures)
49  _t.checkLowS();
50 }
51 
52 SealEngineFace* SealEngineRegistrar::create(ChainOperationParams const& _params)
53 {
54  SealEngineFace* ret = create(_params.sealEngineName);
55  assert(ret && "Seal engine not found.");
56  if (ret)
57  ret->setChainParams(_params);
58  return ret;
59 }
60 
61 EVMSchedule const& SealEngineBase::evmSchedule(EnvInfo const& _envInfo) const
62 {
64  if (u256(0) == chainParams().u256Param("EIP158ForkBlock") &&
65  u256(0) == chainParams().u256Param("EIP150ForkBlock") &&
66  u256(0) == chainParams().u256Param("homsteadForkBlock")){
67  return getFascSchedule();
68  }
70 
71  if (_envInfo.number() >= chainParams().u256Param("metropolisForkBlock"))
72  return MetropolisSchedule;
73  if (_envInfo.number() >= chainParams().u256Param("EIP158ForkBlock"))
74  return EIP158Schedule;
75  else if (_envInfo.number() >= chainParams().u256Param("EIP150ForkBlock"))
76  return EIP150Schedule;
77  else if (_envInfo.number() >= chainParams().u256Param("homsteadForkBlock"))
78  return HomesteadSchedule;
79  else
80  return FrontierSchedule;
81 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
void populateFromParent(BlockHeader const &parent)
Encapsulation of a block header.
Definition: BlockHeader.h:95
bool verify(Public const &_k, Signature const &_s, h256 const &_hash)
Verify signature.
Definition: Common.cpp:255
std::hash for asio::adress
Definition: Common.h:323
assert(len-trim+(2 *lenIndices)<=WIDTH)
u256 const & number() const
Definition: ExtVMFace.h:237
void verify(Strictness _s=CheckEverything, BlockHeader const &_parent=BlockHeader(), bytesConstRef _block=bytesConstRef()) const
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
Definition: Common.h:125
std::string sealEngineName
The chain sealer name: e.g. Ethash, NoProof, BasicAuthority.
void setChainParams(ChainOperationParams const &_params)
Definition: SealEngine.h:76
Encodes a transaction, ready to be exported to or freshly imported from RLP.
Definition: Transaction.h:50
#define ETH_REGISTER_SEAL_ENGINE(Name)
Definition: SealEngine.h:148