diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp
index 0ee2961a1..36b6176f4 100644
--- a/alethzero/MainWin.cpp
+++ b/alethzero/MainWin.cpp
@@ -263,6 +263,7 @@ unsigned Main::installWatch(LogFilter const& _tf, WatchHandler const& _f)
{
auto ret = ethereum()->installWatch(_tf);
m_handlers[ret] = _f;
+ _f(LocalisedLogEntries());
return ret;
}
@@ -270,6 +271,7 @@ unsigned Main::installWatch(dev::h256 _tf, WatchHandler const& _f)
{
auto ret = ethereum()->installWatch(_tf, Reaping::Manual);
m_handlers[ret] = _f;
+ _f(LocalisedLogEntries());
return ret;
}
diff --git a/libethereum/ABI.cpp b/libethereum/ABI.cpp
new file mode 100644
index 000000000..eada1c419
--- /dev/null
+++ b/libethereum/ABI.cpp
@@ -0,0 +1,27 @@
+/*
+ This file is part of cpp-ethereum.
+
+ cpp-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ cpp-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with cpp-ethereum. If not, see .
+*/
+/** @file ABI.cpp
+ * @author Gav Wood
+ * @date 2014
+ */
+
+#include "ABI.h"
+
+using namespace std;
+using namespace dev;
+using namespace dev::eth;
+
diff --git a/libethereum/ABI.h b/libethereum/ABI.h
new file mode 100644
index 000000000..fabda4dc2
--- /dev/null
+++ b/libethereum/ABI.h
@@ -0,0 +1,63 @@
+/*
+ This file is part of cpp-ethereum.
+
+ cpp-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ cpp-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with cpp-ethereum. If not, see .
+*/
+/** @file ABI.h
+ * @author Gav Wood
+ * @date 2014
+ */
+
+#pragma once
+
+namespace dev
+{
+namespace eth
+{
+
+#include
+#include
+#include
+
+template struct ABISerialiser {};
+template struct ABISerialiser> { static bytes serialise(FixedHash const& _t) { static_assert(N <= 32, "Cannot serialise hash > 32 bytes."); static_assert(N > 0, "Cannot serialise zero-length hash."); return bytes(32 - N, 0) + _t.asBytes(); } };
+template <> struct ABISerialiser { static bytes serialise(u256 const& _t) { return h256(_t).asBytes(); } };
+template <> struct ABISerialiser { static bytes serialise(u160 const& _t) { return bytes(12, 0) + h160(_t).asBytes(); } };
+template <> struct ABISerialiser { static bytes serialise(string32 const& _t) { return bytesConstRef((byte const*)_t.data(), 32).toBytes(); } };
+
+inline bytes abiInAux() { return {}; }
+template bytes abiInAux(T const& _t, U const& ... _u)
+{
+ return ABISerialiser::serialise(_t) + abiInAux(_u ...);
+}
+
+template bytes abiIn(std::string _id, T const& ... _t)
+{
+ return sha3(_id).ref().cropped(0, 4).toBytes() + abiInAux(_t ...);
+}
+
+template struct ABIDeserialiser {};
+template struct ABIDeserialiser> { static FixedHash deserialise(bytesConstRef& io_t) { static_assert(N <= 32, "Parameter sizes must be at most 32 bytes."); FixedHash ret; io_t.cropped(32 - N, N).populate(ret.ref()); io_t = io_t.cropped(32); return ret; } };
+template <> struct ABIDeserialiser { static u256 deserialise(bytesConstRef& io_t) { u256 ret = fromBigEndian(io_t.cropped(0, 32)); io_t = io_t.cropped(32); return ret; } };
+template <> struct ABIDeserialiser { static u160 deserialise(bytesConstRef& io_t) { u160 ret = fromBigEndian(io_t.cropped(12, 20)); io_t = io_t.cropped(32); return ret; } };
+template <> struct ABIDeserialiser { static string32 deserialise(bytesConstRef& io_t) { string32 ret; io_t.cropped(0, 32).populate(bytesRef((byte*)ret.data(), 32)); io_t = io_t.cropped(32); return ret; } };
+
+template T abiOut(bytes const& _data)
+{
+ bytesConstRef o(&_data);
+ return ABIDeserialiser::deserialise(o);
+}
+
+}
+}
diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp
index 5af2bebd3..54f23dc84 100644
--- a/libethereum/Client.cpp
+++ b/libethereum/Client.cpp
@@ -250,14 +250,14 @@ void Client::noteChanged(h256Set const& _filters)
if (_filters.size())
cnote << "noteChanged(" << _filters << ")";
// accrue all changes left in each filter into the watches.
- for (auto& i: m_watches)
- if (_filters.count(i.second.id))
+ for (auto& w: m_watches)
+ if (_filters.count(w.second.id))
{
- cwatch << "!!!" << i.first << i.second.id;
- if (m_filters.count(i.second.id))
- i.second.changes += m_filters.at(i.second.id).changes;
- else
- i.second.changes.push_back(LocalisedLogEntry(SpecialLogEntry, 0));
+ cwatch << "!!!" << w.first << w.second.id;
+ if (m_filters.count(w.second.id)) // Normal filtering watch
+ w.second.changes += m_filters.at(w.second.id).changes;
+ else // Special ('pending'/'latest') watch
+ w.second.changes.push_back(LocalisedLogEntry(SpecialLogEntry, 0));
}
// clear the filters now.
for (auto& i: m_filters)
diff --git a/libethereum/Client.h b/libethereum/Client.h
index dad0ca664..013f797b4 100644
--- a/libethereum/Client.h
+++ b/libethereum/Client.h
@@ -41,6 +41,7 @@
#include "State.h"
#include "CommonNet.h"
#include "Miner.h"
+#include "ABI.h"
#include "ClientBase.h"
namespace dev
@@ -71,37 +72,6 @@ private:
std::string m_path;
};
-static const int GenesisBlock = INT_MIN;
-
-template struct ABISerialiser {};
-template struct ABISerialiser> { static bytes serialise(FixedHash const& _t) { static_assert(N <= 32, "Cannot serialise hash > 32 bytes."); static_assert(N > 0, "Cannot serialise zero-length hash."); return bytes(32 - N, 0) + _t.asBytes(); } };
-template <> struct ABISerialiser { static bytes serialise(u256 const& _t) { return h256(_t).asBytes(); } };
-template <> struct ABISerialiser { static bytes serialise(u160 const& _t) { return bytes(12, 0) + h160(_t).asBytes(); } };
-template <> struct ABISerialiser { static bytes serialise(string32 const& _t) { return bytesConstRef((byte const*)_t.data(), 32).toBytes(); } };
-
-inline bytes abiInAux() { return {}; }
-template bytes abiInAux(T const& _t, U const& ... _u)
-{
- return ABISerialiser::serialise(_t) + abiInAux(_u ...);
-}
-
-template bytes abiIn(std::string _id, T const& ... _t)
-{
- return sha3(_id).ref().cropped(0, 4).toBytes() + abiInAux(_t ...);
-}
-
-template struct ABIDeserialiser {};
-template struct ABIDeserialiser> { static FixedHash deserialise(bytesConstRef& io_t) { static_assert(N <= 32, "Parameter sizes must be at most 32 bytes."); FixedHash ret; io_t.cropped(32 - N, N).populate(ret.ref()); io_t = io_t.cropped(32); return ret; } };
-template <> struct ABIDeserialiser { static u256 deserialise(bytesConstRef& io_t) { u256 ret = fromBigEndian(io_t.cropped(0, 32)); io_t = io_t.cropped(32); return ret; } };
-template <> struct ABIDeserialiser { static u160 deserialise(bytesConstRef& io_t) { u160 ret = fromBigEndian(io_t.cropped(12, 20)); io_t = io_t.cropped(32); return ret; } };
-template <> struct ABIDeserialiser { static string32 deserialise(bytesConstRef& io_t) { string32 ret; io_t.cropped(0, 32).populate(bytesRef((byte*)ret.data(), 32)); io_t = io_t.cropped(32); return ret; } };
-
-template T abiOut(bytes const& _data)
-{
- bytesConstRef o(&_data);
- return ABIDeserialiser::deserialise(o);
-}
-
class RemoteMiner: public Miner
{
public:
diff --git a/libethereum/ClientBase.cpp b/libethereum/ClientBase.cpp
index f9caf98ac..de3249991 100644
--- a/libethereum/ClientBase.cpp
+++ b/libethereum/ClientBase.cpp
@@ -224,6 +224,7 @@ unsigned ClientBase::installWatch(h256 _h, Reaping _r)
m_watches[ret] = ClientWatch(_h, _r);
cwatch << "+++" << ret << _h.abridged();
}
+#if INITIAL_STATE_AS_CHANGES
auto ch = logs(ret);
if (ch.empty())
ch.push_back(InitialChange);
@@ -231,6 +232,7 @@ unsigned ClientBase::installWatch(h256 _h, Reaping _r)
Guard l(x_filtersWatches);
swap(m_watches[ret].changes, ch);
}
+#endif
return ret;
}
@@ -260,9 +262,9 @@ LocalisedLogEntries ClientBase::peekWatch(unsigned _watchId) const
{
Guard l(x_filtersWatches);
- cwatch << "peekWatch" << _watchId;
+// cwatch << "peekWatch" << _watchId;
auto& w = m_watches.at(_watchId);
- cwatch << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count();
+// cwatch << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count();
w.lastPoll = chrono::system_clock::now();
return w.changes;
}
@@ -272,9 +274,9 @@ LocalisedLogEntries ClientBase::checkWatch(unsigned _watchId)
Guard l(x_filtersWatches);
LocalisedLogEntries ret;
- cwatch << "checkWatch" << _watchId;
+// cwatch << "checkWatch" << _watchId;
auto& w = m_watches.at(_watchId);
- cwatch << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count();
+// cwatch << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count();
std::swap(ret, w.changes);
w.lastPoll = chrono::system_clock::now();
diff --git a/libethereum/ClientBase.h b/libethereum/ClientBase.h
index 9d9482277..ba4f9e0c4 100644
--- a/libethereum/ClientBase.h
+++ b/libethereum/ClientBase.h
@@ -51,7 +51,11 @@ struct ClientWatch
explicit ClientWatch(h256 _id, Reaping _r): id(_id), lastPoll(_r == Reaping::Automatic ? std::chrono::system_clock::now() : std::chrono::system_clock::time_point::max()) {}
h256 id;
+#if INITIAL_STATE_AS_CHANGES
LocalisedLogEntries changes = LocalisedLogEntries{ InitialChange };
+#else
+ LocalisedLogEntries changes;
+#endif
mutable std::chrono::system_clock::time_point lastPoll = std::chrono::system_clock::now();
};
@@ -161,7 +165,6 @@ protected:
mutable Mutex x_filtersWatches; ///< Our lock.
std::map m_filters; ///< The dictionary of filters that are active.
std::map m_watches; ///< Each and every watch - these reference a filter.
-
};
}}