Browse Source

Use rlpList to construct some RLPs.

cl-refactor
chriseth 10 years ago
parent
commit
ef3ccfcdaa
  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;
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;

12
libdevcore/TrieDB.h

@ -1066,11 +1066,11 @@ template <class DB> bytes GenericTrieDB<DB>::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 <class DB> bytes GenericTrieDB<DB>::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 <class DB> bytes GenericTrieDB<DB>::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

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)
_peer->m_requireTransactions = true;
RLPStream s;
if (_s == SyncState::Hashes)
{
if (m_state == SyncState::Idle || m_state == SyncState::Hashes)

4
libethereum/BlockDetails.h

@ -59,7 +59,7 @@ struct BlockLogBlooms
{
BlockLogBlooms() {}
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;
mutable unsigned size;
@ -69,7 +69,7 @@ struct BlocksBlooms
{
BlocksBlooms() {}
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;
mutable unsigned size;

6
neth/main.cpp

@ -363,11 +363,7 @@ int main(int argc, char** argv)
coinbase = config[1].toHash<Address>();
}
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)
{

Loading…
Cancel
Save