diff --git a/TODO.txt b/TODO.txt index 06216fb722..f4b3ed8682 100644 --- a/TODO.txt +++ b/TODO.txt @@ -14,6 +14,9 @@ Vinnie's Short List (Changes day to day) -------------------------------------------------------------------------------- +- Use static creation member functions instead of endless constructor + variations in base_uint, uint256, and family. + - Take away the "I" prefix from abstract interface classes, in both the class name and the file name. It is messing up sorting in the IDE. Use "Imp" or suffix for implementations. diff --git a/modules/ripple_app/node/ripple_HyperLevelDBBackendFactory.cpp b/modules/ripple_app/node/ripple_HyperLevelDBBackendFactory.cpp index 68e6855b6b..220591a1cc 100644 --- a/modules/ripple_app/node/ripple_HyperLevelDBBackendFactory.cpp +++ b/modules/ripple_app/node/ripple_HyperLevelDBBackendFactory.cpp @@ -176,7 +176,7 @@ public: else { // Uh oh, corrupted data! - WriteLog (lsFATAL, NodeObject) << "Corrupt NodeObject #" << uint256 (it->key ().data ()); + WriteLog (lsFATAL, NodeObject) << "Corrupt NodeObject #" << uint256::fromVoid (it->key ().data ()); } } else diff --git a/modules/ripple_app/node/ripple_MemoryBackendFactory.cpp b/modules/ripple_app/node/ripple_MemoryBackendFactory.cpp index 3a379c3a5e..c0b665473f 100644 --- a/modules/ripple_app/node/ripple_MemoryBackendFactory.cpp +++ b/modules/ripple_app/node/ripple_MemoryBackendFactory.cpp @@ -28,7 +28,7 @@ public: Status fetch (void const* key, NodeObject::Ptr* pObject) { - uint256 const hash (key); + uint256 const hash (uint256::fromVoid (key)); Map::iterator iter = m_map.find (hash); diff --git a/modules/ripple_app/node/ripple_NodeStore.cpp b/modules/ripple_app/node/ripple_NodeStore.cpp index c490ceb4bf..a8fccd34d2 100644 --- a/modules/ripple_app/node/ripple_NodeStore.cpp +++ b/modules/ripple_app/node/ripple_NodeStore.cpp @@ -71,7 +71,7 @@ NodeObject::Ptr NodeStore::DecodedBlob::createObject () memcpy (data.data (), m_objectData, m_dataBytes); object = NodeObject::createObject ( - m_objectType, m_ledgerIndex, data, uint256 (m_key)); + m_objectType, m_ledgerIndex, data, uint256::fromVoid (m_key)); } return object; diff --git a/modules/ripple_app/node/ripple_SqliteBackendFactory.cpp b/modules/ripple_app/node/ripple_SqliteBackendFactory.cpp index 7335352fa5..178cd1355c 100644 --- a/modules/ripple_app/node/ripple_SqliteBackendFactory.cpp +++ b/modules/ripple_app/node/ripple_SqliteBackendFactory.cpp @@ -66,7 +66,7 @@ public: { ScopedLock sl (m_db->getDBLock()); - uint256 const hash (key); + uint256 const hash (uint256::fromVoid (key)); static SqliteStatement pSt (m_db->getDB()->getSqliteDB(), "SELECT ObjType,LedgerIndex,Object FROM CommittedObjects WHERE Hash = ?;"); diff --git a/modules/ripple_basics/types/ripple_UInt256.h b/modules/ripple_basics/types/ripple_UInt256.h index 4790fea7f3..f3786ac7ed 100644 --- a/modules/ripple_basics/types/ripple_UInt256.h +++ b/modules/ripple_basics/types/ripple_UInt256.h @@ -38,17 +38,22 @@ public: { } +protected: + // This is to disambiguate from other 1 parameter ctors + struct FromVoid { }; + /** Construct from a raw pointer. The buffer pointed to by `data` must be at least 32 bytes. */ - explicit base_uint (void const* data) + base_uint (void const* data, FromVoid) { // BITS must be a multiple of 32 static_bassert ((BITS % 32) == 0); memcpy (&pn [0], data, BITS / 8); } +public: bool isZero () const { @@ -504,10 +509,16 @@ public: *this = b; } - explicit uint256 (void const* data) - : base_uint256 (data) +private: + uint256 (void const* data, FromVoid) + : base_uint256 (data, FromVoid ()) { } +public: + static uint256 fromVoid (void const* data) + { + return uint256 (data, FromVoid ()); + } uint256& operator= (uint64 uHost) {