Fabcoin Core  0.16.2
P2P Digital Currency
FixedClient.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  */
22 #pragma once
23 
24 #include <libethereum/ClientBase.h>
25 #include <libethereum/BlockChain.h>
26 #include <libethereum/State.h>
27 
28 namespace dev
29 {
30 namespace test
31 {
32 
38 {
39 public:
40  FixedClient(eth::BlockChain const& _bc, eth::Block const& _block) : m_bc(_bc), m_block(_block) {}
41  virtual ~FixedClient() {}
42 
43  // stub
44  virtual void flushTransactions() override {}
45  virtual eth::BlockChain& bc() override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("FixedClient::bc()")); }
46  virtual eth::BlockChain const& bc() const override { return m_bc; }
47  using ClientBase::block;
48  virtual eth::Block block(h256 const& _h) const override;
49  virtual eth::Block preSeal() const override { ReadGuard l(x_stateDB); return m_block; }
50  virtual eth::Block postSeal() const override { ReadGuard l(x_stateDB); return m_block; }
51  virtual void setAuthor(Address const& _us) override { WriteGuard l(x_stateDB); m_block.setAuthor(_us); }
52  virtual void prepareForTransaction() override {}
53 
54 private:
58 };
59 
60 }
61 }
eth::BlockChain const & m_bc
Definition: FixedClient.h:55
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
Implements the blockchain database.
Definition: BlockChain.h:105
SharedMutex x_stateDB
Lock on the state DB, effectively a lock on m_postSeal.
Definition: FixedClient.h:57
FixedClient(eth::BlockChain const &_bc, eth::Block const &_block)
Definition: FixedClient.h:40
Active model of a block within the block chain.
Definition: Block.h:73
virtual void flushTransactions() override
Blocks until all pending transactions have been processed.
Definition: FixedClient.h:44
virtual void prepareForTransaction() override
Definition: FixedClient.h:52
virtual eth::BlockChain const & bc() const override
Definition: FixedClient.h:46
virtual eth::Block block(h256 const &_h) const override
Definition: FixedClient.cpp:28
virtual eth::Block postSeal() const override
Definition: FixedClient.h:50
boost::shared_lock< boost::shared_mutex > ReadGuard
Definition: Guards.h:44
boost::unique_lock< boost::shared_mutex > WriteGuard
Definition: Guards.h:47
void setAuthor(Address const &_id)
Set the author address for any transactions we do and rewards we get.
Definition: Block.h:118
virtual eth::Block preSeal() const override
Definition: FixedClient.h:49
boost::shared_mutex SharedMutex
Definition: Guards.h:39
virtual eth::BlockChain & bc() override
The interface that must be implemented in any class deriving this.
Definition: FixedClient.h:45
virtual void setAuthor(Address const &_us) override
Set the block author address.
Definition: FixedClient.h:51
mvp implementation of ClientBase Doesn&#39;t support mining interface
Definition: FixedClient.h:37