From 303ad1f7087c193781a6944dcfe2af19a13874fd Mon Sep 17 00:00:00 2001 From: SharpCoiner Date: Sun, 2 Feb 2014 12:02:36 +0100 Subject: [PATCH 1/4] Update BUILDING.md Added libminiupnpc-dev package for Ubuntu dependency list. --- BUILDING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILDING.md b/BUILDING.md index f7b65cd47..56174cbf8 100644 --- a/BUILDING.md +++ b/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: - 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 From 39b06d95c645c68daea860c9b3e0aa4b6cfee79a Mon Sep 17 00:00:00 2001 From: Daniel Hams Date: Sun, 2 Feb 2014 11:08:16 +0000 Subject: [PATCH 2/4] Little fixes found using clang on OSX10.9: * bool to int as its incremented in PeerNetwork.cpp * class to struct to match .cpp of UPnP in PeerNetwork.h * Add missing return to string case in RLP.toBytesConstRef --- libethereum/PeerNetwork.cpp | 2 +- libethereum/PeerNetwork.h | 2 +- libethereum/RLP.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libethereum/PeerNetwork.cpp b/libethereum/PeerNetwork.cpp index 597e2d45e..97f782e3a 100644 --- a/libethereum/PeerNetwork.cpp +++ b/libethereum/PeerNetwork.cpp @@ -959,7 +959,7 @@ bool PeerServer::process(BlockChain& _bc, TransactionQueue& _tq, Overlay& _o) } m_latestBlockSent = h; - for (bool accepted = 1; accepted;) + for (int accepted = 1; accepted;) { accepted = 0; if (m_incomingBlocks.size()) diff --git a/libethereum/PeerNetwork.h b/libethereum/PeerNetwork.h index 3aa794450..aeeaae725 100644 --- a/libethereum/PeerNetwork.h +++ b/libethereum/PeerNetwork.h @@ -117,7 +117,7 @@ enum class NodeMode PeerServer }; -class UPnP; +struct UPnP; class PeerServer { diff --git a/libethereum/RLP.h b/libethereum/RLP.h index 0a586dd21..9b563ed4e 100644 --- a/libethereum/RLP.h +++ b/libethereum/RLP.h @@ -169,7 +169,7 @@ public: /// 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()); } /// 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. std::string toString() const { if (!isString()) return std::string(); return payload().cropped(0, items()).toString(); } /// Converts to string. @throws BadCast if not a string. From b00fa34382461e1770f9e90e125a716dfa8eda12 Mon Sep 17 00:00:00 2001 From: subtly Date: Sun, 2 Feb 2014 08:11:53 -0600 Subject: [PATCH 3/4] #6 mavericks: expand [] operator due to clang bug on latest mavericks/xcode systems. --- libethereum/State.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 7d27520dd..e9e21d9fe 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -103,7 +103,10 @@ void State::ensureCached(Address _a, bool _requireMemory, bool _forceCreate) con TrieDB memdb(const_cast(&m_db), it->second.oldRoot()); // promise we won't alter the overlay! :) map& mem = it->second.takeMemory(); for (auto const& i: memdb) - mem[i.first] = RLP(i.second).toInt(); + if(mem.find(i.first)==mem.end()) + mem.insert(std::pair(i.first,RLP(i.second).toInt())); + else + mem.at(i.first) = RLP(i.second).toInt(); } } @@ -565,7 +568,11 @@ void State::executeBare(Transaction const& _t, Address _sender) m_cache[newAddress] = AddressState(0, 0, sha3(RLPNull)); auto& mem = m_cache[newAddress].takeMemory(); for (uint i = 0; i < _t.data.size(); ++i) - mem[i] = _t.data[i]; + if(mem.find(i)==mem.end()) + mem.insert(std::pair(i,_t.data[i])); + else + mem.at(i) = _t.data[i]; + subBalance(_sender, _t.value + _t.fee); addBalance(newAddress, _t.value); 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) { - if (_v) - myMemory[_n] = _v; - else - myMemory.erase(_n); + if (_v) { + if(myMemory.find(_n)==myMemory.end()) + myMemory.insert(std::pair(_n,_v)); + else + myMemory.at(_n) = _v; + } else { + myMemory.erase(_n); + } }; u256 curPC = 0; From 5843e6b7743a7cd3f172be1f9f6c614920f9ee13 Mon Sep 17 00:00:00 2001 From: subtly Date: Sun, 2 Feb 2014 08:15:16 -0600 Subject: [PATCH 4/4] spaces to tabs --- libethereum/State.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/libethereum/State.cpp b/libethereum/State.cpp index e9e21d9fe..fd3c68f98 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -103,10 +103,10 @@ void State::ensureCached(Address _a, bool _requireMemory, bool _forceCreate) con TrieDB memdb(const_cast(&m_db), it->second.oldRoot()); // promise we won't alter the overlay! :) map& mem = it->second.takeMemory(); for (auto const& i: memdb) - if(mem.find(i.first)==mem.end()) - mem.insert(std::pair(i.first,RLP(i.second).toInt())); - else - mem.at(i.first) = RLP(i.second).toInt(); + if(mem.find(i.first)==mem.end()) + mem.insert(std::pair(i.first,RLP(i.second).toInt())); + else + mem.at(i.first) = RLP(i.second).toInt(); } } @@ -568,10 +568,10 @@ void State::executeBare(Transaction const& _t, Address _sender) m_cache[newAddress] = AddressState(0, 0, sha3(RLPNull)); auto& mem = m_cache[newAddress].takeMemory(); for (uint i = 0; i < _t.data.size(); ++i) - if(mem.find(i)==mem.end()) - mem.insert(std::pair(i,_t.data[i])); - else - mem.at(i) = _t.data[i]; + if(mem.find(i)==mem.end()) + mem.insert(std::pair(i,_t.data[i])); + else + mem.at(i) = _t.data[i]; subBalance(_sender, _t.value + _t.fee); addBalance(newAddress, _t.value); @@ -608,13 +608,13 @@ void State::execute(Address _myAddress, Address _txSender, u256 _txValue, u256 _ auto setMem = [&](u256 _n, u256 _v) { if (_v) { - if(myMemory.find(_n)==myMemory.end()) - myMemory.insert(std::pair(_n,_v)); - else - myMemory.at(_n) = _v; + if(myMemory.find(_n)==myMemory.end()) + myMemory.insert(std::pair(_n,_v)); + else + myMemory.at(_n) = _v; } else { - myMemory.erase(_n); - } + myMemory.erase(_n); + } }; u256 curPC = 0;