Browse Source

Merge branch 'master' of github.com:ethereum/cpp-ethereum

cl-refactor
Gav Wood 11 years ago
parent
commit
a98ccc8cdd
  1. 2
      BUILDING.md
  2. 2
      libethereum/PeerNetwork.cpp
  3. 2
      libethereum/PeerNetwork.h
  4. 2
      libethereum/RLP.h
  5. 21
      libethereum/State.cpp

2
BUILDING.md

@ -13,7 +13,7 @@ A decent C++11 compiler (I use GNU GCC 4.8.1). CMake, version 2.8 or greater.
On Ubuntu: On Ubuntu:
sudo apt-get install libgmp3-dev libcrypto++-dev libssl-dev libboost-all-dev cmake libleveldb-dev sudo apt-get install libgmp3-dev libcrypto++-dev libssl-dev libboost-all-dev cmake libleveldb-dev libminiupnpc-dev
## Building ## Building

2
libethereum/PeerNetwork.cpp

@ -959,7 +959,7 @@ bool PeerServer::process(BlockChain& _bc, TransactionQueue& _tq, Overlay& _o)
} }
m_latestBlockSent = h; m_latestBlockSent = h;
for (bool accepted = 1; accepted;) for (int accepted = 1; accepted;)
{ {
accepted = 0; accepted = 0;
if (m_incomingBlocks.size()) if (m_incomingBlocks.size())

2
libethereum/PeerNetwork.h

@ -117,7 +117,7 @@ enum class NodeMode
PeerServer PeerServer
}; };
class UPnP; struct UPnP;
class PeerServer class PeerServer
{ {

2
libethereum/RLP.h

@ -169,7 +169,7 @@ public:
/// Converts to bytearray. @returns the empty byte array if not a string. /// Converts to bytearray. @returns the empty byte array if not a string.
bytes toBytes() const { if (!isString()) return bytes(); return bytes(payload().data(), payload().data() + items()); } bytes toBytes() const { if (!isString()) return bytes(); return bytes(payload().data(), payload().data() + items()); }
/// Converts to bytearray. @returns the empty byte array if not a string. /// Converts to bytearray. @returns the empty byte array if not a string.
bytesConstRef toBytesConstRef() const { if (!isString()) return bytesConstRef(); payload().cropped(0, items()); } bytesConstRef toBytesConstRef() const { if (!isString()) return bytesConstRef(); return payload().cropped(0, items()); }
/// Converts to string. @returns the empty string if not a string. /// Converts to string. @returns the empty string if not a string.
std::string toString() const { if (!isString()) return std::string(); return payload().cropped(0, items()).toString(); } std::string toString() const { if (!isString()) return std::string(); return payload().cropped(0, items()).toString(); }
/// Converts to string. @throws BadCast if not a string. /// Converts to string. @throws BadCast if not a string.

21
libethereum/State.cpp

@ -103,7 +103,10 @@ void State::ensureCached(Address _a, bool _requireMemory, bool _forceCreate) con
TrieDB<u256, Overlay> memdb(const_cast<Overlay*>(&m_db), it->second.oldRoot()); // promise we won't alter the overlay! :) TrieDB<u256, Overlay> memdb(const_cast<Overlay*>(&m_db), it->second.oldRoot()); // promise we won't alter the overlay! :)
map<u256, u256>& mem = it->second.takeMemory(); map<u256, u256>& mem = it->second.takeMemory();
for (auto const& i: memdb) for (auto const& i: memdb)
mem[i.first] = RLP(i.second).toInt<u256>(); if(mem.find(i.first)==mem.end())
mem.insert(std::pair<u256,u256>(i.first,RLP(i.second).toInt<u256>()));
else
mem.at(i.first) = RLP(i.second).toInt<u256>();
} }
} }
@ -565,7 +568,11 @@ void State::executeBare(Transaction const& _t, Address _sender)
m_cache[newAddress] = AddressState(0, 0, sha3(RLPNull)); m_cache[newAddress] = AddressState(0, 0, sha3(RLPNull));
auto& mem = m_cache[newAddress].takeMemory(); auto& mem = m_cache[newAddress].takeMemory();
for (uint i = 0; i < _t.data.size(); ++i) for (uint i = 0; i < _t.data.size(); ++i)
mem[i] = _t.data[i]; if(mem.find(i)==mem.end())
mem.insert(std::pair<u256,u256>(i,_t.data[i]));
else
mem.at(i) = _t.data[i];
subBalance(_sender, _t.value + _t.fee); subBalance(_sender, _t.value + _t.fee);
addBalance(newAddress, _t.value); addBalance(newAddress, _t.value);
addBalance(m_currentBlock.coinbaseAddress, _t.fee); addBalance(m_currentBlock.coinbaseAddress, _t.fee);
@ -600,10 +607,14 @@ void State::execute(Address _myAddress, Address _txSender, u256 _txValue, u256 _
}; };
auto setMem = [&](u256 _n, u256 _v) auto setMem = [&](u256 _n, u256 _v)
{ {
if (_v) if (_v) {
myMemory[_n] = _v; if(myMemory.find(_n)==myMemory.end())
else myMemory.insert(std::pair<u256,u256>(_n,_v));
else
myMemory.at(_n) = _v;
} else {
myMemory.erase(_n); myMemory.erase(_n);
}
}; };
u256 curPC = 0; u256 curPC = 0;

Loading…
Cancel
Save