Browse Source

Merge pull request #2405 from chriseth/useRLPList

Use rlpList to construct some RLPs.
cl-refactor
Gav Wood 10 years ago
parent
commit
0791b3a996
  1. 10
      eth/main.cpp
  2. 12
      libdevcore/TrieDB.h
  3. 1
      libethereum/BlockChainSync.cpp
  4. 4
      libethereum/BlockDetails.h
  5. 6
      neth/main.cpp

10
eth/main.cpp

@ -1026,9 +1026,7 @@ void interactiveMode(eth::Client* c, std::shared_ptr<eth::TrivialGasPricer> gasP
{ {
string path; string path;
iss >> path; iss >> path;
RLPStream config(2); writeFile(path, rlpList(signingKey, beneficiary));
config << signingKey << beneficiary;
writeFile(path, config.out());
} }
else else
cwarn << "Require parameter: exportConfig PATH"; cwarn << "Require parameter: exportConfig PATH";
@ -1477,11 +1475,7 @@ int main(int argc, char** argv)
for (auto const& s: passwordsToNote) for (auto const& s: passwordsToNote)
keyManager.notePassword(s); keyManager.notePassword(s);
{ writeFile(configFile, rlpList(signingKey, beneficiary));
RLPStream config(2);
config << signingKey << beneficiary;
writeFile(configFile, config.out());
}
if (sessionKey) if (sessionKey)
signingKey = sessionKey; signingKey = sessionKey;

12
libdevcore/TrieDB.h

@ -1076,11 +1076,11 @@ template <class DB> bytes GenericTrieDB<DB>::place(RLP const& _orig, NibbleSlice
killNode(_orig); killNode(_orig);
if (_orig.isEmpty()) if (_orig.isEmpty())
return (RLPStream(2) << hexPrefixEncode(_k, true) << _s).out(); return rlpList(hexPrefixEncode(_k, true), _s);
assert(_orig.isList() && (_orig.itemCount() == 2 || _orig.itemCount() == 17)); assert(_orig.isList() && (_orig.itemCount() == 2 || _orig.itemCount() == 17));
if (_orig.itemCount() == 2) if (_orig.itemCount() == 2)
return (RLPStream(2) << _orig[0] << _s).out(); return rlpList(_orig[0], _s);
auto s = RLPStream(17); auto s = RLPStream(17);
for (unsigned i = 0; i < 16; ++i) for (unsigned i = 0; i < 16; ++i)
@ -1162,7 +1162,7 @@ template <class DB> bytes GenericTrieDB<DB>::graft(RLP const& _orig)
} }
assert(n.itemCount() == 2); assert(n.itemCount() == 2);
return (RLPStream(2) << hexPrefixEncode(keyOf(_orig), keyOf(n), isLeaf(n)) << n[1]).out(); return rlpList(hexPrefixEncode(keyOf(_orig), keyOf(n), isLeaf(n)), n[1]);
// auto ret = // auto ret =
// std::cout << keyOf(_orig) << " ++ " << keyOf(n) << " == " << keyOf(RLP(ret)) << std::endl; // std::cout << keyOf(_orig) << " ++ " << keyOf(n) << " == " << keyOf(RLP(ret)) << std::endl;
// return ret; // return ret;
@ -1211,11 +1211,7 @@ template <class DB> bytes GenericTrieDB<DB>::branch(RLP const& _orig)
for (unsigned i = 0; i < 16; ++i) for (unsigned i = 0; i < 16; ++i)
if (i == b) if (i == b)
if (isLeaf(_orig) || k.size() > 1) if (isLeaf(_orig) || k.size() > 1)
{ streamNode(r, rlpList(hexPrefixEncode(k.mid(1), isLeaf(_orig)), _orig[1]));
RLPStream bottom(2);
bottom << hexPrefixEncode(k.mid(1), isLeaf(_orig)) << _orig[1];
streamNode(r, bottom.out());
}
else else
r << _orig[1]; r << _orig[1];
else else

1
libethereum/BlockChainSync.cpp

@ -397,7 +397,6 @@ void PV60Sync::transition(std::shared_ptr<EthereumPeer> _peer, SyncState _s, boo
if (m_state == SyncState::Idle && _s != SyncState::Idle) if (m_state == SyncState::Idle && _s != SyncState::Idle)
_peer->m_requireTransactions = true; _peer->m_requireTransactions = true;
RLPStream s;
if (_s == SyncState::Hashes) if (_s == SyncState::Hashes)
{ {
if (m_state == SyncState::Idle || m_state == SyncState::Hashes) if (m_state == SyncState::Idle || m_state == SyncState::Hashes)

4
libethereum/BlockDetails.h

@ -59,7 +59,7 @@ struct BlockLogBlooms
{ {
BlockLogBlooms() {} BlockLogBlooms() {}
BlockLogBlooms(RLP const& _r) { blooms = _r.toVector<LogBloom>(); size = _r.data().size(); } BlockLogBlooms(RLP const& _r) { blooms = _r.toVector<LogBloom>(); size = _r.data().size(); }
bytes rlp() const { RLPStream s; s << blooms; size = s.out().size(); return s.out(); } bytes rlp() const { bytes r = dev::rlp(blooms); size = r.size(); return r; }
LogBlooms blooms; LogBlooms blooms;
mutable unsigned size; mutable unsigned size;
@ -69,7 +69,7 @@ struct BlocksBlooms
{ {
BlocksBlooms() {} BlocksBlooms() {}
BlocksBlooms(RLP const& _r) { blooms = _r.toArray<LogBloom, c_bloomIndexSize>(); size = _r.data().size(); } BlocksBlooms(RLP const& _r) { blooms = _r.toArray<LogBloom, c_bloomIndexSize>(); size = _r.data().size(); }
bytes rlp() const { RLPStream s; s << blooms; size = s.out().size(); return s.out(); } bytes rlp() const { bytes r = dev::rlp(blooms); size = r.size(); return r; }
std::array<LogBloom, c_bloomIndexSize> blooms; std::array<LogBloom, c_bloomIndexSize> blooms;
mutable unsigned size; mutable unsigned size;

6
neth/main.cpp

@ -363,11 +363,7 @@ int main(int argc, char** argv)
coinbase = config[1].toHash<Address>(); coinbase = config[1].toHash<Address>();
} }
else else
{ writeFile(configFile, rlpList(us.secret(), coinbase));
RLPStream config(2);
config << us.secret() << coinbase;
writeFile(configFile, config.out());
}
for (int i = 1; i < argc; ++i) for (int i = 1; i < argc; ++i)
{ {

Loading…
Cancel
Save