Fabcoin Core  0.16.2
P2P Digital Currency
LogFilter.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 <libdevcore/Common.h>
25 #include <libdevcore/RLP.h>
26 #include <libethcore/Common.h>
27 #include "TransactionReceipt.h"
28 
29 #ifdef __INTEL_COMPILER
30 #pragma warning(disable:1098) //the qualifier on this friend declaration is ignored
31 #endif
32 
33 namespace dev
34 {
35 
36 namespace eth
37 {
38 class LogFilter;
39 }
40 
41 namespace eth
42 {
43 
45 std::ostream& operator<<(std::ostream& _out, dev::eth::LogFilter const& _s);
46 
47 class State;
48 class Block;
49 
50 class LogFilter
51 {
52 public:
53  LogFilter(h256 _earliest = EarliestBlockHash, h256 _latest = PendingBlockHash): m_earliest(_earliest), m_latest(_latest) {}
54 
55  void streamRLP(RLPStream& _s) const;
56  h256 sha3() const;
57 
59  h256 earliest() const { return m_earliest; }
60 
62  h256 latest() const { return m_latest; }
63 
67  bool isRangeFilter() const;
68 
70  std::vector<LogBloom> bloomPossibilities() const;
71 
72  bool matches(LogBloom _bloom) const;
73  bool matches(Block const& _b, unsigned _i) const;
74  LogEntries matches(TransactionReceipt const& _r) const;
75 
76  LogFilter address(Address _a) { m_addresses.insert(_a); return *this; }
77  LogFilter topic(unsigned _index, h256 const& _t) { if (_index < 4) m_topics[_index].insert(_t); return *this; }
78  LogFilter withEarliest(h256 _e) { m_earliest = _e; return *this; }
79  LogFilter withLatest(h256 _e) { m_latest = _e; return *this; }
80 
81  friend std::ostream& dev::eth::operator<<(std::ostream& _out, dev::eth::LogFilter const& _s);
82 
83 private:
85  std::array<h256Hash, 4> m_topics;
86  h256 m_earliest = EarliestBlockHash;
87  h256 m_latest = PendingBlockHash;
88 };
89 
90 }
91 
92 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
std::ostream & operator<<(std::ostream &_out, BlockHeader const &_bi)
Definition: BlockHeader.h:194
LogFilter withEarliest(h256 _e)
Definition: LogFilter.h:78
Access a block of memory.
Definition: misc.h:2233
LogFilter withLatest(h256 _e)
Definition: LogFilter.h:79
h256 latest() const
hash of latest block which should be filtered
Definition: LogFilter.h:62
Active model of a block within the block chain.
Definition: Block.h:73
LogFilter address(Address _a)
Definition: LogFilter.h:76
LogFilter topic(unsigned _index, h256 const &_t)
Definition: LogFilter.h:77
h256 earliest() const
hash of earliest block which should be filtered
Definition: LogFilter.h:59
AddressHash m_addresses
Definition: LogFilter.h:84
std::array< h256Hash, 4 > m_topics
Definition: LogFilter.h:85
LogFilter(h256 _earliest=EarliestBlockHash, h256 _latest=PendingBlockHash)
Definition: LogFilter.h:53
bool sha3(bytesConstRef _input, bytesRef o_output)
Calculate SHA3-256 hash of the given input and load it into the given output.
Definition: SHA3.cpp:214
Class for writing to an RLP bytestream.
Definition: RLP.h:383
std::vector< LogEntry > LogEntries
Definition: ExtVMFace.h:110
std::unordered_set< h160 > AddressHash
A hash set of Ethereum addresses.
Definition: Common.h:71