Ethereum  PoC-8
The C++ Implementation of Ethereum
LogEntry.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 */
17 
18 #pragma once
19 
20 #include "Common.h"
21 
22 #include <libdevcore/Address.h>
23 #include <libdevcore/FixedHash.h>
24 
25 namespace dev
26 {
27 
28 class RLP;
29 class RLPStream;
30 
31 namespace eth
32 {
33 
34 struct LogEntry
35 {
36  LogEntry() = default;
37  explicit LogEntry(RLP const& _r);
38  LogEntry(Address const& _address, h256s _topics, bytes _data):
39  address(_address), topics(std::move(_topics)), data(std::move(_data))
40  {}
41 
42  void streamRLP(RLPStream& _s) const;
43 
44  LogBloom bloom() const;
45 
49 };
50 
51 using LogEntries = std::vector<LogEntry>;
52 
54 {
55  LocalisedLogEntry() = default;
56  explicit LocalisedLogEntry(LogEntry const& _le): LogEntry(_le) {}
57 
58  LocalisedLogEntry(LogEntry const& _le, h256 _special):
59  LogEntry(_le),
60  isSpecial(true),
61  special(_special)
62  {}
63 
65  LogEntry const& _le,
66  h256 const& _blockHash,
67  BlockNumber _blockNumber,
68  h256 const& _transactionHash,
69  unsigned _transactionIndex,
70  unsigned _logIndex,
72  ):
73  LogEntry(_le),
74  blockHash(_blockHash),
75  blockNumber(_blockNumber),
76  transactionHash(_transactionHash),
77  transactionIndex(_transactionIndex),
78  logIndex(_logIndex),
79  polarity(_polarity),
80  mined(true)
81  {}
82 
86  unsigned transactionIndex = 0;
87  unsigned logIndex = 0;
89  bool mined = false;
90  bool isSpecial = false;
92 };
93 
94 using LocalisedLogEntries = std::vector<LocalisedLogEntry>;
95 
96 inline LogBloom bloom(LogEntries const& _logs)
97 {
98  LogBloom ret;
99  for (auto const& l: _logs)
100  ret |= l.bloom();
101  return ret;
102 }
103 
104 }
105 }
dev::eth::LogEntry::LogEntry
LogEntry(Address const &_address, h256s _topics, bytes _data)
Definition: LogEntry.h:38
dev::eth::LocalisedLogEntry::blockHash
h256 blockHash
Definition: LogEntry.h:83
dev::eth::LogEntry::LogEntry
LogEntry()=default
FixedHash.h
dev::eth::LocalisedLogEntry::special
h256 special
Definition: LogEntry.h:91
dev::eth::LogEntry::address
Address address
Definition: LogEntry.h:46
dev::eth::LocalisedLogEntry::LocalisedLogEntry
LocalisedLogEntry(LogEntry const &_le, h256 const &_blockHash, BlockNumber _blockNumber, h256 const &_transactionHash, unsigned _transactionIndex, unsigned _logIndex, BlockPolarity _polarity=BlockPolarity::Unknown)
Definition: LogEntry.h:64
Address.h
dev::eth::bloom
LogBloom bloom(LogEntries const &_logs)
Definition: LogEntry.h:96
dev::eth::LocalisedLogEntry::logIndex
unsigned logIndex
Definition: LogEntry.h:87
dev::eth::LocalisedLogEntry::LocalisedLogEntry
LocalisedLogEntry()=default
dev::eth::LogEntry::topics
h256s topics
Definition: LogEntry.h:47
dev::FixedHash< 20 >
dev::eth::LocalisedLogEntry::LocalisedLogEntry
LocalisedLogEntry(LogEntry const &_le, h256 _special)
Definition: LogEntry.h:58
dev::eth::LocalisedLogEntry::blockNumber
BlockNumber blockNumber
Definition: LogEntry.h:84
dev::eth::LocalisedLogEntry::mined
bool mined
Definition: LogEntry.h:89
dev::eth::BlockPolarity
BlockPolarity
Definition: Common.h:81
Common.h
dev::h256s
std::vector< h256 > h256s
Definition: FixedHash.h:361
dev::eth::LogEntries
std::vector< LogEntry > LogEntries
Definition: LogEntry.h:51
dev::eth::LogEntry::streamRLP
void streamRLP(RLPStream &_s) const
Definition: LogEntry.cpp:36
dev::bytes
std::vector< byte > bytes
Definition: Common.h:72
dev::eth::LogEntry::data
bytes data
Definition: LogEntry.h:48
dev::eth::LocalisedLogEntry::isSpecial
bool isSpecial
Definition: LogEntry.h:90
dev::eth::LogEntry
Definition: LogEntry.h:35
dev::eth::LocalisedLogEntry::transactionHash
h256 transactionHash
Definition: LogEntry.h:85
dev::eth::BlockPolarity::Unknown
@ Unknown
dev::eth::LocalisedLogEntries
std::vector< LocalisedLogEntry > LocalisedLogEntries
Definition: LogEntry.h:94
dev::RLPStream
Class for writing to an RLP bytestream.
Definition: RLP.h:370
dev::eth::BlockNumber
unsigned BlockNumber
Definition: Common.h:64
std
Definition: FixedHash.h:393
dev::eth::LocalisedLogEntry::LocalisedLogEntry
LocalisedLogEntry(LogEntry const &_le)
Definition: LogEntry.h:56
dev
Definition: Address.cpp:21
dev::eth::LocalisedLogEntry::polarity
BlockPolarity polarity
Definition: LogEntry.h:88
dev::eth::LocalisedLogEntry
Definition: LogEntry.h:54
dev::RLP
Definition: RLP.h:48
dev::eth::LocalisedLogEntry::transactionIndex
unsigned transactionIndex
Definition: LogEntry.h:86
dev::eth::LogEntry::bloom
LogBloom bloom() const
Definition: LogEntry.cpp:41