From ef3ccfcdaaf8e330556d9e41eb921fd7a59998c3 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 7 Jul 2015 10:53:58 +0200 Subject: [PATCH] Use rlpList to construct some RLPs. --- eth/main.cpp | 10 ++-------- libdevcore/TrieDB.h | 12 ++++-------- libethereum/BlockChainSync.cpp | 1 - libethereum/BlockDetails.h | 4 ++-- neth/main.cpp | 6 +----- 5 files changed, 9 insertions(+), 24 deletions(-) diff --git a/eth/main.cpp b/eth/main.cpp index e4facccee..6a66df6a2 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -1026,9 +1026,7 @@ void interactiveMode(eth::Client* c, std::shared_ptr gasP { string path; iss >> path; - RLPStream config(2); - config << signingKey << beneficiary; - writeFile(path, config.out()); + writeFile(path, rlpList(signingKey, beneficiary)); } else cwarn << "Require parameter: exportConfig PATH"; @@ -1477,11 +1475,7 @@ int main(int argc, char** argv) for (auto const& s: passwordsToNote) keyManager.notePassword(s); - { - RLPStream config(2); - config << signingKey << beneficiary; - writeFile(configFile, config.out()); - } + writeFile(configFile, rlpList(signingKey, beneficiary)); if (sessionKey) signingKey = sessionKey; diff --git a/libdevcore/TrieDB.h b/libdevcore/TrieDB.h index f35cf893c..5d3784909 100644 --- a/libdevcore/TrieDB.h +++ b/libdevcore/TrieDB.h @@ -1066,11 +1066,11 @@ template bytes GenericTrieDB::place(RLP const& _orig, NibbleSlice killNode(_orig); 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)); if (_orig.itemCount() == 2) - return (RLPStream(2) << _orig[0] << _s).out(); + return rlpList(_orig[0], _s); auto s = RLPStream(17); for (unsigned i = 0; i < 16; ++i) @@ -1152,7 +1152,7 @@ template bytes GenericTrieDB::graft(RLP const& _orig) } 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 = // std::cout << keyOf(_orig) << " ++ " << keyOf(n) << " == " << keyOf(RLP(ret)) << std::endl; // return ret; @@ -1201,11 +1201,7 @@ template bytes GenericTrieDB::branch(RLP const& _orig) for (unsigned i = 0; i < 16; ++i) if (i == b) if (isLeaf(_orig) || k.size() > 1) - { - RLPStream bottom(2); - bottom << hexPrefixEncode(k.mid(1), isLeaf(_orig)) << _orig[1]; - streamNode(r, bottom.out()); - } + streamNode(r, rlpList(hexPrefixEncode(k.mid(1), isLeaf(_orig)), _orig[1])); else r << _orig[1]; else diff --git a/libethereum/BlockChainSync.cpp b/libethereum/BlockChainSync.cpp index 90dc70574..e22f10880 100644 --- a/libethereum/BlockChainSync.cpp +++ b/libethereum/BlockChainSync.cpp @@ -397,7 +397,6 @@ void PV60Sync::transition(std::shared_ptr _peer, SyncState _s, boo if (m_state == SyncState::Idle && _s != SyncState::Idle) _peer->m_requireTransactions = true; - RLPStream s; if (_s == SyncState::Hashes) { if (m_state == SyncState::Idle || m_state == SyncState::Hashes) diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index f1526b5fd..73026834e 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -59,7 +59,7 @@ struct BlockLogBlooms { BlockLogBlooms() {} BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); 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; mutable unsigned size; @@ -69,7 +69,7 @@ struct BlocksBlooms { BlocksBlooms() {} BlocksBlooms(RLP const& _r) { blooms = _r.toArray(); 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 blooms; mutable unsigned size; diff --git a/neth/main.cpp b/neth/main.cpp index 65f46735f..d5cb4bb4b 100644 --- a/neth/main.cpp +++ b/neth/main.cpp @@ -363,11 +363,7 @@ int main(int argc, char** argv) coinbase = config[1].toHash
(); } else - { - RLPStream config(2); - config << us.secret() << coinbase; - writeFile(configFile, config.out()); - } + writeFile(configFile, rlpList(us.secret(), coinbase)); for (int i = 1; i < argc; ++i) {