transaction: Generate hash for when bus and msg are not initialized

This scenario applies for clients that want to create an error log
and have not made a dbus call yet.

Change-Id: I2702fc01bd66deba2606fad92314eeed8c277277
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/sdbusplus/server/transaction.hpp b/sdbusplus/server/transaction.hpp
index b4443c2..9e76a87 100644
--- a/sdbusplus/server/transaction.hpp
+++ b/sdbusplus/server/transaction.hpp
@@ -15,6 +15,15 @@
 // Transaction Id
 extern thread_local uint64_t id;
 
+struct Transaction
+{
+    Transaction(): time(std::time(nullptr)), thread(std::this_thread::get_id())
+        {}
+
+    int time;
+    std::thread::id thread;
+};
+
 } // namespace details
 
 struct Transaction
@@ -73,6 +82,22 @@
     }
 };
 
+/** @ brief Overload of std::hash for details::Transaction */
+template <>
+struct hash<sdbusplus::server::transaction::details::Transaction>
+{
+    auto operator()
+        (sdbusplus::server::transaction::details::Transaction const& t) const
+    {
+        auto hash1 = std::hash<int>{}(t.time);
+        auto hash2 = std::hash<std::thread::id>{}(t.thread);
+
+        // boost::hash_combine() algorithm.
+        return static_cast<size_t>(hash1 ^ (hash2 + 0x9e3779b9 + (hash1 << 6) +
+            (hash1 >> 2)));
+    }
+};
+
 } // namespace std
 
 namespace sdbusplus