diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index f979f0b68..36b10d0bf 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -217,6 +217,16 @@ inline h160 left160(h256 const& _t) return ret; } +inline std::string toString(h256s const& _bs) +{ + std::ostringstream out; + out << "[ "; + for (auto i: _bs) + out << i.abridged() << ", "; + out << "]"; + return out.str(); +} + } namespace std diff --git a/libdevcore/RLP.h b/libdevcore/RLP.h index d3cb5eed1..35e1d1dcf 100644 --- a/libdevcore/RLP.h +++ b/libdevcore/RLP.h @@ -160,7 +160,6 @@ public: explicit operator std::string() const { return toString(); } explicit operator RLPs() const { return toList(); } explicit operator byte() const { return toInt(); } - explicit operator unsigned() const { return toInt(); } explicit operator u256() const { return toInt(); } explicit operator bigint() const { return toInt(); } template explicit operator FixedHash<_N>() const { return toHash>(); } @@ -178,10 +177,59 @@ public: /// Converts to string. @throws BadCast if not a string. std::string toStringStrict() const { if (!isData()) throw BadCast(); return payload().cropped(0, length()).toString(); } - template std::vector toVector() const { std::vector ret; if (isList()) { ret.reserve(itemCount()); for (auto const& i: *this) ret.push_back((T)i); } return ret; } - template std::set toSet() const { std::set ret; if (isList()) { for (auto const& i: *this) ret.insert((T)i); } return ret; } - template std::pair toPair() const { std::pair ret; if (isList()) { ret.first = (T)((*this)[0]); ret.second = (U)((*this)[1]); } return ret; } - template std::array toArray() const { if (itemCount() != N || !isList()) throw BadCast(); std::array ret; for (unsigned i = 0; i < N; ++i) ret[i] = (T)operator[](i); return ret; } + template + std::vector toVector() const + { + std::vector ret; + if (isList()) + { + ret.reserve(itemCount()); + for (auto const& i: *this) + { + ret.push_back((T)i); + } + } + return ret; + } + + template + std::set toSet() const + { + std::set ret; + if (isList()) + { + for (auto const& i: *this) + { + ret.insert((T)i); + } + } + return ret; + } + + template + std::pair toPair() const + { + std::pair ret; + if (isList()) + { + ret.first = (T)(*this)[0]; + ret.second = (U)(*this)[1]; + } + return ret; + } + + template + std::array toArray() const + { + if (itemCount() != N || !isList()) + throw BadCast(); + std::array ret; + for (unsigned i = 0; i < N; ++i) + { + ret[i] = (T)operator[](i); + } + return ret; + } /// Int conversion flags enum diff --git a/libdevcore/_libdevcore.cpp b/libdevcore/_libdevcore.cpp new file mode 100644 index 000000000..4160a7602 --- /dev/null +++ b/libdevcore/_libdevcore.cpp @@ -0,0 +1,10 @@ +#ifdef _MSC_VER +#include "All.h" +#include "Common.cpp" +#include "CommonData.cpp" +#include "CommonIO.cpp" +#include "FixedHash.cpp" +#include "Guards.cpp" +#include "Log.cpp" +#include "RLP.cpp" +#endif diff --git a/libethcore/All.h b/libethcore/All.h index 9cd9b72ee..4a6747ff0 100644 --- a/libethcore/All.h +++ b/libethcore/All.h @@ -3,10 +3,6 @@ #include "BlockInfo.h" #include "CommonEth.h" #include "Dagger.h" -#include "FileSystem.h" -#include "MemoryDB.h" -#include "OverlayDB.h" -#include "SHA3.h" -#include "TrieCommon.h" -#include "TrieDB.h" -#include "UPnP.h" +#include "CryptoHeaders.h" +#include "Exceptions.h" + diff --git a/libethcore/_libethcore.cpp b/libethcore/_libethcore.cpp new file mode 100644 index 000000000..8a3831584 --- /dev/null +++ b/libethcore/_libethcore.cpp @@ -0,0 +1,6 @@ +#ifdef _MSC_VER +#include "All.h" +#include "BlockInfo.cpp" +#include "CommonEth.cpp" +#include "Dagger.cpp" +#endif diff --git a/libethereum/Client.h b/libethereum/Client.h index 25ec794af..2c29175c2 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -202,7 +202,7 @@ public: /// Should we force mining to happen, even without transactions? bool forceMining() const { return m_forceMining; } /// Enable/disable forcing of mining to happen, even without transactions. - void setForceMining(bool _enable) { m_forceMining = _enable; } + void setForceMining(bool _enable); /// Are we mining as fast as we can? bool turboMining() const { return m_turboMining; } /// Enable/disable fast mining. diff --git a/libethereum/CommonNet.cpp b/libethereum/CommonNet.cpp index acf8e220f..eb92f0b18 100644 --- a/libethereum/CommonNet.cpp +++ b/libethereum/CommonNet.cpp @@ -23,3 +23,6 @@ using namespace std; using namespace dev; using namespace dev::eth; + +#pragma GCC diagnostic ignored "-Wunused-variable" +namespace { char dummy; }; diff --git a/libethereum/EthereumHost.cpp b/libethereum/EthereumHost.cpp index 03435ad4f..13a02a146 100644 --- a/libethereum/EthereumHost.cpp +++ b/libethereum/EthereumHost.cpp @@ -148,26 +148,30 @@ void EthereumHost::maintainTransactions(TransactionQueue& _tq, h256 _currentHash for (auto const& p: peers()) { auto ep = p->cap(); - bytes b; - unsigned n = 0; - for (auto const& i: _tq.transactions()) - if ((!m_transactionsSent.count(i.first) && !ep->m_knownTransactions.count(i.first)) || ep->m_requireTransactions || resendAll) + if (ep) + { + bytes b; + unsigned n = 0; + for (auto const& i: _tq.transactions()) + if ((!m_transactionsSent.count(i.first) && !ep->m_knownTransactions.count(i.first)) || ep->m_requireTransactions || resendAll) + { + b += i.second; + ++n; + m_transactionsSent.insert(i.first); + } + ep->clearKnownTransactions(); + + if (n) { - b += i.second; - ++n; - m_transactionsSent.insert(i.first); + RLPStream ts; + EthereumPeer::prep(ts); + ts.appendList(n + 1) << TransactionsPacket; + ts.appendRaw(b, n).swapOut(b); + seal(b); + ep->send(&b); } - if (n) - { - RLPStream ts; - EthereumPeer::prep(ts); - ts.appendList(n + 1) << TransactionsPacket; - ts.appendRaw(b, n).swapOut(b); - seal(b); - ep->send(&b); + ep->m_requireTransactions = false; } - ep->m_knownTransactions.clear(); - ep->m_requireTransactions = false; } } diff --git a/libethereum/EthereumHost.h b/libethereum/EthereumHost.h index 7e2f38230..418439114 100644 --- a/libethereum/EthereumHost.h +++ b/libethereum/EthereumHost.h @@ -197,6 +197,9 @@ private: /// Sync with the BlockChain. It might contain one of our mined blocks, we might have new candidates from the network. void doWork(); + /// Called by peer to add incoming transactions. + void addIncomingTransaction(bytes const& _bytes) { std::lock_guard l(m_incomingLock); m_incomingTransactions.push_back(_bytes); } + void maintainTransactions(TransactionQueue& _tq, h256 _currentBlock); void maintainBlocks(BlockQueue& _bq, h256 _currentBlock); diff --git a/libethereum/EthereumPeer.cpp b/libethereum/EthereumPeer.cpp index 6990e4f59..f8f944916 100644 --- a/libethereum/EthereumPeer.cpp +++ b/libethereum/EthereumPeer.cpp @@ -91,16 +91,6 @@ void EthereumPeer::startInitialSync() } } -inline string toString(h256s const& _bs) -{ - ostringstream out; - out << "[ "; - for (auto i: _bs) - out << i.abridged() << ", "; - out << "]"; - return out.str(); -} - void EthereumPeer::giveUpOnFetch() { clogS(NetNote) << "GIVE UP FETCH; can't get" << toString(m_askedBlocks); @@ -154,7 +144,9 @@ bool EthereumPeer::interpret(RLP const& _r) lock_guard l(host()->m_incomingLock); for (unsigned i = 1; i < _r.itemCount(); ++i) { - host()->m_incomingTransactions.push_back(_r[i].data().toBytes()); + host()->addIncomingTransaction(_r[i].data().toBytes()); + + lock_guard l(x_knownTransactions); m_knownTransactions.insert(sha3(_r[i].data())); } break; diff --git a/libethereum/EthereumPeer.h b/libethereum/EthereumPeer.h index f09710d97..f171767cd 100644 --- a/libethereum/EthereumPeer.h +++ b/libethereum/EthereumPeer.h @@ -68,6 +68,8 @@ private: void giveUpOnFetch(); + void clearKnownTransactions() { std::lock_guard l(x_knownTransactions); m_knownTransactions.clear(); } + unsigned m_protocolVersion; u256 m_networkId; @@ -84,6 +86,7 @@ private: Mutex x_knownBlocks; std::set m_knownBlocks; std::set m_knownTransactions; + std::mutex x_knownTransactions; }; } diff --git a/libethereum/Interface.cpp b/libethereum/Interface.cpp index a9801cc33..7d731bb1f 100644 --- a/libethereum/Interface.cpp +++ b/libethereum/Interface.cpp @@ -20,3 +20,6 @@ */ #include "Interface.h" + +#pragma GCC diagnostic ignored "-Wunused-variable" +namespace { char dummy; }; diff --git a/libethereum/Miner.cpp b/libethereum/Miner.cpp index 5020a72c9..9b651e2c5 100644 --- a/libethereum/Miner.cpp +++ b/libethereum/Miner.cpp @@ -35,14 +35,15 @@ Miner::Miner(MinerHost* _host, unsigned _id): void Miner::doWork() { // Do some mining. - if ((m_pendingCount || m_host->force()) && m_miningStatus != Mined) + if (m_miningStatus != Waiting && m_miningStatus != Mined) { if (m_miningStatus == Preparing) { - m_miningStatus = Mining; - m_host->setupState(m_mineState); - m_pendingCount = m_mineState.pending().size(); + if (m_host->force() || m_mineState.pending().size()) + m_miningStatus = Mining; + else + m_miningStatus = Waiting; { Guard l(x_mineInfo); @@ -52,26 +53,29 @@ void Miner::doWork() } } + if (m_miningStatus == Mining) + { // Mine for a while. - MineInfo mineInfo = m_mineState.mine(100, m_host->turbo()); + MineInfo mineInfo = m_mineState.mine(100, m_host->turbo()); - { - Guard l(x_mineInfo); - m_mineProgress.best = min(m_mineProgress.best, mineInfo.best); - m_mineProgress.current = mineInfo.best; - m_mineProgress.requirement = mineInfo.requirement; - m_mineProgress.ms += 100; - m_mineProgress.hashes += mineInfo.hashes; - m_mineHistory.push_back(mineInfo); - } - if (mineInfo.completed) - { - m_mineState.completeMine(); - m_host->onComplete(); - m_miningStatus = Mined; + { + Guard l(x_mineInfo); + m_mineProgress.best = min(m_mineProgress.best, mineInfo.best); + m_mineProgress.current = mineInfo.best; + m_mineProgress.requirement = mineInfo.requirement; + m_mineProgress.ms += 100; + m_mineProgress.hashes += mineInfo.hashes; + m_mineHistory.push_back(mineInfo); + } + if (mineInfo.completed) + { + m_mineState.completeMine(); + m_host->onComplete(); + m_miningStatus = Mined; + } + else + m_host->onProgressed(); } - else - m_host->onProgressed(); } else { diff --git a/libethereum/Miner.h b/libethereum/Miner.h index bee4d70e4..763249b7d 100644 --- a/libethereum/Miner.h +++ b/libethereum/Miner.h @@ -126,10 +126,9 @@ private: MinerHost* m_host = nullptr; ///< Our host. - enum MiningStatus { Preparing, Mining, Mined, Stopping, Stopped }; - MiningStatus m_miningStatus = Preparing;///< TODO: consider mutex/atomic variable. + enum MiningStatus { Waiting, Preparing, Mining, Mined, Stopping, Stopped }; + MiningStatus m_miningStatus = Waiting; ///< TODO: consider mutex/atomic variable. State m_mineState; ///< The state on which we are mining, generally equivalent to m_postMine. - mutable unsigned m_pendingCount = 0; ///< How many pending transactions are there in m_mineState? mutable std::mutex x_mineInfo; ///< Lock for the mining progress & history. MineProgress m_mineProgress; ///< What's our progress? diff --git a/libethereum/PastMessage.cpp b/libethereum/PastMessage.cpp index 377b7e4d2..d81ae672c 100644 --- a/libethereum/PastMessage.cpp +++ b/libethereum/PastMessage.cpp @@ -23,3 +23,6 @@ using namespace std; using namespace dev; using namespace dev::eth; + +#pragma GCC diagnostic ignored "-Wunused-variable" +namespace { char dummy; }; diff --git a/libevm/VM.h b/libevm/VM.h index 801779e50..cbecc3ee7 100644 --- a/libevm/VM.h +++ b/libevm/VM.h @@ -156,7 +156,11 @@ template dev::bytesConstRef dev::eth::VM::go(Ext& _ext, OnOpFunc con require(3); newTempSize = memNeed(m_stack.back(), m_stack[m_stack.size() - 3]); break; - + case Instruction::EXTCODECOPY: + require(4); + newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 4]); + break; + case Instruction::BALANCE: runGas = c_balanceGas; break; diff --git a/libevm/_libevm.cpp b/libevm/_libevm.cpp new file mode 100644 index 000000000..27186cbf2 --- /dev/null +++ b/libevm/_libevm.cpp @@ -0,0 +1,6 @@ +#ifdef _MSC_VER +#include "All.h" +#include "ExtVMFace.cpp" +#include "FeeStructure.cpp" +#include "VM.cpp" +#endif diff --git a/libevmface/Instruction.h b/libevmface/Instruction.h index 8d4ca989a..6c87b7a76 100644 --- a/libevmface/Instruction.h +++ b/libevmface/Instruction.h @@ -32,143 +32,140 @@ namespace dev namespace eth { -// TODO: Update comments. - /// Virtual machine bytecode instruction. enum class Instruction: uint8_t { STOP = 0x00, ///< halts execution - ADD, - MUL, - SUB, - DIV, - SDIV, - MOD, - SMOD, - EXP, - NEG, - LT, - GT, - SLT, - SGT, - EQ, - NOT, - - AND = 0x10, - OR, - XOR, - BYTE, - ADDMOD, - MULMOD, - - SHA3 = 0x20, - - ADDRESS = 0x30, - BALANCE, - ORIGIN, - CALLER, - CALLVALUE, - CALLDATALOAD, - CALLDATASIZE, - CALLDATACOPY, - CODESIZE, - CODECOPY, - GASPRICE, - EXTCODESIZE, - EXTCODECOPY, - - PREVHASH = 0x40, - COINBASE, - TIMESTAMP, - NUMBER, - DIFFICULTY, - GASLIMIT, - - POP = 0x50, - MLOAD = 0x53, - MSTORE, - MSTORE8, - SLOAD, - SSTORE, - JUMP, - JUMPI, - PC, - MSIZE, - GAS, - - PUSH1 = 0x60, - PUSH2, - PUSH3, - PUSH4, - PUSH5, - PUSH6, - PUSH7, - PUSH8, - PUSH9, - PUSH10, - PUSH11, - PUSH12, - PUSH13, - PUSH14, - PUSH15, - PUSH16, - PUSH17, - PUSH18, - PUSH19, - PUSH20, - PUSH21, - PUSH22, - PUSH23, - PUSH24, - PUSH25, - PUSH26, - PUSH27, - PUSH28, - PUSH29, - PUSH30, - PUSH31, - PUSH32, - - DUP1 = 0x80, - DUP2, - DUP3, - DUP4, - DUP5, - DUP6, - DUP7, - DUP8, - DUP9, - DUP10, - DUP11, - DUP12, - DUP13, - DUP14, - DUP15, - DUP16, - - SWAP1 = 0x90, - SWAP2, - SWAP3, - SWAP4, - SWAP5, - SWAP6, - SWAP7, - SWAP8, - SWAP9, - SWAP10, - SWAP11, - SWAP12, - SWAP13, - SWAP14, - SWAP15, - SWAP16, - - CREATE = 0xf0, - CALL, - RETURN, - POST, + ADD, ///< addition operation + MUL, ///< mulitplication operation + SUB, ///< subtraction operation + DIV, ///< integer division operation + SDIV, ///< signed integer division operation + MOD, ///< modulo remainder operation + SMOD, ///< signed modulo remainder operation + EXP, ///< exponential operation + NEG, ///< negation operation + LT, ///< less-than comparision + GT, ///< greater-than comparision + SLT, ///< signed less-than comparision + SGT, ///< signed greater-than comparision + EQ, ///< equality comparision + NOT, ///< simple not operator + + AND = 0x10, ///< bitwise AND operation + OR, ///< bitwise OR operation + XOR, ///< bitwise XOR operation + BYTE, ///< retrieve single byte from word + ADDMOD, ///< unsigned modular addition + MULMOD, ///< unsigned modular multiplication + SHA3 = 0x20, ///< compute SHA3-256 hash + + ADDRESS = 0x30, ///< get address of currently executing account + BALANCE, ///< get balance of the given account + ORIGIN, ///< get execution origination address + CALLER, ///< get caller address + CALLVALUE, ///< get deposited value by the instruction/transaction responsible for this execution + CALLDATALOAD, ///< get input data of current environment + CALLDATASIZE, ///< get size of input data in current environment + CALLDATACOPY, ///< copy input data in current environment to memory + CODESIZE, ///< get size of code running in current environment + CODECOPY, ///< copy code running in current environment to memory + GASPRICE, ///< get price of gas in current environment + EXTCODESIZE, ///< get external code size (from another contract) + EXTCODECOPY, ///< copy external code (from another contract) + + PREVHASH = 0x40, ///< get hash of most recent complete block + COINBASE, ///< get the block's coinbase address + TIMESTAMP, ///< get the block's timestamp + NUMBER, ///< get the block's number + DIFFICULTY, ///< get the block's difficulty + GASLIMIT, ///< get the block's gas limit + + POP = 0x50, ///< remove item from stack + MLOAD = 0x53, ///< load word from memory + MSTORE, ///< save word to memory + MSTORE8, ///< save byte to memory + SLOAD, ///< load word from storage + SSTORE, ///< save word to storage + JUMP, ///< alter the program counter + JUMPI, ///< conditionally alter the program counter + PC, ///< get the program counter + MSIZE, ///< get the size of active memory + GAS, ///< get the amount of available gas + + PUSH1 = 0x60, ///< place 1 byte item on stack + PUSH2, ///< place 2 byte item on stack + PUSH3, ///< place 3 byte item on stack + PUSH4, ///< place 4 byte item on stack + PUSH5, ///< place 5 byte item on stack + PUSH6, ///< place 6 byte item on stack + PUSH7, ///< place 7 byte item on stack + PUSH8, ///< place 8 byte item on stack + PUSH9, ///< place 9 byte item on stack + PUSH10, ///< place 10 byte item on stack + PUSH11, ///< place 11 byte item on stack + PUSH12, ///< place 12 byte item on stack + PUSH13, ///< place 13 byte item on stack + PUSH14, ///< place 14 byte item on stack + PUSH15, ///< place 15 byte item on stack + PUSH16, ///< place 16 byte item on stack + PUSH17, ///< place 17 byte item on stack + PUSH18, ///< place 18 byte item on stack + PUSH19, ///< place 19 byte item on stack + PUSH20, ///< place 20 byte item on stack + PUSH21, ///< place 21 byte item on stack + PUSH22, ///< place 22 byte item on stack + PUSH23, ///< place 23 byte item on stack + PUSH24, ///< place 24 byte item on stack + PUSH25, ///< place 25 byte item on stack + PUSH26, ///< place 26 byte item on stack + PUSH27, ///< place 27 byte item on stack + PUSH28, ///< place 28 byte item on stack + PUSH29, ///< place 29 byte item on stack + PUSH30, ///< place 30 byte item on stack + PUSH31, ///< place 31 byte item on stack + PUSH32, ///< place 32 byte item on stack + + DUP1 = 0x80, ///< copies the highest item in the stack to the top of the stack + DUP2, ///< copies the second highest item in the stack to the top of the stack + DUP3, ///< copies the third highest item in the stack to the top of the stack + DUP4, ///< copies the 4th highest item in the stack to the top of the stack + DUP5, ///< copies the 5th highest item in the stack to the top of the stack + DUP6, ///< copies the 6th highest item in the stack to the top of the stack + DUP7, ///< copies the 7th highest item in the stack to the top of the stack + DUP8, ///< copies the 8th highest item in the stack to the top of the stack + DUP9, ///< copies the 9th highest item in the stack to the top of the stack + DUP10, ///< copies the 10th highest item in the stack to the top of the stack + DUP11, ///< copies the 11th highest item in the stack to the top of the stack + DUP12, ///< copies the 12th highest item in the stack to the top of the stack + DUP13, ///< copies the 13th highest item in the stack to the top of the stack + DUP14, ///< copies the 14th highest item in the stack to the top of the stack + DUP15, ///< copies the 15th highest item in the stack to the top of the stack + DUP16, ///< copies the 16th highest item in the stack to the top of the stack + + SWAP1 = 0x90, ///< swaps the highest and second highest value on the stack + SWAP2, ///< swaps the highest and third highest value on the stack + SWAP3, ///< swaps the highest and 4th highest value on the stack + SWAP4, ///< swaps the highest and 5th highest value on the stack + SWAP5, ///< swaps the highest and 6th highest value on the stack + SWAP6, ///< swaps the highest and 7th highest value on the stack + SWAP7, ///< swaps the highest and 8th highest value on the stack + SWAP8, ///< swaps the highest and 9th highest value on the stack + SWAP9, ///< swaps the highest and 10th highest value on the stack + SWAP10, ///< swaps the highest and 11th highest value on the stack + SWAP11, ///< swaps the highest and 12th highest value on the stack + SWAP12, ///< swaps the highest and 13th highest value on the stack + SWAP13, ///< swaps the highest and 14th highest value on the stack + SWAP14, ///< swaps the highest and 15th highest value on the stack + SWAP15, ///< swaps the highest and 16th highest value on the stack + SWAP16, ///< swaps the highest and 17th highest value on the stack + + CREATE = 0xf0, ///< create a new account with associated code + CALL, ///< message-call into an account + RETURN, ///< halt execution returning output data + POST, ///< asynchronous call without output (adds a message to the post queue) CALLSTATELESS, - SUICIDE = 0xff + SUICIDE = 0xff ///< halt execution and register account for later deletion }; /// Information structure for a particular instruction. diff --git a/libp2p/Host.h b/libp2p/Host.h index 57f0a0022..e8b95e2a8 100644 --- a/libp2p/Host.h +++ b/libp2p/Host.h @@ -77,7 +77,7 @@ public: /// Register a peer-capability; all new peer connections will have this capability. template std::shared_ptr registerCapability(T* _t) { _t->m_host = this; auto ret = std::shared_ptr(_t); m_capabilities[T::staticName()] = ret; return ret; } - bool haveCapability(std::string const& _name) const { return m_capabilities.count(_name); } + bool haveCapability(std::string const& _name) const { return m_capabilities.count(_name) != 0; } std::vector caps() const { std::vector ret; for (auto const& i: m_capabilities) ret.push_back(i.first); return ret; } template std::shared_ptr cap() const { try { return std::static_pointer_cast(m_capabilities.at(T::staticName())); } catch (...) { return nullptr; } } diff --git a/libp2p/Session.cpp b/libp2p/Session.cpp index ea75c687f..f117b426e 100644 --- a/libp2p/Session.cpp +++ b/libp2p/Session.cpp @@ -266,19 +266,19 @@ void Session::writeImpl(bytes& _buffer) if (!m_socket.is_open()) return; - lock_guard l(m_writeLock); - m_writeQueue.push_back(_buffer); - if (m_writeQueue.size() == 1) + bool doWrite = false; + { + lock_guard l(m_writeLock); + m_writeQueue.push_back(_buffer); + doWrite = (m_writeQueue.size() == 1); + } + + if (doWrite) write(); } void Session::write() { -// cerr << (void*)this << " write" << endl; - lock_guard l(m_writeLock); - if (m_writeQueue.empty()) - return; - const bytes& bytes = m_writeQueue[0]; auto self(shared_from_this()); ba::async_write(m_socket, ba::buffer(bytes), [this, self](boost::system::error_code ec, std::size_t /*length*/) @@ -290,12 +290,16 @@ void Session::write() { cwarn << "Error sending: " << ec.message(); dropped(); + return; } else { + lock_guard l(m_writeLock); m_writeQueue.pop_front(); - write(); + if (m_writeQueue.empty()) + return; } + write(); }); } diff --git a/libp2p/Session.h b/libp2p/Session.h index 289ec1063..7c3fc3732 100644 --- a/libp2p/Session.h +++ b/libp2p/Session.h @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -85,7 +86,7 @@ private: Host* m_server; - std::recursive_mutex m_writeLock; + std::mutex m_writeLock; std::deque m_writeQueue; mutable bi::tcp::socket m_socket; ///< Mutable to ask for native_handle(). diff --git a/libp2p/_libp2p.cpp b/libp2p/_libp2p.cpp new file mode 100644 index 000000000..440ba362b --- /dev/null +++ b/libp2p/_libp2p.cpp @@ -0,0 +1,9 @@ +#ifdef _MSC_VER +#include "All.h" +#include "Capability.cpp" +#include "Common.cpp" +#include "Host.cpp" +#include "HostCapability.cpp" +#include "Session.cpp" +#include "UPnP.cpp" +#endif diff --git a/libwhisper/Common.h b/libwhisper/Common.h index 2324be024..ba4285f2b 100644 --- a/libwhisper/Common.h +++ b/libwhisper/Common.h @@ -33,6 +33,7 @@ namespace dev namespace shh { +/* this makes these symbols ambiguous on VS2013 using h256 = dev::h256; using h512 = dev::h512; using h256s = dev::h256s; @@ -42,6 +43,7 @@ using RLP = dev::RLP; using bytesRef = dev::bytesRef; using bytesConstRef = dev::bytesConstRef; using h256Set = dev::h256Set; +*/ class WhisperHost; class WhisperPeer; diff --git a/libwhisper/WhisperPeer.h b/libwhisper/WhisperPeer.h index d428670c3..94d3233c1 100644 --- a/libwhisper/WhisperPeer.h +++ b/libwhisper/WhisperPeer.h @@ -95,7 +95,7 @@ class MessageFilter public: MessageFilter() {} MessageFilter(std::vector > const& _m): m_topicMasks(_m) {} - MessageFilter(RLP const& _r): m_topicMasks((std::vector >)_r) {} + MessageFilter(RLP const& _r): m_topicMasks((std::vector>)_r) {} void fillStream(RLPStream& _s) const { _s << m_topicMasks; } h256 sha3() const { RLPStream s; fillStream(s); return dev::eth::sha3(s.out()); } diff --git a/libwhisper/_libwhisper.cpp b/libwhisper/_libwhisper.cpp new file mode 100644 index 000000000..58bd97213 --- /dev/null +++ b/libwhisper/_libwhisper.cpp @@ -0,0 +1,5 @@ +#ifdef _MSC_VER +#include "All.h" +#include "Common.cpp" +#include "WhisperPeer.cpp" +#endif diff --git a/windows/LibEthereum.vcxproj b/windows/LibEthereum.vcxproj index c806de064..196325353 100644 --- a/windows/LibEthereum.vcxproj +++ b/windows/LibEthereum.vcxproj @@ -19,22 +19,69 @@ - - - - - - - - - - - - - - - - + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + + + + + + + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + @@ -44,9 +91,10 @@ - + + @@ -56,14 +104,68 @@ - - - + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + + true + true + true + true + + stdafx.h Create @@ -73,30 +175,114 @@ - - - - - - - - - - - - - - - - - - - - - - + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + + + + + + + + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + @@ -104,9 +290,10 @@ - + + @@ -116,10 +303,30 @@ - - - - + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + @@ -127,6 +334,60 @@ + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + diff --git a/windows/LibEthereum.vcxproj.filters b/windows/LibEthereum.vcxproj.filters index 3280140fc..5a650b0c5 100644 --- a/windows/LibEthereum.vcxproj.filters +++ b/windows/LibEthereum.vcxproj.filters @@ -22,15 +22,6 @@ libethereum - - libethereum - - - libethereum - - - libethereum - libethereum @@ -40,15 +31,6 @@ libethereum - - libethcore - - - libethcore - - - libethcore - libevm @@ -58,48 +40,9 @@ libevm - - libethential - - - libethential - - - libethential - - - libethential - - - libethential - - - libethential - libevmface - - libethcore - - - libethcore - - - libethcore - - - libethcore - - - libethcore - - - libethcore - - - libethcore - liblll @@ -136,6 +79,102 @@ libethereum + + libdevcrypto + + + libdevcrypto + + + libdevcrypto + + + libdevcrypto + + + libdevcrypto + + + libdevcrypto + + + libdevcrypto + + + libethcore + + + libethcore + + + libethcore + + + libdevcore + + + libdevcore + + + libdevcore + + + libdevcore + + + libdevcore + + + libdevcore + + + libdevcore + + + libethcore + + + libevm + + + libethereum + + + libethereum + + + libethereum + + + libethereum + + + libethereum + + + libp2p + + + libp2p + + + libp2p + + + libp2p + + + libp2p + + + libp2p + + + libwhisper + + + libwhisper + @@ -159,15 +198,6 @@ libethereum - - libethereum - - - libethereum - - - libethereum - libethereum @@ -177,18 +207,6 @@ libethereum - - libethcore - - - libethcore - - - libethcore - - - libethcore - libevm @@ -198,66 +216,12 @@ libevm - - libethential - - - libethential - - - libethential - - - libethential - - - libethential - - - libethential - - - libethential - - - libethential - - - libethential - libevm libevmface - - libethcore - - - libethcore - - - libethcore - - - libethcore - - - libethcore - - - libethcore - - - libethcore - - - libethcore - - - libethcore - liblll @@ -300,6 +264,126 @@ libethereum + + libdevcrypto + + + libdevcrypto + + + libdevcrypto + + + libdevcrypto + + + libdevcrypto + + + libdevcrypto + + + libdevcrypto + + + libdevcrypto + + + libdevcrypto + + + libethcore + + + libethcore + + + libethcore + + + libethcore + + + libethcore + + + libethcore + + + libdevcore + + + libdevcore + + + libdevcore + + + libdevcore + + + libdevcore + + + libdevcore + + + libdevcore + + + libdevcore + + + libdevcore + + + libdevcore + + + libethereum + + + libethereum + + + libethereum + + + libethereum + + + libethereum + + + libethereum + + + libp2p + + + libp2p + + + libp2p + + + libp2p + + + libp2p + + + libp2p + + + libp2p + + + libwhisper + + + libwhisper + @@ -317,11 +401,20 @@ {ed9ad1b3-700c-47f9-8548-a90b5ef179ac} - - {35c32f6c-3f19-4603-8084-1b88ec9ae498} - {e6332606-e0ca-48aa-8a6b-303971ba7a93} + + {fae2102b-d574-40fc-9f90-1b9ed0d117ac} + + + {35c32f6c-3f19-4603-8084-1b88ec9ae498} + + + {fc2cb618-ab0c-45b6-8eb9-6d88e0336fa9} + + + {36748e80-c977-4fee-84e6-699c039dff87} + \ No newline at end of file