Ethereum  PoC-8
The C++ Implementation of Ethereum
LogEntry.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 */
17 
18 #include "LogEntry.h"
19 
20 #include <libdevcore/RLP.h>
21 #include <libdevcore/SHA3.h>
22 
23 namespace dev
24 {
25 namespace eth
26 {
27 
29 {
30  assert(_r.itemCount() == 3);
31  address = (Address)_r[0];
32  topics = _r[1].toVector<h256>();
33  data = _r[2].toBytes();
34 }
35 
37 {
38  _s.appendList(3) << address << topics << data;
39 }
40 
42 {
43  LogBloom ret;
44  ret.shiftBloom<3>(sha3(address.ref()));
45  for (auto t: topics)
46  ret.shiftBloom<3>(sha3(t.ref()));
47  return ret;
48 }
49 
50 }
51 }
Definition: Address.cpp:20
bytes toBytes(int _flags=LaissezFaire) const
Converts to bytearray.
Definition: RLP.h:177
LogEntry()=default
h160 Address
Definition: Address.h:30
FixedHash & shiftBloom(FixedHash< M > const &_h)
Definition: FixedHash.h:175
bool sha3(bytesConstRef _input, bytesRef o_output) noexcept
Definition: SHA3.cpp:28
bytesRef ref()
Definition: FixedHash.h:132
h256s topics
Definition: LogEntry.h:47
RLPStream & appendList(size_t _items)
Appends a list.
Definition: RLP.cpp:268
std::vector< T > toVector(int _flags=LaissezFaire) const
Definition: RLP.h:186
Address address
Definition: LogEntry.h:46
void streamRLP(RLPStream &_s) const
Definition: LogEntry.cpp:36
bytes data
Definition: LogEntry.h:48
size_t itemCount() const
Definition: RLP.h:101
LogBloom bloom() const
Definition: LogEntry.cpp:41
Class for writing to an RLP bytestream.
Definition: RLP.h:369
Definition: RLP.h:47