Ethereum  PoC-8
The C++ Implementation of Ethereum
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:
84  AddressHash m_addresses;
85  std::array<h256Hash, 4> m_topics;
86  h256 m_earliest = EarliestBlockHash;
87  h256 m_latest = PendingBlockHash;
88 };
89 
90 }
91 
92 }
dev::eth::LogFilter::address
LogFilter address(Address _a)
Definition: LogFilter.h:76
dev::eth::LogFilter
Definition: LogFilter.h:51
dev::eth::LogFilter::withEarliest
LogFilter withEarliest(h256 _e)
Definition: LogFilter.h:78
dev::eth::LogFilter::withLatest
LogFilter withLatest(h256 _e)
Definition: LogFilter.h:79
dev::FixedHash< 32 >
dev::eth::LogFilter::bloomPossibilities
std::vector< LogBloom > bloomPossibilities() const
Definition: LogFilter.cpp:88
dev::AddressHash
std::unordered_set< h160 > AddressHash
A hash set of Ethereum addresses.
Definition: Address.h:36
Common.h
dev::eth::Asking::State
@ State
Common.h
dev::eth::LogFilter::earliest
h256 earliest() const
hash of earliest block which should be filtered
Definition: LogFilter.h:59
dev::eth::LogEntries
std::vector< LogEntry > LogEntries
Definition: LogEntry.h:51
TransactionReceipt.h
dev::eth::LogFilter::matches
bool matches(LogBloom _bloom) const
Definition: LogFilter.cpp:61
dev::eth::LogFilter::streamRLP
void streamRLP(RLPStream &_s) const
Definition: LogFilter.cpp:37
dev::RLPStream
Class for writing to an RLP bytestream.
Definition: RLP.h:370
dev::eth::LogFilter::topic
LogFilter topic(unsigned _index, h256 const &_t)
Definition: LogFilter.h:77
dev::eth::operator<<
std::ostream & operator<<(std::ostream &_out, BlockHeader const &_bi)
Definition: BlockHeader.h:217
dev::eth::TransactionReceipt
Definition: TransactionReceipt.h:40
dev
Definition: Address.cpp:21
dev::eth::LogFilter::LogFilter
LogFilter(h256 _earliest=EarliestBlockHash, h256 _latest=PendingBlockHash)
Definition: LogFilter.h:53
dev::eth::LogFilter::latest
h256 latest() const
hash of latest block which should be filtered
Definition: LogFilter.h:62
dev::eth::LogFilter::isRangeFilter
bool isRangeFilter() const
Definition: LogFilter.cpp:49
dev::eth::LogFilter::sha3
h256 sha3() const
Definition: LogFilter.cpp:42
RLP.h
dev::eth::Block
Active model of a block within the block chain. Keeps track of all transactions, receipts and state f...
Definition: Block.h:69