From cad50c68a85488833080d68d586275cb7b9cc06d Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Fri, 7 Mar 2014 18:54:11 -0500 Subject: [PATCH] General tidy and refactoring: * Use nullptr (C++11) instead of NULL. * Put each file into its own namespace declaration. * Remove "using namespace" directives and add scope qualifiers. * Control when beast's implementation of std::equal (C++14) is used. * Tidy up some const declarations. Conflicts: src/ripple_app/shamap/SHAMapSync.cpp src/ripple_app/tx/TransactionEngine.cpp --- Builds/VisualStudio2013/RippleD.vcxproj | 6 + .../VisualStudio2013/RippleD.vcxproj.filters | 3 + src/beast/beast/cxx14/algorithm.h | 4 + src/beast/beast/cxx14/config.h | 12 +- .../modules/beast_asio/async/AsyncObject.h | 2 +- src/beast/modules/beast_core/beast_core.cpp | 5 - src/beast/modules/beast_core/beast_core.h | 7 +- .../modules/beast_core/containers/Array.h | 5 + .../containers/ArrayAllocationBase.h | 5 + .../beast_core/containers/DynamicObject.cpp | 5 + .../beast_core/containers/DynamicObject.h | 5 +- .../beast_core/containers/ElementComparator.h | 5 + .../beast_core/containers/LinkedListPointer.h | 3 + .../beast_core/containers/NamedValueSet.cpp | 5 + .../beast_core/containers/NamedValueSet.h | 4 + .../beast_core/containers/OwnedArray.h | 4 + .../beast_core/containers/PropertySet.cpp | 5 + .../beast_core/containers/PropertySet.h | 4 + .../beast_core/containers/ScopedValueSetter.h | 3 + .../modules/beast_core/containers/SparseSet.h | 5 +- .../modules/beast_core/containers/Variant.cpp | 5 + .../modules/beast_core/containers/Variant.h | 4 + .../beast_core/diagnostic/FPUFlags.cpp | 5 + .../modules/beast_core/diagnostic/FPUFlags.h | 5 + .../beast_core/diagnostic/FatalError.cpp | 5 + .../beast_core/diagnostic/FatalError.h | 5 + .../diagnostic/MeasureFunctionCallTime.h | 5 + .../beast_core/diagnostic/SemanticVersion.cpp | 5 + .../beast_core/diagnostic/SemanticVersion.h | 5 + .../modules/beast_core/diagnostic/Throw.h | 5 + .../beast_core/diagnostic/UnitTest.cpp | 5 + .../modules/beast_core/diagnostic/UnitTest.h | 5 + .../diagnostic/UnitTestUtilities.cpp | 5 + .../beast_core/diagnostic/UnitTestUtilities.h | 5 + .../beast_core/files/DirectoryIterator.cpp | 5 + .../beast_core/files/DirectoryIterator.h | 5 + src/beast/modules/beast_core/files/File.cpp | 4 + src/beast/modules/beast_core/files/File.h | 5 + .../beast_core/files/FileInputStream.cpp | 5 + .../beast_core/files/FileInputStream.h | 5 + .../beast_core/files/FileOutputStream.cpp | 7 +- .../beast_core/files/FileOutputStream.h | 5 + .../beast_core/files/FileSearchPath.cpp | 5 + .../modules/beast_core/files/FileSearchPath.h | 5 + .../beast_core/files/MemoryMappedFile.h | 3 + .../beast_core/files/RandomAccessFile.cpp | 5 + .../beast_core/files/RandomAccessFile.h | 5 + .../beast_core/files/TemporaryFile.cpp | 5 + .../modules/beast_core/files/TemporaryFile.h | 5 + src/beast/modules/beast_core/json/JSON.cpp | 5 + src/beast/modules/beast_core/json/JSON.h | 4 + .../modules/beast_core/logging/FileLogger.cpp | 5 + .../modules/beast_core/logging/FileLogger.h | 4 + .../modules/beast_core/logging/Logger.cpp | 5 + src/beast/modules/beast_core/logging/Logger.h | 4 + .../modules/beast_core/maths/BigInteger.cpp | 5 + .../modules/beast_core/maths/BigInteger.h | 4 + src/beast/modules/beast_core/maths/Math.h | 5 + src/beast/modules/beast_core/maths/Random.cpp | 5 + src/beast/modules/beast_core/maths/Random.h | 4 + src/beast/modules/beast_core/maths/Range.h | 4 + .../modules/beast_core/memory/CacheLine.h | 7 +- .../beast_core/memory/MemoryAlignment.h | 7 +- .../modules/beast_core/memory/MemoryBlock.cpp | 7 +- .../modules/beast_core/memory/MemoryBlock.h | 5 + .../beast_core/memory/OptionalScopedPointer.h | 4 + .../beast_core/memory/SharedSingleton.h | 5 + src/beast/modules/beast_core/misc/Main.cpp | 5 + src/beast/modules/beast_core/misc/Main.h | 5 + src/beast/modules/beast_core/misc/Result.cpp | 5 + src/beast/modules/beast_core/misc/Result.h | 5 + src/beast/modules/beast_core/misc/Uuid.cpp | 5 + src/beast/modules/beast_core/misc/Uuid.h | 4 + .../modules/beast_core/misc/WindowsRegistry.h | 6 + .../beast_core/native/android_Files.cpp | 5 + .../beast_core/native/android_JNIHelpers.h | 5 + .../beast_core/native/android_Misc.cpp | 5 + .../beast_core/native/android_Network.cpp | 5 + .../beast_core/native/android_SystemStats.cpp | 5 + .../beast_core/native/android_Threads.cpp | 5 + .../modules/beast_core/native/bsd_Files.cpp | 5 + .../modules/beast_core/native/bsd_Network.cpp | 5 + .../beast_core/native/bsd_SystemStats.cpp | 5 + .../modules/beast_core/native/bsd_Threads.cpp | 5 + .../modules/beast_core/native/linux_Files.cpp | 5 + .../beast_core/native/linux_Network.cpp | 5 + .../beast_core/native/linux_SystemStats.cpp | 5 + .../beast_core/native/linux_Threads.cpp | 5 + .../modules/beast_core/native/mac_Files.mm | 5 + .../modules/beast_core/native/mac_Network.mm | 5 + .../modules/beast_core/native/mac_Strings.mm | 5 + .../beast_core/native/mac_SystemStats.mm | 5 + .../modules/beast_core/native/mac_Threads.mm | 5 + .../beast_core/native/osx_ObjCHelpers.h | 4 + .../beast_core/native/posix_FPUFlags.cpp | 5 + .../beast_core/native/posix_SharedCode.h | 5 + .../beast_core/native/win32_ComSmartPtr.h | 5 + .../beast_core/native/win32_FPUFlags.cpp | 5 + .../modules/beast_core/native/win32_Files.cpp | 5 + .../beast_core/native/win32_Network.cpp | 5 + .../beast_core/native/win32_Registry.cpp | 5 + .../beast_core/native/win32_SystemStats.cpp | 5 + .../beast_core/native/win32_Threads.cpp | 5 + .../modules/beast_core/network/MACAddress.cpp | 5 + .../modules/beast_core/network/MACAddress.h | 4 + .../modules/beast_core/network/NamedPipe.cpp | 5 + .../modules/beast_core/network/NamedPipe.h | 4 + .../modules/beast_core/network/Socket.cpp | 5 + src/beast/modules/beast_core/network/Socket.h | 4 + .../streams/BufferedInputStream.cpp | 5 + .../beast_core/streams/BufferedInputStream.h | 5 + .../beast_core/streams/FileInputSource.cpp | 5 + .../beast_core/streams/FileInputSource.h | 4 + .../modules/beast_core/streams/InputSource.h | 4 + .../beast_core/streams/InputStream.cpp | 4 + .../modules/beast_core/streams/InputStream.h | 5 + .../beast_core/streams/MemoryInputStream.cpp | 5 + .../beast_core/streams/MemoryInputStream.h | 5 + .../beast_core/streams/MemoryOutputStream.cpp | 7 +- .../beast_core/streams/MemoryOutputStream.h | 7 +- .../beast_core/streams/OutputStream.cpp | 5 + .../modules/beast_core/streams/OutputStream.h | 5 + .../beast_core/streams/SubregionStream.cpp | 5 + .../beast_core/streams/SubregionStream.h | 5 + .../modules/beast_core/system/Functional.h | 5 + .../modules/beast_core/system/SystemStats.cpp | 5 + .../modules/beast_core/system/SystemStats.h | 4 + .../modules/beast_core/text/Identifier.cpp | 5 + .../modules/beast_core/text/Identifier.h | 4 + .../modules/beast_core/text/LexicalCast.cpp | 5 + .../modules/beast_core/text/LexicalCast.h | 5 + .../beast_core/text/LocalisedStrings.cpp | 5 + .../beast_core/text/LocalisedStrings.h | 4 + .../modules/beast_core/text/StringArray.cpp | 5 + .../modules/beast_core/text/StringArray.h | 4 + .../beast_core/text/StringPairArray.cpp | 5 + .../modules/beast_core/text/StringPairArray.h | 4 + .../modules/beast_core/text/StringPool.cpp | 5 + .../modules/beast_core/text/StringPool.h | 4 + .../beast_core/thread/DeadlineTimer.cpp | 5 + .../modules/beast_core/thread/DeadlineTimer.h | 5 + .../modules/beast_core/thread/MutexTraits.h | 5 + .../modules/beast_core/thread/Workers.cpp | 5 + src/beast/modules/beast_core/thread/Workers.h | 5 + .../beast_core/thread/detail/ScopedLock.h | 5 + .../beast_core/thread/detail/TrackedMutex.h | 5 + .../beast_core/thread/impl/TrackedMutex.cpp | 4 + .../beast_core/thread/impl/TrackedMutex.h | 5 + .../beast_core/thread/impl/TrackedMutexType.h | 5 + .../thread/impl/UntrackedMutexType.h | 5 + .../beast_core/threads/ChildProcess.cpp | 5 + .../modules/beast_core/threads/ChildProcess.h | 3 + .../beast_core/threads/CriticalSection.h | 4 + .../beast_core/threads/DynamicLibrary.h | 4 + .../threads/HighResolutionTimer.cpp | 5 + .../beast_core/threads/HighResolutionTimer.h | 4 + .../beast_core/threads/InterProcessLock.h | 4 + .../modules/beast_core/threads/Process.h | 4 + .../modules/beast_core/threads/ScopedLock.h | 5 + .../modules/beast_core/threads/SpinDelay.cpp | 5 + .../modules/beast_core/threads/SpinDelay.h | 5 + .../modules/beast_core/time/AtExitHook.cpp | 5 + .../modules/beast_core/time/AtExitHook.h | 5 + .../beast_core/time/PerformanceCounter.cpp | 5 + .../beast_core/time/PerformanceCounter.h | 5 + src/beast/modules/beast_core/time/Time.cpp | 5 + src/beast/modules/beast_core/time/Time.h | 4 + .../modules/beast_core/xml/XmlDocument.cpp | 7 +- .../modules/beast_core/xml/XmlDocument.h | 6 +- .../modules/beast_core/xml/XmlElement.cpp | 5 + src/beast/modules/beast_core/xml/XmlElement.h | 4 + .../zip/GZIPCompressorOutputStream.cpp | 5 + .../zip/GZIPCompressorOutputStream.h | 5 + .../zip/GZIPDecompressorInputStream.cpp | 5 + .../zip/GZIPDecompressorInputStream.h | 5 + src/beast/modules/beast_core/zip/ZipFile.cpp | 5 + src/beast/modules/beast_core/zip/ZipFile.h | 5 + src/ripple/common/KeyCache.h | 16 +- src/ripple/common/TaggedCache.h | 22 +- src/ripple/common/impl/KeyCache.cpp | 4 +- src/ripple/common/impl/MultiSocketType.h | 106 ++++--- src/ripple/common/impl/ResolverAsio.cpp | 10 +- src/ripple/common/impl/RippleSSLContext.cpp | 9 +- src/ripple/common/impl/TaggedCache.cpp | 6 +- src/ripple/common/impl/counted_bind.cpp | 10 +- src/ripple/http/api/Handler.h | 5 +- src/ripple/http/api/Port.h | 11 +- src/ripple/http/api/ScopedStream.h | 5 +- src/ripple/http/api/Server.h | 9 +- src/ripple/http/api/Session.h | 15 +- src/ripple/http/impl/Door.h | 8 +- src/ripple/http/impl/Peer.h | 26 +- src/ripple/http/impl/Port.cpp | 4 +- src/ripple/http/impl/Server.cpp | 4 +- src/ripple/http/impl/ServerImpl.cpp | 4 +- src/ripple/http/impl/ServerImpl.h | 18 +- src/ripple/http/impl/Types.h | 6 +- src/ripple/json/impl/Tests.cpp | 5 +- src/ripple/json/impl/json_writer.cpp | 6 +- src/ripple/peerfinder/api/Config.h | 4 +- src/ripple/peerfinder/api/Endpoint.h | 8 +- src/ripple/peerfinder/api/Manager.h | 18 +- src/ripple/peerfinder/api/Slot.h | 4 +- src/ripple/peerfinder/api/Types.h | 2 +- src/ripple/peerfinder/impl/Bootcache.cpp | 30 +- src/ripple/peerfinder/impl/Bootcache.h | 18 +- src/ripple/peerfinder/impl/Checker.cpp | 34 +-- src/ripple/peerfinder/impl/Checker.h | 6 +- src/ripple/peerfinder/impl/CheckerAdapter.h | 20 +- src/ripple/peerfinder/impl/Config.cpp | 2 +- .../peerfinder/impl/ConnectHandouts.cpp | 4 +- src/ripple/peerfinder/impl/ConnectHandouts.h | 6 +- src/ripple/peerfinder/impl/Counts.h | 2 +- src/ripple/peerfinder/impl/Endpoint.cpp | 2 +- src/ripple/peerfinder/impl/Livecache.cpp | 12 +- src/ripple/peerfinder/impl/Livecache.h | 42 +-- src/ripple/peerfinder/impl/Logic.h | 144 +++++----- src/ripple/peerfinder/impl/Manager.cpp | 56 ++-- src/ripple/peerfinder/impl/Reporting.h | 10 +- src/ripple/peerfinder/impl/SlotImp.cpp | 10 +- src/ripple/peerfinder/impl/SlotImp.h | 24 +- src/ripple/peerfinder/impl/Source.h | 6 +- src/ripple/peerfinder/impl/SourceStrings.cpp | 9 +- src/ripple/peerfinder/impl/SourceStrings.h | 2 +- src/ripple/peerfinder/impl/Store.h | 4 +- src/ripple/peerfinder/impl/StoreSqdb.h | 70 ++--- src/ripple/peerfinder/ripple_peerfinder.cpp | 4 - src/ripple/peerfinder/ripple_peerfinder.h | 4 - src/ripple/peerfinder/sim/Predicates.h | 4 +- src/ripple/peerfinder/sim/WrappedSink.h | 15 +- src/ripple/resource/api/Gossip.h | 2 +- src/ripple/resource/api/Manager.h | 10 +- src/ripple/resource/impl/Entry.h | 4 +- src/ripple/resource/impl/Key.h | 4 +- src/ripple/resource/impl/Logic.h | 60 ++-- src/ripple/resource/impl/Manager.cpp | 20 +- src/ripple/resource/impl/Tests.cpp | 40 +-- src/ripple/resource/ripple_resource.h | 4 - src/ripple/sitefiles/api/Manager.h | 6 +- src/ripple/sitefiles/impl/Logic.h | 18 +- src/ripple/sitefiles/impl/Manager.cpp | 24 +- src/ripple/sitefiles/ripple_sitefiles.h | 4 - src/ripple/sslutil/api/CAutoBN_CTX.h | 2 +- src/ripple/sslutil/api/CBigNum.h | 18 +- src/ripple/sslutil/impl/CBigNum.cpp | 46 +-- src/ripple/sslutil/impl/ECDSACanonical.cpp | 2 +- src/ripple/sslutil/ripple_sslutil.h | 4 - src/ripple/testoverlay/api/ConfigType.h | 2 +- src/ripple/testoverlay/api/PeerType.h | 2 +- src/ripple/testoverlay/api/Results.h | 3 +- src/ripple/testoverlay/api/SimplePayload.h | 6 +- src/ripple/testoverlay/api/StateBase.h | 6 +- src/ripple/testoverlay/impl/TestOverlay.cpp | 7 +- src/ripple/testoverlay/ripple_testoverlay.h | 2 - src/ripple/types/api/CryptoIdentifier.h | 18 +- src/ripple/types/api/HashMaps.h | 2 +- src/ripple/types/api/IdentifierStorage.h | 10 +- src/ripple/types/api/IdentifierType.h | 2 +- src/ripple/types/api/RandomNumbers.h | 4 +- src/ripple/types/api/RippleAccountID.h | 2 +- src/ripple/types/api/SimpleIdentifier.h | 2 +- src/ripple/types/api/UInt160.h | 10 +- src/ripple/types/api/UInt256.h | 12 +- src/ripple/types/api/base_uint.h | 15 +- src/ripple/types/impl/Base58.cpp | 2 +- src/ripple/types/impl/RandomNumbers.cpp | 26 +- src/ripple/types/impl/RippleAssets.cpp | 2 +- src/ripple/types/ripple_types.h | 4 - src/ripple/validators/api/Manager.h | 18 +- src/ripple/validators/api/Source.h | 14 +- src/ripple/validators/impl/ChosenList.h | 4 +- src/ripple/validators/impl/Count.h | 2 +- src/ripple/validators/impl/Logic.h | 24 +- src/ripple/validators/impl/Manager.cpp | 72 ++--- src/ripple/validators/impl/SourceDesc.h | 10 +- src/ripple/validators/impl/SourceFile.cpp | 26 +- src/ripple/validators/impl/SourceFile.h | 2 +- src/ripple/validators/impl/SourceStrings.cpp | 23 +- src/ripple/validators/impl/SourceStrings.h | 2 +- src/ripple/validators/impl/SourceURL.cpp | 14 +- src/ripple/validators/impl/SourceURL.h | 2 +- src/ripple/validators/impl/StoreSqdb.cpp | 108 ++++---- src/ripple/validators/impl/StoreSqdb.h | 16 +- src/ripple/validators/impl/Tests.cpp | 39 +-- src/ripple/validators/impl/Utilities.cpp | 23 +- src/ripple/validators/impl/Utilities.h | 17 +- src/ripple/validators/ripple_validators.cpp | 4 - src/ripple_app/consensus/LedgerConsensus.cpp | 44 +-- src/ripple_app/consensus/LedgerConsensus.h | 4 +- src/ripple_app/contracts/Contract.h | 4 +- src/ripple_app/contracts/Interpreter.cpp | 4 +- src/ripple_app/data/Database.cpp | 6 +- src/ripple_app/data/Database.h | 10 +- src/ripple_app/data/DatabaseCon.h | 2 +- src/ripple_app/data/SqliteDatabase.cpp | 46 +-- src/ripple_app/data/SqliteDatabase.h | 14 +- src/ripple_app/ledger/AcceptedLedgerTx.cpp | 2 +- src/ripple_app/ledger/AcceptedLedgerTx.h | 2 +- src/ripple_app/ledger/InboundLedger.cpp | 6 +- src/ripple_app/ledger/InboundLedger.h | 6 +- src/ripple_app/ledger/InboundLedgers.cpp | 16 +- src/ripple_app/ledger/InboundLedgers.h | 8 +- src/ripple_app/ledger/Ledger.cpp | 117 ++++---- src/ripple_app/ledger/Ledger.h | 104 +++---- src/ripple_app/ledger/LedgerCleaner.cpp | 16 +- src/ripple_app/ledger/LedgerCleaner.h | 6 +- src/ripple_app/ledger/LedgerEntrySet.cpp | 74 ++--- src/ripple_app/ledger/LedgerEntrySet.h | 23 +- src/ripple_app/ledger/LedgerHistory.cpp | 10 +- src/ripple_app/ledger/LedgerHistory.h | 2 +- src/ripple_app/ledger/LedgerMaster.cpp | 108 ++++---- src/ripple_app/ledger/LedgerMaster.h | 41 +-- src/ripple_app/ledger/LedgerProposal.cpp | 15 +- src/ripple_app/ledger/LedgerProposal.h | 22 +- src/ripple_app/ledger/OrderBookDB.cpp | 4 +- src/ripple_app/ledger/OrderBookDB.h | 10 +- src/ripple_app/ledger/OrderBookIterator.cpp | 4 +- src/ripple_app/ledger/OrderBookIterator.h | 6 +- .../ledger/SerializedValidation.cpp | 6 +- src/ripple_app/ledger/SerializedValidation.h | 9 +- src/ripple_app/main/Application.cpp | 46 +-- src/ripple_app/main/Application.h | 2 +- src/ripple_app/main/CollectorManager.cpp | 26 +- src/ripple_app/main/CollectorManager.h | 8 +- src/ripple_app/main/FatalErrorReporter.cpp | 12 +- src/ripple_app/main/FatalErrorReporter.h | 6 +- src/ripple_app/main/IoServicePool.cpp | 7 +- src/ripple_app/main/IoServicePool.h | 10 +- src/ripple_app/main/LoadManager.cpp | 8 +- src/ripple_app/main/LoadManager.h | 4 +- src/ripple_app/main/LocalCredentials.h | 2 +- src/ripple_app/main/NodeStoreScheduler.h | 2 +- src/ripple_app/main/ParameterTable.cpp | 2 +- src/ripple_app/main/RPCHTTPServer.cpp | 16 +- src/ripple_app/main/RPCHTTPServer.h | 7 +- src/ripple_app/main/RippleMain.cpp | 38 +-- src/ripple_app/main/RippleMain.h | 2 +- src/ripple_app/misc/AccountItems.cpp | 2 +- src/ripple_app/misc/AccountItems.h | 2 +- src/ripple_app/misc/AccountState.h | 4 +- src/ripple_app/misc/CanonicalTXSet.h | 6 +- src/ripple_app/misc/Features.cpp | 24 +- src/ripple_app/misc/FeeVote.cpp | 27 +- src/ripple_app/misc/IFeatures.h | 12 +- src/ripple_app/misc/IFeeVote.h | 6 +- src/ripple_app/misc/IHashRouter.h | 2 +- src/ripple_app/misc/NetworkOPs.cpp | 262 ++++++++++-------- src/ripple_app/misc/NetworkOPs.h | 71 ++--- src/ripple_app/misc/OrderBook.h | 2 +- src/ripple_app/misc/ProofOfWork.cpp | 6 +- src/ripple_app/misc/ProofOfWork.h | 6 +- src/ripple_app/misc/ProofOfWorkFactory.cpp | 30 +- src/ripple_app/misc/ProofOfWorkFactory.h | 2 +- src/ripple_app/misc/SerializedLedger.cpp | 15 +- src/ripple_app/misc/SerializedLedger.h | 7 +- src/ripple_app/misc/SerializedTransaction.cpp | 15 +- src/ripple_app/misc/SerializedTransaction.h | 14 +- src/ripple_app/misc/Validations.cpp | 14 +- src/ripple_app/misc/Validations.h | 4 +- src/ripple_app/node/SqliteFactory.cpp | 8 +- src/ripple_app/paths/PathRequest.cpp | 4 +- src/ripple_app/paths/PathRequest.h | 4 +- src/ripple_app/paths/PathRequests.cpp | 4 +- src/ripple_app/paths/PathRequests.h | 14 +- src/ripple_app/paths/PathState.h | 4 +- src/ripple_app/paths/Pathfinder.cpp | 6 +- src/ripple_app/paths/Pathfinder.h | 10 +- src/ripple_app/paths/RippleCalc.cpp | 24 +- src/ripple_app/paths/RippleCalc.h | 4 +- src/ripple_app/paths/RippleState.h | 18 +- src/ripple_app/peers/ClusterNodeStatus.h | 10 +- src/ripple_app/peers/PeerSet.cpp | 2 +- src/ripple_app/peers/PeerSet.h | 8 +- src/ripple_app/peers/UniqueNodeList.cpp | 14 +- src/ripple_app/peers/UniqueNodeList.h | 4 +- src/ripple_app/rpc/RPCHandler.cpp | 60 ++-- src/ripple_app/rpc/RPCServerHandler.cpp | 3 +- src/ripple_app/rpc/RPCServerHandler.h | 3 +- src/ripple_app/shamap/FetchPackTests.cpp | 10 +- src/ripple_app/shamap/RadixMapTest.cpp | 4 +- src/ripple_app/shamap/RadixMapTest.h | 4 +- src/ripple_app/shamap/SHAMap.cpp | 38 +-- src/ripple_app/shamap/SHAMap.h | 19 +- src/ripple_app/shamap/SHAMapAddNode.h | 6 +- src/ripple_app/shamap/SHAMapNode.cpp | 2 +- src/ripple_app/shamap/SHAMapSync.cpp | 16 +- src/ripple_app/shamap/SHAMapSyncFilters.cpp | 4 +- src/ripple_app/shamap/SHAMapSyncFilters.h | 8 +- src/ripple_app/shamap/SHAMapTreeNode.cpp | 19 +- src/ripple_app/shamap/SHAMapTreeNode.h | 17 +- .../transactors/AccountSetTransactor.cpp | 12 +- .../transactors/OfferCancelTransactor.cpp | 6 +- .../transactors/OfferCreateTransactor.cpp | 20 +- .../transactors/PaymentTransactor.cpp | 6 +- .../transactors/RegularKeySetTransactor.cpp | 4 +- .../transactors/RegularKeySetTransactor.h | 7 +- src/ripple_app/transactors/Transactor.cpp | 8 +- src/ripple_app/transactors/Transactor.h | 6 +- .../transactors/TrustSetTransactor.cpp | 22 +- .../transactors/WalletAddTransactor.cpp | 6 +- src/ripple_app/tx/Transaction.cpp | 12 +- src/ripple_app/tx/Transaction.h | 20 +- src/ripple_app/tx/TransactionAcquire.cpp | 2 +- src/ripple_app/tx/TransactionEngine.cpp | 6 +- src/ripple_app/tx/TransactionMaster.cpp | 7 +- src/ripple_app/tx/TransactionMaster.h | 6 +- src/ripple_app/tx/TransactionMeta.cpp | 13 +- src/ripple_app/tx/TransactionMeta.h | 44 +-- src/ripple_app/tx/TxQueue.cpp | 2 +- src/ripple_app/tx/TxQueue.h | 2 +- src/ripple_app/websocket/WSConnection.cpp | 2 +- src/ripple_app/websocket/WSConnection.h | 6 +- src/ripple_app/websocket/WSDoor.cpp | 7 +- src/ripple_app/websocket/WSDoor.h | 2 +- src/ripple_app/websocket/WSServerHandler.h | 4 +- src/ripple_basics/containers/RangeSet.cpp | 36 +-- src/ripple_basics/containers/RangeSet.h | 24 +- src/ripple_basics/log/Log.h | 2 +- src/ripple_basics/log/LogFile.cpp | 2 +- src/ripple_basics/log/LogFile.h | 4 +- src/ripple_basics/log/LogPartition.cpp | 10 +- src/ripple_basics/log/LogPartition.h | 14 +- src/ripple_basics/log/LogSink.cpp | 6 +- src/ripple_basics/log/LogSink.h | 2 +- src/ripple_basics/log/LoggedTimings.h | 20 +- src/ripple_basics/ripple_basics.h | 2 - src/ripple_basics/types/BasicTypes.h | 8 +- src/ripple_basics/utility/CountedObject.h | 4 +- src/ripple_basics/utility/IniFile.cpp | 11 +- src/ripple_basics/utility/IniFile.h | 3 +- src/ripple_basics/utility/StringUtilities.cpp | 29 +- src/ripple_basics/utility/StringUtilities.h | 7 +- src/ripple_basics/utility/UptimeTimer.cpp | 2 +- src/ripple_core/functional/Config.cpp | 124 ++++----- src/ripple_core/functional/Config.h | 56 ++-- src/ripple_core/functional/ConfigSections.h | 6 +- src/ripple_core/functional/Job.cpp | 4 +- src/ripple_core/functional/Job.h | 6 +- src/ripple_core/functional/JobQueue.cpp | 36 +-- src/ripple_core/functional/JobQueue.h | 6 +- src/ripple_core/functional/JobTypeData.h | 8 +- src/ripple_core/functional/JobTypeInfo.h | 10 +- src/ripple_core/functional/JobTypes.h | 2 +- src/ripple_core/functional/LoadEvent.cpp | 6 +- src/ripple_core/functional/LoadEvent.h | 4 +- src/ripple_core/functional/LoadFeeTrack.h | 25 +- .../functional/LoadFeeTrackImp.cpp | 4 +- src/ripple_core/functional/LoadFeeTrackImp.h | 44 +-- src/ripple_core/functional/LoadMonitor.cpp | 6 +- src/ripple_core/functional/LoadMonitor.h | 24 +- src/ripple_core/nodestore/api/Database.h | 4 +- src/ripple_core/nodestore/api/Factory.h | 4 +- src/ripple_core/nodestore/api/Manager.h | 4 +- src/ripple_core/nodestore/api/NodeObject.h | 2 +- src/ripple_core/nodestore/api/Types.h | 2 +- .../nodestore/backend/HyperDBFactory.cpp | 14 +- .../nodestore/backend/LevelDBFactory.cpp | 16 +- .../nodestore/backend/MemoryFactory.cpp | 8 +- .../nodestore/backend/NullFactory.cpp | 4 +- .../nodestore/backend/RocksDBFactory.cpp | 16 +- src/ripple_core/nodestore/impl/DatabaseImp.h | 14 +- .../nodestore/impl/DecodedBlob.cpp | 4 +- .../nodestore/impl/EncodedBlob.cpp | 8 +- src/ripple_core/nodestore/impl/EncodedBlob.h | 2 +- src/ripple_core/nodestore/impl/Manager.cpp | 4 +- .../nodestore/tests/BackendTests.cpp | 13 +- .../nodestore/tests/BasicTests.cpp | 6 +- .../nodestore/tests/DatabaseTests.cpp | 42 +-- src/ripple_core/nodestore/tests/TestBase.h | 15 +- .../nodestore/tests/TimingTests.cpp | 24 +- src/ripple_data/crypto/CKey.cpp | 2 +- src/ripple_data/crypto/CKey.h | 14 +- src/ripple_data/crypto/CKeyDeterministic.cpp | 62 ++--- src/ripple_data/crypto/CKeyECIES.cpp | 8 +- src/ripple_data/crypto/RFC1751.cpp | 6 +- src/ripple_data/crypto/RFC1751.h | 2 +- src/ripple_data/protocol/BuildInfo.cpp | 20 +- src/ripple_data/protocol/BuildInfo.h | 4 +- src/ripple_data/protocol/FieldNames.cpp | 7 +- src/ripple_data/protocol/HashPrefix.h | 4 +- src/ripple_data/protocol/KnownFormats.h | 2 +- src/ripple_data/protocol/LedgerFormats.cpp | 2 +- src/ripple_data/protocol/Protocol.h | 6 +- src/ripple_data/protocol/RippleAddress.cpp | 8 +- src/ripple_data/protocol/STAmount.cpp | 148 +++++----- src/ripple_data/protocol/STAmountRound.cpp | 34 +-- src/ripple_data/protocol/STParsedJSON.cpp | 22 +- src/ripple_data/protocol/SerializedObject.cpp | 46 +-- src/ripple_data/protocol/SerializedObject.h | 32 +-- .../protocol/SerializedObjectTemplate.h | 2 +- src/ripple_data/protocol/SerializedTypes.cpp | 10 +- src/ripple_data/protocol/SerializedTypes.h | 127 ++++----- src/ripple_data/protocol/Serializer.cpp | 30 +- src/ripple_data/protocol/Serializer.h | 26 +- src/ripple_data/protocol/TxFlags.h | 62 ++--- src/ripple_data/ripple_data.cpp | 8 +- src/ripple_net/basics/HTTPClient.cpp | 12 +- src/ripple_net/basics/HTTPRequest.cpp | 2 +- src/ripple_net/basics/RPCDoor.cpp | 6 +- src/ripple_net/basics/RPCServer.h | 3 +- src/ripple_net/basics/SNTPClient.cpp | 24 +- src/ripple_net/basics/SNTPClient.h | 6 +- src/ripple_net/basics/impl/RPCServerImp.h | 2 +- src/ripple_net/rpc/InfoSub.cpp | 6 +- src/ripple_net/rpc/InfoSub.h | 24 +- src/ripple_net/rpc/RPCCall.cpp | 18 +- src/ripple_net/rpc/RPCSub.cpp | 2 +- src/ripple_net/rpc/RPCUtil.cpp | 2 +- src/ripple_overlay/api/Peer.h | 12 +- src/ripple_overlay/api/Peers.h | 10 +- src/ripple_overlay/impl/PeerDoor.cpp | 6 +- src/ripple_overlay/impl/PeerDoor.h | 2 +- src/ripple_overlay/impl/PeerImp.h | 60 ++-- src/ripple_overlay/impl/Peers.cpp | 30 +- src/ripple_overlay/ripple_overlay.h | 4 - src/ripple_rpc/api/Manager.h | 2 +- src/ripple_rpc/api/Request.h | 4 +- src/ripple_rpc/impl/Manager.cpp | 6 +- .../autosocket/LogWebsockets.cpp | 4 +- 519 files changed, 3618 insertions(+), 2726 deletions(-) diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj index af832708e9..14239607f8 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj +++ b/Builds/VisualStudio2013/RippleD.vcxproj @@ -702,6 +702,12 @@ true true + + true + true + true + true + true true diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters index 912dd38f20..832e6db7c0 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters @@ -1494,6 +1494,9 @@ [1] Ripple\common\impl + + [1] Ripple\sslutil\impl + diff --git a/src/beast/beast/cxx14/algorithm.h b/src/beast/beast/cxx14/algorithm.h index c72a631bc2..f10bd7bb99 100644 --- a/src/beast/beast/cxx14/algorithm.h +++ b/src/beast/beast/cxx14/algorithm.h @@ -25,6 +25,8 @@ #include +#if ! BEAST_NO_CXX14_EQUAL + namespace std { namespace detail { @@ -88,3 +90,5 @@ bool equal (FwdIt1 first1, FwdIt1 last1, } #endif + +#endif diff --git a/src/beast/beast/cxx14/config.h b/src/beast/beast/cxx14/config.h index 841e9052c0..cf0541c3bd 100644 --- a/src/beast/beast/cxx14/config.h +++ b/src/beast/beast/cxx14/config.h @@ -23,22 +23,32 @@ // Sets C++14 compatibility configuration macros based on build environment // Disables beast c++14 compatibility additions when set to 1 +// Note, some compatibilty features are enabled or disabled individually. // #ifndef BEAST_NO_CXX14_COMPATIBILITY # ifdef _MSC_VER # define BEAST_NO_CXX14_COMPATIBILITY 1 +# elif defined(__clang__) && defined(_LIBCPP_VERSION) && __cplusplus >= 201305 +# define BEAST_NO_CXX14_COMPATIBILITY 1 # else # define BEAST_NO_CXX14_COMPATIBILITY 0 # endif #endif -// Disables beast's make_unique +// Disables beast's std::make_unique #ifndef BEAST_NO_CXX14_MAKE_UNIQUE # ifdef _MSC_VER # define BEAST_NO_CXX14_MAKE_UNIQUE 1 +# elif defined(__clang__) && defined(_LIBCPP_VERSION) && __cplusplus >= 201305 +# define BEAST_NO_CXX14_MAKE_UNIQUE 1 # else # define BEAST_NO_CXX14_MAKE_UNIQUE 0 # endif #endif +// Disables beast's std::equal safe iterator overloads +#ifndef BEAST_NO_CXX14_EQUAL +# define BEAST_NO_CXX14_EQUAL 0 +#endif + #endif diff --git a/src/beast/modules/beast_asio/async/AsyncObject.h b/src/beast/modules/beast_asio/async/AsyncObject.h index ef4ef17583..cc36049b73 100644 --- a/src/beast/modules/beast_asio/async/AsyncObject.h +++ b/src/beast/modules/beast_asio/async/AsyncObject.h @@ -80,7 +80,7 @@ public: private: // The number of handlers pending. - Atomic m_pending; + beast::Atomic m_pending; }; } diff --git a/src/beast/modules/beast_core/beast_core.cpp b/src/beast/modules/beast_core/beast_core.cpp index 37a36b7381..d250fbd476 100644 --- a/src/beast/modules/beast_core/beast_core.cpp +++ b/src/beast/modules/beast_core/beast_core.cpp @@ -126,9 +126,6 @@ #undef _aligned_msize #endif -namespace beast -{ - #include "containers/DynamicObject.cpp" #include "containers/NamedValueSet.cpp" #include "containers/PropertySet.cpp" @@ -256,8 +253,6 @@ namespace beast #include "threads/HighResolutionTimer.cpp" -} - // Has to be outside the beast namespace extern "C" { void beast_reportFatalError (char const* message, char const* fileName, int lineNumber) diff --git a/src/beast/modules/beast_core/beast_core.h b/src/beast/modules/beast_core/beast_core.h index a5d6ab17c7..d02ec74577 100644 --- a/src/beast/modules/beast_core/beast_core.h +++ b/src/beast/modules/beast_core/beast_core.h @@ -63,13 +63,16 @@ #include "system/StandardIncludes.h" -namespace beast { +namespace beast +{ class InputStream; class OutputStream; class FileInputStream; class FileOutputStream; +} // namespace beast + // Order matters, since headers don't have their own #include lines. // Add new includes to the bottom. @@ -209,8 +212,6 @@ class FileOutputStream; #include "thread/Workers.h" -} - #if BEAST_MSVC #pragma warning (pop) #endif diff --git a/src/beast/modules/beast_core/containers/Array.h b/src/beast/modules/beast_core/containers/Array.h index 97eac103f2..d516cbfd2d 100644 --- a/src/beast/modules/beast_core/containers/Array.h +++ b/src/beast/modules/beast_core/containers/Array.h @@ -24,6 +24,9 @@ #ifndef BEAST_ARRAY_H_INCLUDED #define BEAST_ARRAY_H_INCLUDED +namespace beast +{ + //============================================================================== /** Holds a resizable array of primitive or copy-by-value objects. @@ -1052,4 +1055,6 @@ private: } }; +} // namespace beast + #endif // BEAST_ARRAY_H_INCLUDED diff --git a/src/beast/modules/beast_core/containers/ArrayAllocationBase.h b/src/beast/modules/beast_core/containers/ArrayAllocationBase.h index 6887392cd6..43f0920115 100644 --- a/src/beast/modules/beast_core/containers/ArrayAllocationBase.h +++ b/src/beast/modules/beast_core/containers/ArrayAllocationBase.h @@ -24,6 +24,9 @@ #ifndef BEAST_ARRAYALLOCATIONBASE_H_INCLUDED #define BEAST_ARRAYALLOCATIONBASE_H_INCLUDED +namespace beast +{ + //============================================================================== /** Implements some basic array storage allocation functions. @@ -126,4 +129,6 @@ public: int numAllocated; }; +} // namespace beast + #endif // BEAST_ARRAYALLOCATIONBASE_H_INCLUDED diff --git a/src/beast/modules/beast_core/containers/DynamicObject.cpp b/src/beast/modules/beast_core/containers/DynamicObject.cpp index 0a5e15462d..edf8a58880 100644 --- a/src/beast/modules/beast_core/containers/DynamicObject.cpp +++ b/src/beast/modules/beast_core/containers/DynamicObject.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + DynamicObject::DynamicObject() { } @@ -72,3 +75,5 @@ void DynamicObject::clear() { properties.clear(); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/containers/DynamicObject.h b/src/beast/modules/beast_core/containers/DynamicObject.h index 56e4cf7b65..c3a8556dd3 100644 --- a/src/beast/modules/beast_core/containers/DynamicObject.h +++ b/src/beast/modules/beast_core/containers/DynamicObject.h @@ -24,6 +24,9 @@ #ifndef BEAST_DYNAMICOBJECT_H_INCLUDED #define BEAST_DYNAMICOBJECT_H_INCLUDED +namespace beast +{ + //============================================================================== /** Represents a dynamically implemented object. @@ -112,6 +115,6 @@ private: NamedValueSet properties; }; - +} // namespace beast #endif // BEAST_DYNAMICOBJECT_H_INCLUDED diff --git a/src/beast/modules/beast_core/containers/ElementComparator.h b/src/beast/modules/beast_core/containers/ElementComparator.h index 438628ed9e..929e71ca71 100644 --- a/src/beast/modules/beast_core/containers/ElementComparator.h +++ b/src/beast/modules/beast_core/containers/ElementComparator.h @@ -24,6 +24,9 @@ #ifndef BEAST_ELEMENTCOMPARATOR_H_INCLUDED #define BEAST_ELEMENTCOMPARATOR_H_INCLUDED +namespace beast +{ + #ifndef DOXYGEN /** This is an internal helper class which converts a beast ElementComparator style @@ -185,5 +188,7 @@ public: } }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/containers/LinkedListPointer.h b/src/beast/modules/beast_core/containers/LinkedListPointer.h index b55f2e9939..4ab1aca684 100644 --- a/src/beast/modules/beast_core/containers/LinkedListPointer.h +++ b/src/beast/modules/beast_core/containers/LinkedListPointer.h @@ -24,6 +24,8 @@ #ifndef BEAST_LINKEDLISTPOINTER_H_INCLUDED #define BEAST_LINKEDLISTPOINTER_H_INCLUDED +namespace beast +{ //============================================================================== /** @@ -358,5 +360,6 @@ private: ObjectType* item; }; +} // namespace beast #endif // BEAST_LINKEDLISTPOINTER_H_INCLUDED diff --git a/src/beast/modules/beast_core/containers/NamedValueSet.cpp b/src/beast/modules/beast_core/containers/NamedValueSet.cpp index e092865eb4..7bdc0816f9 100644 --- a/src/beast/modules/beast_core/containers/NamedValueSet.cpp +++ b/src/beast/modules/beast_core/containers/NamedValueSet.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + NamedValueSet::NamedValue::NamedValue() noexcept { } @@ -302,3 +305,5 @@ void NamedValueSet::copyToXmlAttributes (XmlElement& xml) const } } } + +} // namespace beast diff --git a/src/beast/modules/beast_core/containers/NamedValueSet.h b/src/beast/modules/beast_core/containers/NamedValueSet.h index 24e4bcc65e..58c7183c2f 100644 --- a/src/beast/modules/beast_core/containers/NamedValueSet.h +++ b/src/beast/modules/beast_core/containers/NamedValueSet.h @@ -24,6 +24,9 @@ #ifndef BEAST_NAMEDVALUESET_H_INCLUDED #define BEAST_NAMEDVALUESET_H_INCLUDED +namespace beast +{ + class XmlElement; #ifndef DOXYGEN class JSONFormatter; @@ -157,5 +160,6 @@ private: friend class JSONFormatter; }; +} // namespace beast #endif // BEAST_NAMEDVALUESET_H_INCLUDED diff --git a/src/beast/modules/beast_core/containers/OwnedArray.h b/src/beast/modules/beast_core/containers/OwnedArray.h index 52b31cbb88..b971690dae 100644 --- a/src/beast/modules/beast_core/containers/OwnedArray.h +++ b/src/beast/modules/beast_core/containers/OwnedArray.h @@ -24,6 +24,9 @@ #ifndef BEAST_OWNEDARRAY_H_INCLUDED #define BEAST_OWNEDARRAY_H_INCLUDED +namespace beast +{ + //============================================================================== /** An array designed for holding objects. @@ -885,5 +888,6 @@ private: } }; +} // namespace beast #endif diff --git a/src/beast/modules/beast_core/containers/PropertySet.cpp b/src/beast/modules/beast_core/containers/PropertySet.cpp index c87e5cfb1f..2ee1a12160 100644 --- a/src/beast/modules/beast_core/containers/PropertySet.cpp +++ b/src/beast/modules/beast_core/containers/PropertySet.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + PropertySet::PropertySet (const bool ignoreCaseOfKeyNames) : properties (ignoreCaseOfKeyNames), fallbackProperties (nullptr), @@ -216,3 +219,5 @@ void PropertySet::restoreFromXml (const XmlElement& xml) void PropertySet::propertyChanged() { } + +} // namespace beast diff --git a/src/beast/modules/beast_core/containers/PropertySet.h b/src/beast/modules/beast_core/containers/PropertySet.h index 40d84f992d..1e003fec95 100644 --- a/src/beast/modules/beast_core/containers/PropertySet.h +++ b/src/beast/modules/beast_core/containers/PropertySet.h @@ -24,6 +24,9 @@ #ifndef BEAST_PROPERTYSET_H_INCLUDED #define BEAST_PROPERTYSET_H_INCLUDED +namespace beast +{ + //============================================================================== /** A set of named property values, which can be strings, integers, floating point, etc. @@ -203,5 +206,6 @@ private: bool ignoreCaseOfKeys; }; +} // namespace beast #endif // BEAST_PROPERTYSET_H_INCLUDED diff --git a/src/beast/modules/beast_core/containers/ScopedValueSetter.h b/src/beast/modules/beast_core/containers/ScopedValueSetter.h index ff10da1315..3859b74921 100644 --- a/src/beast/modules/beast_core/containers/ScopedValueSetter.h +++ b/src/beast/modules/beast_core/containers/ScopedValueSetter.h @@ -24,6 +24,8 @@ #ifndef BEAST_SCOPEDVALUESETTER_H_INCLUDED #define BEAST_SCOPEDVALUESETTER_H_INCLUDED +namespace beast +{ //============================================================================== /** @@ -89,5 +91,6 @@ private: const ValueType originalValue; }; +} // namespace beast #endif // BEAST_SCOPEDVALUESETTER_H_INCLUDED diff --git a/src/beast/modules/beast_core/containers/SparseSet.h b/src/beast/modules/beast_core/containers/SparseSet.h index 807a75038e..ebe49b33a5 100644 --- a/src/beast/modules/beast_core/containers/SparseSet.h +++ b/src/beast/modules/beast_core/containers/SparseSet.h @@ -24,6 +24,9 @@ #ifndef BEAST_SPARSESET_H_INCLUDED #define BEAST_SPARSESET_H_INCLUDED +namespace beast +{ + //============================================================================== /** Holds a set of primitive values, storing them as a set of ranges. @@ -287,6 +290,6 @@ private: } }; - +} // namespace beast #endif // BEAST_SPARSESET_H_INCLUDED diff --git a/src/beast/modules/beast_core/containers/Variant.cpp b/src/beast/modules/beast_core/containers/Variant.cpp index 943064a7c4..bb923ce4f5 100644 --- a/src/beast/modules/beast_core/containers/Variant.cpp +++ b/src/beast/modules/beast_core/containers/Variant.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + enum VariantStreamMarkers { varMarker_Int = 1, @@ -702,3 +705,5 @@ var var::readFromStream (InputStream& input) return var::null; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/containers/Variant.h b/src/beast/modules/beast_core/containers/Variant.h index 927979080e..3ddc1c5dca 100644 --- a/src/beast/modules/beast_core/containers/Variant.h +++ b/src/beast/modules/beast_core/containers/Variant.h @@ -24,6 +24,9 @@ #ifndef BEAST_VARIANT_H_INCLUDED #define BEAST_VARIANT_H_INCLUDED +namespace beast +{ + #ifndef DOXYGEN class SharedObject; class DynamicObject; @@ -293,5 +296,6 @@ bool operator!= (const var& v1, const String& v2); bool operator== (const var& v1, const char* v2); bool operator!= (const var& v1, const char* v2); +} // namespace beast #endif // BEAST_VARIANT_H_INCLUDED diff --git a/src/beast/modules/beast_core/diagnostic/FPUFlags.cpp b/src/beast/modules/beast_core/diagnostic/FPUFlags.cpp index 39eb589cfc..5ba2acb25e 100644 --- a/src/beast/modules/beast_core/diagnostic/FPUFlags.cpp +++ b/src/beast/modules/beast_core/diagnostic/FPUFlags.cpp @@ -17,6 +17,9 @@ */ //============================================================================== +namespace beast +{ + void FPUFlags::clearUnsetFlagsFrom (FPUFlags const& flags) { if (!flags.getMaskNaNs ().is_set ()) m_maskNaNs.clear (); @@ -38,3 +41,5 @@ void FPUFlags::clearUnsetFlagsFrom (FPUFlags const& flags) if (!flags.getPrecision ().is_set ()) m_precision.clear (); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/diagnostic/FPUFlags.h b/src/beast/modules/beast_core/diagnostic/FPUFlags.h index 73c17e56f0..9b4f2c4362 100644 --- a/src/beast/modules/beast_core/diagnostic/FPUFlags.h +++ b/src/beast/modules/beast_core/diagnostic/FPUFlags.h @@ -20,6 +20,9 @@ #ifndef BEAST_FPUFLAGS_H_INCLUDED #define BEAST_FPUFLAGS_H_INCLUDED +namespace beast +{ + /*============================================================================*/ /** A set of IEEE FPU flags. @@ -331,5 +334,7 @@ private: FPUFlags m_savedFlags; }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/diagnostic/FatalError.cpp b/src/beast/modules/beast_core/diagnostic/FatalError.cpp index dc23017385..295c44ceb3 100644 --- a/src/beast/modules/beast_core/diagnostic/FatalError.cpp +++ b/src/beast/modules/beast_core/diagnostic/FatalError.cpp @@ -17,6 +17,9 @@ */ //============================================================================== +namespace beast +{ + // // FatalError::Reporter // @@ -130,3 +133,5 @@ public: }; static FatalErrorTests fatalErrorTests; + +} // namespace beast diff --git a/src/beast/modules/beast_core/diagnostic/FatalError.h b/src/beast/modules/beast_core/diagnostic/FatalError.h index 861575b314..5aa949d5b8 100644 --- a/src/beast/modules/beast_core/diagnostic/FatalError.h +++ b/src/beast/modules/beast_core/diagnostic/FatalError.h @@ -20,6 +20,9 @@ #ifndef BEAST_CORE_FATALERROR_H_INCLUDED #define BEAST_CORE_FATALERROR_H_INCLUDED +namespace beast +{ + /** Signal a fatal error. A fatal error indicates that the program has encountered an unexpected @@ -146,4 +149,6 @@ private: static Reporter* s_reporter; }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/diagnostic/MeasureFunctionCallTime.h b/src/beast/modules/beast_core/diagnostic/MeasureFunctionCallTime.h index 99efe3412b..41a05dbed9 100644 --- a/src/beast/modules/beast_core/diagnostic/MeasureFunctionCallTime.h +++ b/src/beast/modules/beast_core/diagnostic/MeasureFunctionCallTime.h @@ -20,6 +20,9 @@ #ifndef BEAST_CORE_DIAGNOSTIC_MEASUREFUNCTIONCALLTIME_H_INCLUDED #define BEAST_CORE_DIAGNOSTIC_MEASUREFUNCTIONCALLTIME_H_INCLUDED +namespace beast +{ + /** Measures the speed of invoking a function. */ /** @{ */ template @@ -77,4 +80,6 @@ double measureFunctionCallTime (Function f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P } #endif +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/diagnostic/SemanticVersion.cpp b/src/beast/modules/beast_core/diagnostic/SemanticVersion.cpp index a8b4427424..56ffd366d7 100644 --- a/src/beast/modules/beast_core/diagnostic/SemanticVersion.cpp +++ b/src/beast/modules/beast_core/diagnostic/SemanticVersion.cpp @@ -17,6 +17,9 @@ */ //============================================================================== +namespace beast +{ + SemanticVersion::SemanticVersion () : majorVersion (0) , minorVersion (0) @@ -517,3 +520,5 @@ public: }; static SemanticVersionTests semanticVersionTests; + +} // namespace beast diff --git a/src/beast/modules/beast_core/diagnostic/SemanticVersion.h b/src/beast/modules/beast_core/diagnostic/SemanticVersion.h index e24d46f666..691f9ff5d0 100644 --- a/src/beast/modules/beast_core/diagnostic/SemanticVersion.h +++ b/src/beast/modules/beast_core/diagnostic/SemanticVersion.h @@ -20,6 +20,9 @@ #ifndef BEAST_SEMANTICVERSION_H_INCLUDED #define BEAST_SEMANTICVERSION_H_INCLUDED +namespace beast +{ + /** A Semantic Version number. Identifies the build of a particular version of software using @@ -71,4 +74,6 @@ private: static bool chopIdentifiers (StringArray* value, bool preRelease, String& input); }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/diagnostic/Throw.h b/src/beast/modules/beast_core/diagnostic/Throw.h index e5c86f1b4a..bef8b256a6 100644 --- a/src/beast/modules/beast_core/diagnostic/Throw.h +++ b/src/beast/modules/beast_core/diagnostic/Throw.h @@ -20,6 +20,9 @@ #ifndef BEAST_THROW_H_INCLUDED #define BEAST_THROW_H_INCLUDED +namespace beast +{ + /** Throw an exception, with a debugger hook. This provides an opportunity to utilize the debugger before @@ -36,4 +39,6 @@ void Throw (Exception const& e, char const* = "", int = 0) throw e; } +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/diagnostic/UnitTest.cpp b/src/beast/modules/beast_core/diagnostic/UnitTest.cpp index 5d94ab60bb..c14a5c16b8 100644 --- a/src/beast/modules/beast_core/diagnostic/UnitTest.cpp +++ b/src/beast/modules/beast_core/diagnostic/UnitTest.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + UnitTest::UnitTest (String const& className, String const& packageName, When when) @@ -477,3 +480,5 @@ public: }; static UnitTestsPrinter unitTestsPrinter; + +} // namespace beast diff --git a/src/beast/modules/beast_core/diagnostic/UnitTest.h b/src/beast/modules/beast_core/diagnostic/UnitTest.h index 71c3091bf2..d28bf7a695 100644 --- a/src/beast/modules/beast_core/diagnostic/UnitTest.h +++ b/src/beast/modules/beast_core/diagnostic/UnitTest.h @@ -24,6 +24,9 @@ #ifndef BEAST_UNITTEST_H_INCLUDED #define BEAST_UNITTEST_H_INCLUDED +namespace beast +{ + class UnitTests; /** This is a base class for classes that perform a unit test. @@ -547,4 +550,6 @@ private: JournalSink m_sink; }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/diagnostic/UnitTestUtilities.cpp b/src/beast/modules/beast_core/diagnostic/UnitTestUtilities.cpp index a18293a9be..7875d0da7a 100644 --- a/src/beast/modules/beast_core/diagnostic/UnitTestUtilities.cpp +++ b/src/beast/modules/beast_core/diagnostic/UnitTestUtilities.cpp @@ -17,6 +17,9 @@ */ //============================================================================== +namespace beast +{ + namespace UnitTestUtilities { @@ -197,3 +200,5 @@ public: }; static UnitTestUtilitiesTests unitTestUtilitiesTests; + +} // namespace beast diff --git a/src/beast/modules/beast_core/diagnostic/UnitTestUtilities.h b/src/beast/modules/beast_core/diagnostic/UnitTestUtilities.h index 2e2df5d962..c42b431666 100644 --- a/src/beast/modules/beast_core/diagnostic/UnitTestUtilities.h +++ b/src/beast/modules/beast_core/diagnostic/UnitTestUtilities.h @@ -20,6 +20,9 @@ #ifndef BEAST_UNITTESTUTILITIES_H_INCLUDED #define BEAST_UNITTESTUTILITIES_H_INCLUDED +namespace beast +{ + namespace UnitTestUtilities { @@ -132,4 +135,6 @@ private: } +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/files/DirectoryIterator.cpp b/src/beast/modules/beast_core/files/DirectoryIterator.cpp index ce51b47927..5195f20697 100644 --- a/src/beast/modules/beast_core/files/DirectoryIterator.cpp +++ b/src/beast/modules/beast_core/files/DirectoryIterator.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + static StringArray parseWildcards (const String& pattern) { StringArray s; @@ -152,3 +155,5 @@ float DirectoryIterator::getEstimatedProgress() const return detailedIndex / totalNumFiles; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/files/DirectoryIterator.h b/src/beast/modules/beast_core/files/DirectoryIterator.h index 74d6153283..62c43351ba 100644 --- a/src/beast/modules/beast_core/files/DirectoryIterator.h +++ b/src/beast/modules/beast_core/files/DirectoryIterator.h @@ -24,6 +24,9 @@ #ifndef BEAST_DIRECTORYITERATOR_H_INCLUDED #define BEAST_DIRECTORYITERATOR_H_INCLUDED +namespace beast +{ + //============================================================================== /** Searches through a the files in a directory, returning each file that is found. @@ -143,4 +146,6 @@ private: File currentFile; }; +} // namespace beast + #endif // BEAST_DIRECTORYITERATOR_H_INCLUDED diff --git a/src/beast/modules/beast_core/files/File.cpp b/src/beast/modules/beast_core/files/File.cpp index 9717dca5da..ba26fae0e1 100644 --- a/src/beast/modules/beast_core/files/File.cpp +++ b/src/beast/modules/beast_core/files/File.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + // We need to make a shared singleton or else there are // issues with the leak detector and order of detruction. // @@ -1101,3 +1104,4 @@ public: static FileTests fileTests; +} // namespace beast diff --git a/src/beast/modules/beast_core/files/File.h b/src/beast/modules/beast_core/files/File.h index e5cfa4fe36..03ad73f654 100644 --- a/src/beast/modules/beast_core/files/File.h +++ b/src/beast/modules/beast_core/files/File.h @@ -24,6 +24,9 @@ #ifndef BEAST_FILE_H_INCLUDED #define BEAST_FILE_H_INCLUDED +namespace beast +{ + //============================================================================== /** Represents a local file or directory. @@ -948,5 +951,7 @@ private: bool setFileReadOnlyInternal (bool) const; }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/files/FileInputStream.cpp b/src/beast/modules/beast_core/files/FileInputStream.cpp index bceed5ba2f..6edec461b2 100644 --- a/src/beast/modules/beast_core/files/FileInputStream.cpp +++ b/src/beast/modules/beast_core/files/FileInputStream.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + int64 beast_fileSetPosition (void* handle, int64 pos); //============================================================================== @@ -88,3 +91,5 @@ bool FileInputStream::setPosition (int64 pos) return true; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/files/FileInputStream.h b/src/beast/modules/beast_core/files/FileInputStream.h index cbf1b47bf5..cbe26120dc 100644 --- a/src/beast/modules/beast_core/files/FileInputStream.h +++ b/src/beast/modules/beast_core/files/FileInputStream.h @@ -24,6 +24,9 @@ #ifndef BEAST_FILEINPUTSTREAM_H_INCLUDED #define BEAST_FILEINPUTSTREAM_H_INCLUDED +namespace beast +{ + //============================================================================== /** An input stream that reads from a local file. @@ -87,4 +90,6 @@ private: size_t readInternal (void* buffer, size_t numBytes); }; +} // namespace beast + #endif // BEAST_FILEINPUTSTREAM_H_INCLUDED diff --git a/src/beast/modules/beast_core/files/FileOutputStream.cpp b/src/beast/modules/beast_core/files/FileOutputStream.cpp index b7f24708f3..f61829cb7a 100644 --- a/src/beast/modules/beast_core/files/FileOutputStream.cpp +++ b/src/beast/modules/beast_core/files/FileOutputStream.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + int64 beast_fileSetPosition (void* handle, int64 pos); //============================================================================== @@ -127,4 +130,6 @@ bool FileOutputStream::writeRepeatedByte (uint8 byte, size_t numBytes) } return OutputStream::writeRepeatedByte (byte, numBytes); -} \ No newline at end of file +} + +} // namespace beast diff --git a/src/beast/modules/beast_core/files/FileOutputStream.h b/src/beast/modules/beast_core/files/FileOutputStream.h index 74b30d825b..18adec0f4f 100644 --- a/src/beast/modules/beast_core/files/FileOutputStream.h +++ b/src/beast/modules/beast_core/files/FileOutputStream.h @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + #ifndef BEAST_FILEOUTPUTSTREAM_H_INCLUDED #define BEAST_FILEOUTPUTSTREAM_H_INCLUDED @@ -107,4 +110,6 @@ private: ssize_t writeInternal (const void*, size_t); }; +} // namespace beast + #endif \ No newline at end of file diff --git a/src/beast/modules/beast_core/files/FileSearchPath.cpp b/src/beast/modules/beast_core/files/FileSearchPath.cpp index bfef91dd77..156ccb32ee 100644 --- a/src/beast/modules/beast_core/files/FileSearchPath.cpp +++ b/src/beast/modules/beast_core/files/FileSearchPath.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + FileSearchPath::FileSearchPath() { } @@ -164,3 +167,5 @@ bool FileSearchPath::isFileInPath (const File& fileToCheck, return false; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/files/FileSearchPath.h b/src/beast/modules/beast_core/files/FileSearchPath.h index 7c7d075e45..9bf2a3a231 100644 --- a/src/beast/modules/beast_core/files/FileSearchPath.h +++ b/src/beast/modules/beast_core/files/FileSearchPath.h @@ -24,6 +24,9 @@ #ifndef BEAST_FILESEARCHPATH_H_INCLUDED #define BEAST_FILESEARCHPATH_H_INCLUDED +namespace beast +{ + //============================================================================== /** Encapsulates a set of folders that make up a search path. @@ -155,4 +158,6 @@ private: void init (const String& path); }; +} // namespace beast + #endif // BEAST_FILESEARCHPATH_H_INCLUDED diff --git a/src/beast/modules/beast_core/files/MemoryMappedFile.h b/src/beast/modules/beast_core/files/MemoryMappedFile.h index f621966519..1856e3eee1 100644 --- a/src/beast/modules/beast_core/files/MemoryMappedFile.h +++ b/src/beast/modules/beast_core/files/MemoryMappedFile.h @@ -24,6 +24,8 @@ #ifndef BEAST_MEMORYMAPPEDFILE_H_INCLUDED #define BEAST_MEMORYMAPPEDFILE_H_INCLUDED +namespace beast +{ //============================================================================== /** @@ -104,5 +106,6 @@ private: void openInternal (const File&, AccessMode); }; +} // namespace beast #endif // BEAST_MEMORYMAPPEDFILE_H_INCLUDED diff --git a/src/beast/modules/beast_core/files/RandomAccessFile.cpp b/src/beast/modules/beast_core/files/RandomAccessFile.cpp index 84814b56c1..a20270ca1a 100644 --- a/src/beast/modules/beast_core/files/RandomAccessFile.cpp +++ b/src/beast/modules/beast_core/files/RandomAccessFile.cpp @@ -17,6 +17,9 @@ */ //============================================================================== +namespace beast +{ + RandomAccessFile::RandomAccessFile () noexcept : fileHandle (nullptr) , currentPosition (0) @@ -270,3 +273,5 @@ private: }; static RandomAccessFileTests randomAccessFileTests; + +} // namespace beast diff --git a/src/beast/modules/beast_core/files/RandomAccessFile.h b/src/beast/modules/beast_core/files/RandomAccessFile.h index 05f87a3116..d6c409a2f3 100644 --- a/src/beast/modules/beast_core/files/RandomAccessFile.h +++ b/src/beast/modules/beast_core/files/RandomAccessFile.h @@ -20,6 +20,9 @@ #ifndef BEAST_RANDOMACCESSFILE_H_INCLUDED #define BEAST_RANDOMACCESSFILE_H_INCLUDED +namespace beast +{ + /** Provides random access reading and writing to an operating system file. This class wraps the underlying native operating system routines for @@ -191,5 +194,7 @@ private: FileOffset currentPosition; }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/files/TemporaryFile.cpp b/src/beast/modules/beast_core/files/TemporaryFile.cpp index e5603da72c..9a91b3d4b5 100644 --- a/src/beast/modules/beast_core/files/TemporaryFile.cpp +++ b/src/beast/modules/beast_core/files/TemporaryFile.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + static File createTempFile (const File& parentDirectory, String name, const String& suffix, const int optionFlags) { @@ -110,3 +113,5 @@ bool TemporaryFile::deleteTemporaryFile() const return false; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/files/TemporaryFile.h b/src/beast/modules/beast_core/files/TemporaryFile.h index 9bea480aa1..b2f13fd4d5 100644 --- a/src/beast/modules/beast_core/files/TemporaryFile.h +++ b/src/beast/modules/beast_core/files/TemporaryFile.h @@ -24,6 +24,9 @@ #ifndef BEAST_TEMPORARYFILE_H_INCLUDED #define BEAST_TEMPORARYFILE_H_INCLUDED +namespace beast +{ + //============================================================================== /** Manages a temporary file, which will be deleted when this object is deleted. @@ -158,4 +161,6 @@ private: const File temporaryFile, targetFile; }; +} // namespace beast + #endif // BEAST_TEMPORARYFILE_H_INCLUDED diff --git a/src/beast/modules/beast_core/json/JSON.cpp b/src/beast/modules/beast_core/json/JSON.cpp index ebd6051a94..933245b2f0 100644 --- a/src/beast/modules/beast_core/json/JSON.cpp +++ b/src/beast/modules/beast_core/json/JSON.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + class JSONParser { public: @@ -640,3 +643,5 @@ public: }; static JSONTests jsonTests; + +} // namespace beast diff --git a/src/beast/modules/beast_core/json/JSON.h b/src/beast/modules/beast_core/json/JSON.h index 6e854f63fc..f17d019c5e 100644 --- a/src/beast/modules/beast_core/json/JSON.h +++ b/src/beast/modules/beast_core/json/JSON.h @@ -24,6 +24,9 @@ #ifndef BEAST_JSON_H_INCLUDED #define BEAST_JSON_H_INCLUDED +namespace beast +{ + class InputStream; class OutputStream; class File; @@ -106,5 +109,6 @@ private: JSON(); // This class can't be instantiated - just use its static methods. }; +} // namespace beast #endif // BEAST_JSON_H_INCLUDED diff --git a/src/beast/modules/beast_core/logging/FileLogger.cpp b/src/beast/modules/beast_core/logging/FileLogger.cpp index ad654cdf8f..1eba14fe2d 100644 --- a/src/beast/modules/beast_core/logging/FileLogger.cpp +++ b/src/beast/modules/beast_core/logging/FileLogger.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + FileLogger::FileLogger (const File& file, const String& welcomeMessage, const int64 maxInitialFileSizeBytes) @@ -127,3 +130,5 @@ FileLogger* FileLogger::createDateStampedLogger (const String& logFileSubDirecto .getNonexistentSibling(), welcomeMessage, 0); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/logging/FileLogger.h b/src/beast/modules/beast_core/logging/FileLogger.h index ddf887ee76..bf17d3fa68 100644 --- a/src/beast/modules/beast_core/logging/FileLogger.h +++ b/src/beast/modules/beast_core/logging/FileLogger.h @@ -24,6 +24,9 @@ #ifndef BEAST_FILELOGGER_H_INCLUDED #define BEAST_FILELOGGER_H_INCLUDED +namespace beast +{ + //============================================================================== /** A simple implementation of a Logger that writes to a file. @@ -126,5 +129,6 @@ private: void trimFileSize (int64 maxFileSizeBytes) const; }; +} // namespace beast #endif // BEAST_FILELOGGER_H_INCLUDED diff --git a/src/beast/modules/beast_core/logging/Logger.cpp b/src/beast/modules/beast_core/logging/Logger.cpp index 5a5f073345..bb3ed1dad5 100644 --- a/src/beast/modules/beast_core/logging/Logger.cpp +++ b/src/beast/modules/beast_core/logging/Logger.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + Logger::Logger() {} Logger::~Logger() @@ -56,3 +59,5 @@ void logAssertion (const char* const filename, const int lineNum) noexcept #endif } #endif + +} // namespace beast diff --git a/src/beast/modules/beast_core/logging/Logger.h b/src/beast/modules/beast_core/logging/Logger.h index a9935d5f77..1d682e19e6 100644 --- a/src/beast/modules/beast_core/logging/Logger.h +++ b/src/beast/modules/beast_core/logging/Logger.h @@ -24,6 +24,9 @@ #ifndef BEAST_LOGGER_H_INCLUDED #define BEAST_LOGGER_H_INCLUDED +namespace beast +{ + //============================================================================== /** Acts as an application-wide logging class. @@ -87,5 +90,6 @@ private: static Logger* currentLogger; }; +} // namespace beast #endif // BEAST_LOGGER_H_INCLUDED diff --git a/src/beast/modules/beast_core/maths/BigInteger.cpp b/src/beast/modules/beast_core/maths/BigInteger.cpp index f358981ec1..ff25eedd90 100644 --- a/src/beast/modules/beast_core/maths/BigInteger.cpp +++ b/src/beast/modules/beast_core/maths/BigInteger.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + namespace { inline size_t bitToIndex (const int bit) noexcept { return (size_t) (bit >> 5); } @@ -1014,3 +1017,5 @@ void BigInteger::loadFromMemoryBlock (const MemoryBlock& data) for (int i = (int) data.getSize(); --i >= 0;) this->setBitRangeAsInt (i << 3, 8, (uint32) data [i]); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/maths/BigInteger.h b/src/beast/modules/beast_core/maths/BigInteger.h index 0d2c2ea7fb..273a6bc7c8 100644 --- a/src/beast/modules/beast_core/maths/BigInteger.h +++ b/src/beast/modules/beast_core/maths/BigInteger.h @@ -24,6 +24,9 @@ #ifndef BEAST_BIGINTEGER_H_INCLUDED #define BEAST_BIGINTEGER_H_INCLUDED +namespace beast +{ + //============================================================================== /** An arbitrarily large integer class. @@ -318,5 +321,6 @@ OutputStream& BEAST_CALLTYPE operator<< (OutputStream& stream, const BigInteger& typedef BigInteger BitArray; #endif +} // namespace beast #endif // BEAST_BIGINTEGER_H_INCLUDED diff --git a/src/beast/modules/beast_core/maths/Math.h b/src/beast/modules/beast_core/maths/Math.h index b3976656f0..26f5bcfe4f 100644 --- a/src/beast/modules/beast_core/maths/Math.h +++ b/src/beast/modules/beast_core/maths/Math.h @@ -20,6 +20,9 @@ #ifndef BEAST_MATH_H_INCLUDED #define BEAST_MATH_H_INCLUDED +namespace beast +{ + // // Miscellaneous mathematical calculations // @@ -81,4 +84,6 @@ inline T radiansToDegrees (U radians) return deg; } +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/maths/Random.cpp b/src/beast/modules/beast_core/maths/Random.cpp index 4e8cf36d5c..2a9fd1c056 100644 --- a/src/beast/modules/beast_core/maths/Random.cpp +++ b/src/beast/modules/beast_core/maths/Random.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + Random::Random (const int64 seedValue) noexcept : seed (seedValue) { @@ -185,3 +188,5 @@ public: }; static RandomTests randomTests; + +} // namespace beast diff --git a/src/beast/modules/beast_core/maths/Random.h b/src/beast/modules/beast_core/maths/Random.h index 88af60b485..b80dd8066e 100644 --- a/src/beast/modules/beast_core/maths/Random.h +++ b/src/beast/modules/beast_core/maths/Random.h @@ -24,6 +24,9 @@ #ifndef BEAST_RANDOM_H_INCLUDED #define BEAST_RANDOM_H_INCLUDED +namespace beast +{ + //============================================================================== /** A random number generator. @@ -129,5 +132,6 @@ private: int64 seed; }; +} // namespace beast #endif // BEAST_RANDOM_H_INCLUDED diff --git a/src/beast/modules/beast_core/maths/Range.h b/src/beast/modules/beast_core/maths/Range.h index 48ccf87b4c..e184ebefb9 100644 --- a/src/beast/modules/beast_core/maths/Range.h +++ b/src/beast/modules/beast_core/maths/Range.h @@ -25,6 +25,9 @@ #define BEAST_RANGE_H_INCLUDED +namespace beast +{ + //============================================================================== /** A general-purpose range object, that simply represents any linear range with a start and end point. @@ -255,5 +258,6 @@ private: ValueType start, end; }; +} // namespace beast #endif // BEAST_RANGE_H_INCLUDED diff --git a/src/beast/modules/beast_core/memory/CacheLine.h b/src/beast/modules/beast_core/memory/CacheLine.h index fbc9c1914e..eba3b1cd12 100644 --- a/src/beast/modules/beast_core/memory/CacheLine.h +++ b/src/beast/modules/beast_core/memory/CacheLine.h @@ -25,6 +25,9 @@ // #define GLOBAL_PADDING_ENABLED 1 +namespace beast +{ + namespace CacheLine { @@ -412,6 +415,8 @@ private: T m_t; }; -} +} // namespace CacheLine + +} // namespace beast #endif diff --git a/src/beast/modules/beast_core/memory/MemoryAlignment.h b/src/beast/modules/beast_core/memory/MemoryAlignment.h index 0ff5dad1c4..a2928d56e4 100644 --- a/src/beast/modules/beast_core/memory/MemoryAlignment.h +++ b/src/beast/modules/beast_core/memory/MemoryAlignment.h @@ -20,6 +20,9 @@ #ifndef BEAST_MEMORYALIGNMENT_H_INCLUDED #define BEAST_MEMORYALIGNMENT_H_INCLUDED +namespace beast +{ + namespace Memory { @@ -62,6 +65,8 @@ inline P* pointerAdjustedForAlignment (P* const p) bytesNeededForAlignment (p)); } -} +} // namespace Memory + +} // namespace beast #endif diff --git a/src/beast/modules/beast_core/memory/MemoryBlock.cpp b/src/beast/modules/beast_core/memory/MemoryBlock.cpp index 1d57ece749..9c2e3c13b9 100644 --- a/src/beast/modules/beast_core/memory/MemoryBlock.cpp +++ b/src/beast/modules/beast_core/memory/MemoryBlock.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + MemoryBlock::MemoryBlock() noexcept : size (0) { @@ -402,4 +405,6 @@ bool MemoryBlock::fromBase64Encoding (const String& s) } return true; -} \ No newline at end of file +} + +} // namespace beast diff --git a/src/beast/modules/beast_core/memory/MemoryBlock.h b/src/beast/modules/beast_core/memory/MemoryBlock.h index b5d9cf0f2d..c411192d0e 100644 --- a/src/beast/modules/beast_core/memory/MemoryBlock.h +++ b/src/beast/modules/beast_core/memory/MemoryBlock.h @@ -24,6 +24,9 @@ #ifndef BEAST_MEMORYBLOCK_H_INCLUDED #define BEAST_MEMORYBLOCK_H_INCLUDED +namespace beast +{ + //============================================================================== /** A class to hold a resizable block of raw data. @@ -264,5 +267,7 @@ private: size_t size; }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/memory/OptionalScopedPointer.h b/src/beast/modules/beast_core/memory/OptionalScopedPointer.h index 9aeffd7a1f..1c3008f390 100644 --- a/src/beast/modules/beast_core/memory/OptionalScopedPointer.h +++ b/src/beast/modules/beast_core/memory/OptionalScopedPointer.h @@ -24,6 +24,9 @@ #ifndef BEAST_OPTIONALSCOPEDPOINTER_H_INCLUDED #define BEAST_OPTIONALSCOPEDPOINTER_H_INCLUDED +namespace beast +{ + //============================================================================== /** Holds a pointer to an object which can optionally be deleted when this pointer @@ -176,5 +179,6 @@ private: bool shouldDelete; }; +} // namespace beast #endif // BEAST_OPTIONALSCOPEDPOINTER_H_INCLUDED diff --git a/src/beast/modules/beast_core/memory/SharedSingleton.h b/src/beast/modules/beast_core/memory/SharedSingleton.h index 4e019cb0d8..28b8ee8d37 100644 --- a/src/beast/modules/beast_core/memory/SharedSingleton.h +++ b/src/beast/modules/beast_core/memory/SharedSingleton.h @@ -20,6 +20,9 @@ #ifndef BEAST_SHAREDSINGLETON_H_INCLUDED #define BEAST_SHAREDSINGLETON_H_INCLUDED +namespace beast +{ + /** Thread-safe singleton which comes into existence on first use. Use this instead of creating objects with static storage duration. These singletons are automatically reference counted, so if you hold a pointer to it in every @@ -190,4 +193,6 @@ private: //------------------------------------------------------------------------------ +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/misc/Main.cpp b/src/beast/modules/beast_core/misc/Main.cpp index e9ccaf4d8b..1f04b0ecf5 100644 --- a/src/beast/modules/beast_core/misc/Main.cpp +++ b/src/beast/modules/beast_core/misc/Main.cpp @@ -17,6 +17,9 @@ */ //============================================================================== +namespace beast +{ + Main* Main::s_instance; Main::Main () @@ -124,3 +127,5 @@ int Main::runFromMain (int argc, char const* const* argv) return exitCode; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/misc/Main.h b/src/beast/modules/beast_core/misc/Main.h index 0059b9cc92..25158476d8 100644 --- a/src/beast/modules/beast_core/misc/Main.h +++ b/src/beast/modules/beast_core/misc/Main.h @@ -20,6 +20,9 @@ #ifndef BEAST_CORE_MAIN_H_INCLUDED #define BEAST_CORE_MAIN_H_INCLUDED +namespace beast +{ + /** Represents a command line program's entry point To use this, derive your class from @ref Main and implement the function run (); @@ -75,5 +78,7 @@ private: static Main* s_instance; }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/misc/Result.cpp b/src/beast/modules/beast_core/misc/Result.cpp index cf04bbc07b..36dfe59bd1 100644 --- a/src/beast/modules/beast_core/misc/Result.cpp +++ b/src/beast/modules/beast_core/misc/Result.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + Result::Result() noexcept {} Result::Result (const String& message) noexcept @@ -76,3 +79,5 @@ bool Result::wasOk() const noexcept { return errorMessage.isEmpty(); } Result::operator bool() const noexcept { return errorMessage.isEmpty(); } bool Result::failed() const noexcept { return errorMessage.isNotEmpty(); } bool Result::operator!() const noexcept { return errorMessage.isNotEmpty(); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/misc/Result.h b/src/beast/modules/beast_core/misc/Result.h index d596a8d6a5..661137b2a3 100644 --- a/src/beast/modules/beast_core/misc/Result.h +++ b/src/beast/modules/beast_core/misc/Result.h @@ -24,6 +24,9 @@ #ifndef BEAST_RESULT_H_INCLUDED #define BEAST_RESULT_H_INCLUDED +namespace beast +{ + /** Represents the 'success' or 'failure' of an operation, and holds an associated error message to describe the error when there's a failure. @@ -113,5 +116,7 @@ private: operator void*() const; }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/misc/Uuid.cpp b/src/beast/modules/beast_core/misc/Uuid.cpp index 3a947f848c..64bae164bf 100644 --- a/src/beast/modules/beast_core/misc/Uuid.cpp +++ b/src/beast/modules/beast_core/misc/Uuid.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + namespace { int64 getRandomSeedFromMACAddresses() @@ -107,3 +110,5 @@ Uuid& Uuid::operator= (const uint8* const rawData) noexcept return *this; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/misc/Uuid.h b/src/beast/modules/beast_core/misc/Uuid.h index 36b08c43e4..b7a7848d66 100644 --- a/src/beast/modules/beast_core/misc/Uuid.h +++ b/src/beast/modules/beast_core/misc/Uuid.h @@ -24,6 +24,9 @@ #ifndef BEAST_UUID_H_INCLUDED #define BEAST_UUID_H_INCLUDED +namespace beast +{ + //============================================================================== /** A universally unique 128-bit identifier. @@ -100,5 +103,6 @@ private: uint8 uuid[16]; }; +} // namespace beast #endif // BEAST_UUID_H_INCLUDED diff --git a/src/beast/modules/beast_core/misc/WindowsRegistry.h b/src/beast/modules/beast_core/misc/WindowsRegistry.h index 9d89defd30..504369791b 100644 --- a/src/beast/modules/beast_core/misc/WindowsRegistry.h +++ b/src/beast/modules/beast_core/misc/WindowsRegistry.h @@ -24,6 +24,9 @@ #ifndef BEAST_WINDOWSREGISTRY_H_INCLUDED #define BEAST_WINDOWSREGISTRY_H_INCLUDED +namespace beast +{ + #if BEAST_WINDOWS || DOXYGEN /** @@ -115,4 +118,7 @@ private: }; #endif + +} // namespace beast + #endif // BEAST_WINDOWSREGISTRY_H_INCLUDED diff --git a/src/beast/modules/beast_core/native/android_Files.cpp b/src/beast/modules/beast_core/native/android_Files.cpp index a789f7e8d3..ec01713a3f 100644 --- a/src/beast/modules/beast_core/native/android_Files.cpp +++ b/src/beast/modules/beast_core/native/android_Files.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + bool File::copyInternal (const File& dest) const { FileInputStream in (*this); @@ -233,3 +236,5 @@ bool Process::openDocument (const String& fileName, const String& parameters) void File::revealToUser() const { } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/android_JNIHelpers.h b/src/beast/modules/beast_core/native/android_JNIHelpers.h index 6a4f1f9672..f9c0892817 100644 --- a/src/beast/modules/beast_core/native/android_JNIHelpers.h +++ b/src/beast/modules/beast_core/native/android_JNIHelpers.h @@ -24,6 +24,9 @@ #ifndef BEAST_ANDROID_JNIHELPERS_H_INCLUDED #define BEAST_ANDROID_JNIHELPERS_H_INCLUDED +namespace beast +{ + #if ! (defined (BEAST_ANDROID_ACTIVITY_CLASSNAME) && defined (BEAST_ANDROID_ACTIVITY_CLASSPATH)) #error "The BEAST_ANDROID_ACTIVITY_CLASSNAME and BEAST_ANDROID_ACTIVITY_CLASSPATH macros must be set!" #endif @@ -397,4 +400,6 @@ DECLARE_JNI_CLASS (Matrix, "android/graphics/Matrix"); DECLARE_JNI_CLASS (RectClass, "android/graphics/Rect"); #undef JNI_CLASS_MEMBERS +} // namespace beast + #endif // BEAST_ANDROID_JNIHELPERS_H_INCLUDED diff --git a/src/beast/modules/beast_core/native/android_Misc.cpp b/src/beast/modules/beast_core/native/android_Misc.cpp index 275fd6e114..fd77f73eb4 100644 --- a/src/beast/modules/beast_core/native/android_Misc.cpp +++ b/src/beast/modules/beast_core/native/android_Misc.cpp @@ -21,7 +21,12 @@ */ //============================================================================== +namespace beast +{ + void Logger::outputDebugString (const String& text) { __android_log_print (ANDROID_LOG_INFO, "BEAST", "%", text.toUTF8().getAddress()); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/android_Network.cpp b/src/beast/modules/beast_core/native/android_Network.cpp index ec2ba4964e..ee0b2091b5 100644 --- a/src/beast/modules/beast_core/native/android_Network.cpp +++ b/src/beast/modules/beast_core/native/android_Network.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + //============================================================================== #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (constructor, "", "()V") \ @@ -57,3 +60,5 @@ bool Process::openEmailWithAttachments (const String& targetEmailAddress, // TODO return false; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/android_SystemStats.cpp b/src/beast/modules/beast_core/native/android_SystemStats.cpp index fe66fa6df6..c262df3eac 100644 --- a/src/beast/modules/beast_core/native/android_SystemStats.cpp +++ b/src/beast/modules/beast_core/native/android_SystemStats.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + JNIClassBase::JNIClassBase (const char* classPath_) : classPath (classPath_), classRef (0) { @@ -299,3 +302,5 @@ bool Time::setSystemTimeToThisTime() const bassertfalse; return false; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/android_Threads.cpp b/src/beast/modules/beast_core/native/android_Threads.cpp index e36cdf8252..0a32a3547f 100644 --- a/src/beast/modules/beast_core/native/android_Threads.cpp +++ b/src/beast/modules/beast_core/native/android_Threads.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + /* Note that a lot of methods that you'd expect to find in this file actually live in beast_posix_SharedCode.h! @@ -69,3 +72,5 @@ BEAST_API bool BEAST_CALLTYPE Process::isRunningUnderDebugger() void Process::raisePrivilege() {} void Process::lowerPrivilege() {} + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/bsd_Files.cpp b/src/beast/modules/beast_core/native/bsd_Files.cpp index 109b947f15..69ba29c81b 100644 --- a/src/beast/modules/beast_core/native/bsd_Files.cpp +++ b/src/beast/modules/beast_core/native/bsd_Files.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + enum { U_ISOFS_SUPER_MAGIC = 5, @@ -367,3 +370,5 @@ void File::revealToUser() const else if (getParentDirectory().exists()) getParentDirectory().startAsProcess(); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/bsd_Network.cpp b/src/beast/modules/beast_core/native/bsd_Network.cpp index 9fb630149d..6a7a88eed4 100644 --- a/src/beast/modules/beast_core/native/bsd_Network.cpp +++ b/src/beast/modules/beast_core/native/bsd_Network.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + void MACAddress::findAllAddresses (Array& result) { ifaddrs* addrs = nullptr; @@ -57,3 +60,5 @@ bool Process::openEmailWithAttachments (const String& /* targetEmailAddress */, return false; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/bsd_SystemStats.cpp b/src/beast/modules/beast_core/native/bsd_SystemStats.cpp index e5ce2ec208..f4e288e591 100644 --- a/src/beast/modules/beast_core/native/bsd_SystemStats.cpp +++ b/src/beast/modules/beast_core/native/bsd_SystemStats.cpp @@ -52,6 +52,9 @@ * */ +namespace beast +{ + #define SI_LOAD_SHIFT 16 struct sysinfo { long uptime; /* Seconds since boot */ @@ -349,3 +352,5 @@ bool Time::setSystemTimeToThisTime() const return settimeofday (&t, 0) == 0; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/bsd_Threads.cpp b/src/beast/modules/beast_core/native/bsd_Threads.cpp index 5573fc48db..680b9fbf2a 100644 --- a/src/beast/modules/beast_core/native/bsd_Threads.cpp +++ b/src/beast/modules/beast_core/native/bsd_Threads.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + /* Note that a lot of methods that you'd expect to find in this file actually live in beast_posix_SharedCode.h! @@ -67,3 +70,5 @@ static void swapUserAndEffectiveUser() void Process::raisePrivilege() { if (geteuid() != 0 && getuid() == 0) swapUserAndEffectiveUser(); } void Process::lowerPrivilege() { if (geteuid() == 0 && getuid() != 0) swapUserAndEffectiveUser(); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/linux_Files.cpp b/src/beast/modules/beast_core/native/linux_Files.cpp index 3a9aa88cf3..1f05ee0f9d 100644 --- a/src/beast/modules/beast_core/native/linux_Files.cpp +++ b/src/beast/modules/beast_core/native/linux_Files.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + enum { U_ISOFS_SUPER_MAGIC = 0x9660, // linux/iso_fs.h @@ -367,3 +370,5 @@ void File::revealToUser() const else if (getParentDirectory().exists()) getParentDirectory().startAsProcess(); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/linux_Network.cpp b/src/beast/modules/beast_core/native/linux_Network.cpp index 38046c496d..a182bc233b 100644 --- a/src/beast/modules/beast_core/native/linux_Network.cpp +++ b/src/beast/modules/beast_core/native/linux_Network.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + void MACAddress::findAllAddresses (Array& result) { const int s = socket (AF_INET, SOCK_DGRAM, 0); @@ -59,3 +62,5 @@ bool Process::openEmailWithAttachments (const String& /* targetEmailAddress */, return false; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/linux_SystemStats.cpp b/src/beast/modules/beast_core/native/linux_SystemStats.cpp index 5fce6d211d..f74c06671a 100644 --- a/src/beast/modules/beast_core/native/linux_SystemStats.cpp +++ b/src/beast/modules/beast_core/native/linux_SystemStats.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + void Logger::outputDebugString (const String& text) { std::cerr << text << std::endl; @@ -174,3 +177,5 @@ bool Time::setSystemTimeToThisTime() const return settimeofday (&t, 0) == 0; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/linux_Threads.cpp b/src/beast/modules/beast_core/native/linux_Threads.cpp index 795bebc047..64af66fc4b 100644 --- a/src/beast/modules/beast_core/native/linux_Threads.cpp +++ b/src/beast/modules/beast_core/native/linux_Threads.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + /* Note that a lot of methods that you'd expect to find in this file actually live in beast_posix_SharedCode.h! @@ -78,3 +81,5 @@ static void swapUserAndEffectiveUser() void Process::raisePrivilege() { if (geteuid() != 0 && getuid() == 0) swapUserAndEffectiveUser(); } void Process::lowerPrivilege() { if (geteuid() == 0 && getuid() != 0) swapUserAndEffectiveUser(); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/mac_Files.mm b/src/beast/modules/beast_core/native/mac_Files.mm index 03e8fe7c39..dc2ad72b7d 100644 --- a/src/beast/modules/beast_core/native/mac_Files.mm +++ b/src/beast/modules/beast_core/native/mac_Files.mm @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + /* Note that a lot of methods that you'd expect to find in this file actually live in beast_posix_SharedCode.h! @@ -477,3 +480,5 @@ void File::addToDock() const } } #endif + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/mac_Network.mm b/src/beast/modules/beast_core/native/mac_Network.mm index b8e2d74ae5..4fe1fe6b3b 100644 --- a/src/beast/modules/beast_core/native/mac_Network.mm +++ b/src/beast/modules/beast_core/native/mac_Network.mm @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + void MACAddress::findAllAddresses (Array& result) { ifaddrs* addrs = nullptr; @@ -95,3 +98,5 @@ bool Process::openEmailWithAttachments (const String& targetEmailAddress, } #endif } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/mac_Strings.mm b/src/beast/modules/beast_core/native/mac_Strings.mm index 4b1cb88678..befece2cfc 100644 --- a/src/beast/modules/beast_core/native/mac_Strings.mm +++ b/src/beast/modules/beast_core/native/mac_Strings.mm @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + String String::fromCFString (CFStringRef cfString) { if (cfString == 0) @@ -89,3 +92,5 @@ String String::convertToPrecomposedUnicode() const return result; #endif } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/mac_SystemStats.mm b/src/beast/modules/beast_core/native/mac_SystemStats.mm index 39e9fb941a..040f5a7330 100644 --- a/src/beast/modules/beast_core/native/mac_SystemStats.mm +++ b/src/beast/modules/beast_core/native/mac_SystemStats.mm @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + ScopedAutoReleasePool::ScopedAutoReleasePool() { pool = [[NSAutoreleasePool alloc] init]; @@ -289,3 +292,5 @@ int SystemStats::getPageSize() { return (int) NSPageSize(); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/mac_Threads.mm b/src/beast/modules/beast_core/native/mac_Threads.mm index f40d7b2593..fd64ed6c9b 100644 --- a/src/beast/modules/beast_core/native/mac_Threads.mm +++ b/src/beast/modules/beast_core/native/mac_Threads.mm @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + /* Note that a lot of methods that you'd expect to find in this file actually live in beast_posix_SharedCode.h! @@ -79,3 +82,5 @@ BEAST_API bool BEAST_CALLTYPE Process::isRunningUnderDebugger() { return beast_isRunningUnderDebugger(); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/osx_ObjCHelpers.h b/src/beast/modules/beast_core/native/osx_ObjCHelpers.h index 42743eedec..d4f19bc719 100644 --- a/src/beast/modules/beast_core/native/osx_ObjCHelpers.h +++ b/src/beast/modules/beast_core/native/osx_ObjCHelpers.h @@ -24,6 +24,9 @@ #ifndef BEAST_OSX_OBJCHELPERS_H_INCLUDED #define BEAST_OSX_OBJCHELPERS_H_INCLUDED +namespace beast +{ + /* This file contains a few helper functions that are used internally but which need to be kept away from the public headers because they use obj-C symbols. */ @@ -146,5 +149,6 @@ private: } }; +} // namespace beast #endif // BEAST_OSX_OBJCHELPERS_H_INCLUDED diff --git a/src/beast/modules/beast_core/native/posix_FPUFlags.cpp b/src/beast/modules/beast_core/native/posix_FPUFlags.cpp index 0b0d476c12..5fc31f95e4 100644 --- a/src/beast/modules/beast_core/native/posix_FPUFlags.cpp +++ b/src/beast/modules/beast_core/native/posix_FPUFlags.cpp @@ -17,6 +17,9 @@ */ //============================================================================== +namespace beast +{ + //#pragma message(BEAST_FILEANDLINE_ "Missing platform-specific implementation") FPUFlags FPUFlags::getCurrent () @@ -27,3 +30,5 @@ FPUFlags FPUFlags::getCurrent () void FPUFlags::setCurrent (const FPUFlags& flags) { } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/posix_SharedCode.h b/src/beast/modules/beast_core/native/posix_SharedCode.h index 4d72928d40..01d151a998 100644 --- a/src/beast/modules/beast_core/native/posix_SharedCode.h +++ b/src/beast/modules/beast_core/native/posix_SharedCode.h @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + CriticalSection::CriticalSection() noexcept { pthread_mutexattr_t atts; @@ -1207,3 +1210,5 @@ private: #endif } }; + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/win32_ComSmartPtr.h b/src/beast/modules/beast_core/native/win32_ComSmartPtr.h index 03c9380acd..f704a8e70b 100644 --- a/src/beast/modules/beast_core/native/win32_ComSmartPtr.h +++ b/src/beast/modules/beast_core/native/win32_ComSmartPtr.h @@ -24,6 +24,9 @@ #ifndef BEAST_WIN32_COMSMARTPTR_H_INCLUDED #define BEAST_WIN32_COMSMARTPTR_H_INCLUDED +namespace beast +{ + #ifndef _MSC_VER template struct UUIDGetter { static CLSID get() { bassertfalse; return CLSID(); } }; #define __uuidof(x) UUIDGetter::get() @@ -162,4 +165,6 @@ public: } }; +} // namespace beast + #endif // BEAST_WIN32_COMSMARTPTR_H_INCLUDED diff --git a/src/beast/modules/beast_core/native/win32_FPUFlags.cpp b/src/beast/modules/beast_core/native/win32_FPUFlags.cpp index a21354d448..ca6fc7c05b 100644 --- a/src/beast/modules/beast_core/native/win32_FPUFlags.cpp +++ b/src/beast/modules/beast_core/native/win32_FPUFlags.cpp @@ -17,6 +17,9 @@ */ //============================================================================== +namespace beast +{ + FPUFlags FPUFlags::getCurrent () { unsigned int currentControl; @@ -174,3 +177,5 @@ void FPUFlags::setCurrent (const FPUFlags& flags) if (result != 0) Throw (std::runtime_error ("error in _controlfp_s")); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/win32_Files.cpp b/src/beast/modules/beast_core/native/win32_Files.cpp index 5767925b5b..6eb7275d0f 100644 --- a/src/beast/modules/beast_core/native/win32_Files.cpp +++ b/src/beast/modules/beast_core/native/win32_Files.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + #ifndef INVALID_FILE_ATTRIBUTES #define INVALID_FILE_ATTRIBUTES ((DWORD) -1) #endif @@ -883,3 +886,5 @@ void File::revealToUser() const } } } + +} // beast diff --git a/src/beast/modules/beast_core/native/win32_Network.cpp b/src/beast/modules/beast_core/native/win32_Network.cpp index 231b897ab5..37deb8be29 100644 --- a/src/beast/modules/beast_core/native/win32_Network.cpp +++ b/src/beast/modules/beast_core/native/win32_Network.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + struct GetAdaptersInfoHelper { bool callGetAdaptersInfo() @@ -152,3 +155,5 @@ bool Process::openEmailWithAttachments (const String& targetEmailAddress, return mapiSendMail (0, 0, &message, MAPI_DIALOG | MAPI_LOGON_UI, 0) == SUCCESS_SUCCESS; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/win32_Registry.cpp b/src/beast/modules/beast_core/native/win32_Registry.cpp index 467323852a..c2a09204fc 100644 --- a/src/beast/modules/beast_core/native/win32_Registry.cpp +++ b/src/beast/modules/beast_core/native/win32_Registry.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + struct RegistryKeyWrapper : public Uncopyable { RegistryKeyWrapper (String name, const bool createForWriting, const DWORD wow64Flags) @@ -212,3 +215,5 @@ bool WindowsRegistry::registerFileAssociation (const String& fileExtension, || setValue (key + "\\DefaultIcon\\", targetExecutable.getFullPathName() + "," + String (-iconResourceNumber))); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/win32_SystemStats.cpp b/src/beast/modules/beast_core/native/win32_SystemStats.cpp index c4f1f8ca4e..56e892aaab 100644 --- a/src/beast/modules/beast_core/native/win32_SystemStats.cpp +++ b/src/beast/modules/beast_core/native/win32_SystemStats.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + void Logger::outputDebugString (const String& text) { OutputDebugString ((text + "\n").toWideCharPointer()); @@ -416,3 +419,5 @@ String SystemStats::getDisplayLanguage() return "en"; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/native/win32_Threads.cpp b/src/beast/modules/beast_core/native/win32_Threads.cpp index 019a6d900e..bb38984b0f 100644 --- a/src/beast/modules/beast_core/native/win32_Threads.cpp +++ b/src/beast/modules/beast_core/native/win32_Threads.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + void* getUser32Function (const char* functionName) { HMODULE module = GetModuleHandleA ("user32.dll"); @@ -450,3 +453,5 @@ private: timer->owner.hiResTimerCallback(); } }; + +} // namespace beast diff --git a/src/beast/modules/beast_core/network/MACAddress.cpp b/src/beast/modules/beast_core/network/MACAddress.cpp index d9de043f76..abcf4f536c 100644 --- a/src/beast/modules/beast_core/network/MACAddress.cpp +++ b/src/beast/modules/beast_core/network/MACAddress.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + MACAddress::MACAddress() { zeromem (address, sizeof (address)); @@ -71,3 +74,5 @@ bool MACAddress::isNull() const noexcept { return bool MACAddress::operator== (const MACAddress& other) const noexcept { return memcmp (address, other.address, sizeof (address)) == 0; } bool MACAddress::operator!= (const MACAddress& other) const noexcept { return ! operator== (other); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/network/MACAddress.h b/src/beast/modules/beast_core/network/MACAddress.h index 24e003c097..dd8d3a643a 100644 --- a/src/beast/modules/beast_core/network/MACAddress.h +++ b/src/beast/modules/beast_core/network/MACAddress.h @@ -24,6 +24,9 @@ #ifndef BEAST_MACADDRESS_H_INCLUDED #define BEAST_MACADDRESS_H_INCLUDED +namespace beast +{ + //============================================================================== /** A wrapper for a streaming (TCP) socket. @@ -77,5 +80,6 @@ private: uint8 address[6]; }; +} // namespace beast #endif // BEAST_MACADDRESS_H_INCLUDED diff --git a/src/beast/modules/beast_core/network/NamedPipe.cpp b/src/beast/modules/beast_core/network/NamedPipe.cpp index c46cae3b7d..dd8e77bbc9 100644 --- a/src/beast/modules/beast_core/network/NamedPipe.cpp +++ b/src/beast/modules/beast_core/network/NamedPipe.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + NamedPipe::NamedPipe() { } @@ -59,3 +62,5 @@ String NamedPipe::getName() const } // other methods for this class are implemented in the platform-specific files + +} // namespace beast diff --git a/src/beast/modules/beast_core/network/NamedPipe.h b/src/beast/modules/beast_core/network/NamedPipe.h index 2f59ba4a12..530593a325 100644 --- a/src/beast/modules/beast_core/network/NamedPipe.h +++ b/src/beast/modules/beast_core/network/NamedPipe.h @@ -24,6 +24,9 @@ #ifndef BEAST_NAMEDPIPE_H_INCLUDED #define BEAST_NAMEDPIPE_H_INCLUDED +namespace beast +{ + //============================================================================== /** A cross-process pipe that can have data written to and read from it. @@ -92,5 +95,6 @@ private: bool openInternal (const String& pipeName, const bool createPipe); }; +} // namespace beast #endif // BEAST_NAMEDPIPE_H_INCLUDED diff --git a/src/beast/modules/beast_core/network/Socket.cpp b/src/beast/modules/beast_core/network/Socket.cpp index 60e997d2b7..77bb82f9f9 100644 --- a/src/beast/modules/beast_core/network/Socket.cpp +++ b/src/beast/modules/beast_core/network/Socket.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + #if BEAST_MSVC #pragma warning (push) #pragma warning (disable : 4127 4389 4018) @@ -583,3 +586,5 @@ bool DatagramSocket::isLocal() const noexcept #if BEAST_MSVC #pragma warning (pop) #endif + +} // namespace beast diff --git a/src/beast/modules/beast_core/network/Socket.h b/src/beast/modules/beast_core/network/Socket.h index 734f0c6c6a..125408f87a 100644 --- a/src/beast/modules/beast_core/network/Socket.h +++ b/src/beast/modules/beast_core/network/Socket.h @@ -24,6 +24,9 @@ #ifndef BEAST_SOCKET_H_INCLUDED #define BEAST_SOCKET_H_INCLUDED +namespace beast +{ + //============================================================================== /** A wrapper for a streaming (TCP) socket. @@ -291,5 +294,6 @@ private: DatagramSocket (const String& hostname, int portNumber, int handle, int localPortNumber); }; +} // namespace beast #endif // BEAST_SOCKET_H_INCLUDED diff --git a/src/beast/modules/beast_core/streams/BufferedInputStream.cpp b/src/beast/modules/beast_core/streams/BufferedInputStream.cpp index 8fcb738681..2b858beaff 100644 --- a/src/beast/modules/beast_core/streams/BufferedInputStream.cpp +++ b/src/beast/modules/beast_core/streams/BufferedInputStream.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + namespace { int calcBufferStreamBufferSize (int requestedSize, InputStream* const source) noexcept @@ -191,3 +194,5 @@ String BufferedInputStream::readString() return InputStream::readString(); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/streams/BufferedInputStream.h b/src/beast/modules/beast_core/streams/BufferedInputStream.h index 8f55ee42e8..d50121273c 100644 --- a/src/beast/modules/beast_core/streams/BufferedInputStream.h +++ b/src/beast/modules/beast_core/streams/BufferedInputStream.h @@ -24,6 +24,9 @@ #ifndef BEAST_BUFFEREDINPUTSTREAM_H_INCLUDED #define BEAST_BUFFEREDINPUTSTREAM_H_INCLUDED +namespace beast +{ + //============================================================================== /** Wraps another input stream, and reads from it using an intermediate buffer @@ -83,4 +86,6 @@ private: void ensureBuffered(); }; +} // namespace beast + #endif // BEAST_BUFFEREDINPUTSTREAM_H_INCLUDED diff --git a/src/beast/modules/beast_core/streams/FileInputSource.cpp b/src/beast/modules/beast_core/streams/FileInputSource.cpp index a2f677dcd5..5248a4d602 100644 --- a/src/beast/modules/beast_core/streams/FileInputSource.cpp +++ b/src/beast/modules/beast_core/streams/FileInputSource.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + FileInputSource::FileInputSource (const File& f, bool useFileTimeInHash) : file (f), useFileTimeInHashGeneration (useFileTimeInHash) { @@ -49,3 +52,5 @@ int64 FileInputSource::hashCode() const return h; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/streams/FileInputSource.h b/src/beast/modules/beast_core/streams/FileInputSource.h index 63149434c1..b0f8dd91d2 100644 --- a/src/beast/modules/beast_core/streams/FileInputSource.h +++ b/src/beast/modules/beast_core/streams/FileInputSource.h @@ -24,6 +24,9 @@ #ifndef BEAST_FILEINPUTSOURCE_H_INCLUDED #define BEAST_FILEINPUTSOURCE_H_INCLUDED +namespace beast +{ + //============================================================================== /** A type of InputSource that represents a normal file. @@ -57,5 +60,6 @@ private: bool useFileTimeInHashGeneration; }; +} // namespace beast #endif // BEAST_FILEINPUTSOURCE_H_INCLUDED diff --git a/src/beast/modules/beast_core/streams/InputSource.h b/src/beast/modules/beast_core/streams/InputSource.h index ec1c386087..9653fa4999 100644 --- a/src/beast/modules/beast_core/streams/InputSource.h +++ b/src/beast/modules/beast_core/streams/InputSource.h @@ -24,6 +24,9 @@ #ifndef BEAST_INPUTSOURCE_H_INCLUDED #define BEAST_INPUTSOURCE_H_INCLUDED +namespace beast +{ + //============================================================================== /** A lightweight object that can create a stream to read some kind of resource. @@ -63,5 +66,6 @@ public: virtual int64 hashCode() const = 0; }; +} // namespace beast #endif // BEAST_INPUTSOURCE_H_INCLUDED diff --git a/src/beast/modules/beast_core/streams/InputStream.cpp b/src/beast/modules/beast_core/streams/InputStream.cpp index 17360a1e49..c883c039e5 100644 --- a/src/beast/modules/beast_core/streams/InputStream.cpp +++ b/src/beast/modules/beast_core/streams/InputStream.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + int64 InputStream::getNumBytesRemaining() { int64 len = getTotalLength(); @@ -320,3 +323,4 @@ float InputStream::readTypeBigEndian () { return readFloatBigEndian (); template <> double InputStream::readTypeBigEndian () { return readDoubleBigEndian (); } +} // namespace beast diff --git a/src/beast/modules/beast_core/streams/InputStream.h b/src/beast/modules/beast_core/streams/InputStream.h index 3c32dd448d..9944981c3f 100644 --- a/src/beast/modules/beast_core/streams/InputStream.h +++ b/src/beast/modules/beast_core/streams/InputStream.h @@ -24,6 +24,9 @@ #ifndef BEAST_INPUTSTREAM_H_INCLUDED #define BEAST_INPUTSTREAM_H_INCLUDED +namespace beast +{ + class MemoryBlock; //============================================================================== @@ -352,4 +355,6 @@ protected: InputStream() noexcept {} }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/streams/MemoryInputStream.cpp b/src/beast/modules/beast_core/streams/MemoryInputStream.cpp index e0679c60f8..7d354b8c45 100644 --- a/src/beast/modules/beast_core/streams/MemoryInputStream.cpp +++ b/src/beast/modules/beast_core/streams/MemoryInputStream.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + MemoryInputStream::MemoryInputStream (const void* const sourceData, const size_t sourceDataSize, const bool keepInternalCopy) @@ -149,3 +152,5 @@ public: }; static MemoryStreamTests memoryStreamTests; + +} // namespace beast diff --git a/src/beast/modules/beast_core/streams/MemoryInputStream.h b/src/beast/modules/beast_core/streams/MemoryInputStream.h index 24c8c063cf..a6a7d5dd90 100644 --- a/src/beast/modules/beast_core/streams/MemoryInputStream.h +++ b/src/beast/modules/beast_core/streams/MemoryInputStream.h @@ -24,6 +24,9 @@ #ifndef BEAST_MEMORYINPUTSTREAM_H_INCLUDED #define BEAST_MEMORYINPUTSTREAM_H_INCLUDED +namespace beast +{ + //============================================================================== /** Allows a block of data to be accessed as a stream. @@ -88,4 +91,6 @@ private: void createInternalCopy(); }; +} // namespace beast + #endif // BEAST_MEMORYINPUTSTREAM_H_INCLUDED diff --git a/src/beast/modules/beast_core/streams/MemoryOutputStream.cpp b/src/beast/modules/beast_core/streams/MemoryOutputStream.cpp index 8df895da1b..34005a8029 100644 --- a/src/beast/modules/beast_core/streams/MemoryOutputStream.cpp +++ b/src/beast/modules/beast_core/streams/MemoryOutputStream.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + MemoryOutputStream::MemoryOutputStream (const size_t initialSize) : blockToUse (&internalBlock), externalData (nullptr), position (0), size (0), availableSize (0) @@ -206,4 +209,6 @@ OutputStream& BEAST_CALLTYPE operator<< (OutputStream& stream, const MemoryOutpu stream.write (streamToRead.getData(), dataSize); return stream; -} \ No newline at end of file +} + +} // namespace beast diff --git a/src/beast/modules/beast_core/streams/MemoryOutputStream.h b/src/beast/modules/beast_core/streams/MemoryOutputStream.h index e51f395ebb..80514f27ad 100644 --- a/src/beast/modules/beast_core/streams/MemoryOutputStream.h +++ b/src/beast/modules/beast_core/streams/MemoryOutputStream.h @@ -24,6 +24,9 @@ #ifndef BEAST_MEMORYOUTPUTSTREAM_H_INCLUDED #define BEAST_MEMORYOUTPUTSTREAM_H_INCLUDED +namespace beast +{ + //============================================================================== /** Writes data to an internal memory buffer, which grows as required. @@ -137,4 +140,6 @@ private: /** Copies all the data that has been written to a MemoryOutputStream into another stream. */ OutputStream& BEAST_CALLTYPE operator<< (OutputStream& stream, const MemoryOutputStream& streamToRead); -#endif \ No newline at end of file +} // namespace beast + +#endif diff --git a/src/beast/modules/beast_core/streams/OutputStream.cpp b/src/beast/modules/beast_core/streams/OutputStream.cpp index 26b91d8e02..af70c88dcf 100644 --- a/src/beast/modules/beast_core/streams/OutputStream.cpp +++ b/src/beast/modules/beast_core/streams/OutputStream.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + #if BEAST_DEBUG struct DanglingStreamChecker @@ -431,3 +434,5 @@ BEAST_API OutputStream& BEAST_CALLTYPE operator<< (OutputStream& stream, const S return stream; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/streams/OutputStream.h b/src/beast/modules/beast_core/streams/OutputStream.h index 89ca7ca478..1a35622e95 100644 --- a/src/beast/modules/beast_core/streams/OutputStream.h +++ b/src/beast/modules/beast_core/streams/OutputStream.h @@ -24,6 +24,9 @@ #ifndef BEAST_OUTPUTSTREAM_H_INCLUDED #define BEAST_OUTPUTSTREAM_H_INCLUDED +namespace beast +{ + class InputStream; class MemoryBlock; class File; @@ -296,4 +299,6 @@ BEAST_API OutputStream& BEAST_CALLTYPE operator<< (OutputStream& stream, const N /** Writes a string to an OutputStream as UTF8. */ BEAST_API OutputStream& BEAST_CALLTYPE operator<< (OutputStream& stream, const String& stringToWrite); +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/streams/SubregionStream.cpp b/src/beast/modules/beast_core/streams/SubregionStream.cpp index 158b99a06c..e0d0ffccf6 100644 --- a/src/beast/modules/beast_core/streams/SubregionStream.cpp +++ b/src/beast/modules/beast_core/streams/SubregionStream.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + SubregionStream::SubregionStream (InputStream* const sourceStream, const int64 start, const int64 length, const bool deleteSourceWhenDestroyed) @@ -75,3 +78,5 @@ bool SubregionStream::isExhausted() return source->isExhausted(); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/streams/SubregionStream.h b/src/beast/modules/beast_core/streams/SubregionStream.h index c61cf7fd8a..b423fda13e 100644 --- a/src/beast/modules/beast_core/streams/SubregionStream.h +++ b/src/beast/modules/beast_core/streams/SubregionStream.h @@ -24,6 +24,9 @@ #ifndef BEAST_SUBREGIONSTREAM_H_INCLUDED #define BEAST_SUBREGIONSTREAM_H_INCLUDED +namespace beast +{ + //============================================================================== /** Wraps another input stream, and reads from a specific part of it. @@ -80,4 +83,6 @@ private: const int64 startPositionInSourceStream, lengthOfSourceStream; }; +} // namespace beast + #endif // BEAST_SUBREGIONSTREAM_H_INCLUDED diff --git a/src/beast/modules/beast_core/system/Functional.h b/src/beast/modules/beast_core/system/Functional.h index f8aaba2c33..eed61a9a19 100644 --- a/src/beast/modules/beast_core/system/Functional.h +++ b/src/beast/modules/beast_core/system/Functional.h @@ -20,6 +20,9 @@ #ifndef BEAST_FUNCTIONAL_H_INCLUDED #define BEAST_FUNCTIONAL_H_INCLUDED +namespace beast +{ + //------------------------------------------------------------------------------ /* Brings functional support into our namespace, based on environment. @@ -373,4 +376,6 @@ using namespace placeholders; #endif +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/system/SystemStats.cpp b/src/beast/modules/beast_core/system/SystemStats.cpp index cb600a3697..c9caeddf52 100644 --- a/src/beast/modules/beast_core/system/SystemStats.cpp +++ b/src/beast/modules/beast_core/system/SystemStats.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + String SystemStats::getBeastVersion() { // Some basic tests, to keep an eye on things and make sure these types work ok @@ -158,3 +161,5 @@ void SystemStats::setApplicationCrashHandler (CrashHandlerFunction handler) } #endif } + +} // namespace beast diff --git a/src/beast/modules/beast_core/system/SystemStats.h b/src/beast/modules/beast_core/system/SystemStats.h index 05c447aac3..d0b7682a4d 100644 --- a/src/beast/modules/beast_core/system/SystemStats.h +++ b/src/beast/modules/beast_core/system/SystemStats.h @@ -24,6 +24,9 @@ #ifndef BEAST_SYSTEMSTATS_H_INCLUDED #define BEAST_SYSTEMSTATS_H_INCLUDED +namespace beast +{ + //============================================================================== /** Contains methods for finding out about the current hardware and OS configuration. @@ -177,5 +180,6 @@ private: SystemStats(); }; +} // namespace beast #endif // BEAST_SYSTEMSTATS_H_INCLUDED diff --git a/src/beast/modules/beast_core/text/Identifier.cpp b/src/beast/modules/beast_core/text/Identifier.cpp index f003ad0034..acc1971bcd 100644 --- a/src/beast/modules/beast_core/text/Identifier.cpp +++ b/src/beast/modules/beast_core/text/Identifier.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + StringPool& Identifier::getPool() { static StringPool pool; @@ -67,3 +70,5 @@ bool Identifier::isValidIdentifier (const String& possibleIdentifier) noexcept return possibleIdentifier.isNotEmpty() && possibleIdentifier.containsOnly ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-:#@$%"); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/text/Identifier.h b/src/beast/modules/beast_core/text/Identifier.h index d9bdf7ef89..beb471d82b 100644 --- a/src/beast/modules/beast_core/text/Identifier.h +++ b/src/beast/modules/beast_core/text/Identifier.h @@ -24,6 +24,9 @@ #ifndef BEAST_IDENTIFIER_H_INCLUDED #define BEAST_IDENTIFIER_H_INCLUDED +namespace beast +{ + class StringPool; @@ -102,5 +105,6 @@ private: static StringPool& getPool(); }; +} // namespace beast #endif // BEAST_IDENTIFIER_H_INCLUDED diff --git a/src/beast/modules/beast_core/text/LexicalCast.cpp b/src/beast/modules/beast_core/text/LexicalCast.cpp index 76165bca5c..a074d7712e 100644 --- a/src/beast/modules/beast_core/text/LexicalCast.cpp +++ b/src/beast/modules/beast_core/text/LexicalCast.cpp @@ -17,6 +17,9 @@ */ //============================================================================== +namespace beast +{ + unsigned char const LexicalCastUtilities::s_digitTable [256] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0xFF - 0x07 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x08 - 0x0F @@ -121,3 +124,5 @@ public: }; static LexicalCastTests lexicalCastTests; + +} // namespace beast diff --git a/src/beast/modules/beast_core/text/LexicalCast.h b/src/beast/modules/beast_core/text/LexicalCast.h index 20ac2e58a4..3995191053 100644 --- a/src/beast/modules/beast_core/text/LexicalCast.h +++ b/src/beast/modules/beast_core/text/LexicalCast.h @@ -20,6 +20,9 @@ #ifndef BEAST_LEXICALCAST_H_INCLUDED #define BEAST_LEXICALCAST_H_INCLUDED +namespace beast +{ + // Base class with utility functions struct LexicalCastUtilities { @@ -300,4 +303,6 @@ Out lexicalCast (In in, Out defaultValue = Out ()) return defaultValue; } +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/text/LocalisedStrings.cpp b/src/beast/modules/beast_core/text/LocalisedStrings.cpp index ca734b4780..d39740207f 100644 --- a/src/beast/modules/beast_core/text/LocalisedStrings.cpp +++ b/src/beast/modules/beast_core/text/LocalisedStrings.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + LocalisedStrings::LocalisedStrings (const String& fileContents, bool ignoreCase) { loadFromText (fileContents, ignoreCase); @@ -166,3 +169,5 @@ String translate (const String& text, const String& resultIfNotFound) return resultIfNotFound; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/text/LocalisedStrings.h b/src/beast/modules/beast_core/text/LocalisedStrings.h index be0b0ba43d..ae7c523d0c 100644 --- a/src/beast/modules/beast_core/text/LocalisedStrings.h +++ b/src/beast/modules/beast_core/text/LocalisedStrings.h @@ -24,6 +24,9 @@ #ifndef BEAST_LOCALISEDSTRINGS_H_INCLUDED #define BEAST_LOCALISEDSTRINGS_H_INCLUDED +namespace beast +{ + //============================================================================== /** Used to convert strings to localised foreign-language versions. @@ -215,5 +218,6 @@ String translate (CharPointer_UTF8 stringLiteral); */ String translate (const String& stringLiteral, const String& resultIfNotFound); +} // namespace beast #endif // BEAST_LOCALISEDSTRINGS_H_INCLUDED diff --git a/src/beast/modules/beast_core/text/StringArray.cpp b/src/beast/modules/beast_core/text/StringArray.cpp index 98d34ffd9d..1d74a40ba4 100644 --- a/src/beast/modules/beast_core/text/StringArray.cpp +++ b/src/beast/modules/beast_core/text/StringArray.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + StringArray::StringArray() noexcept { } @@ -508,3 +511,5 @@ void StringArray::minimiseStorageOverheads() { strings.minimiseStorageOverheads(); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/text/StringArray.h b/src/beast/modules/beast_core/text/StringArray.h index 5150784707..c37e24894a 100644 --- a/src/beast/modules/beast_core/text/StringArray.h +++ b/src/beast/modules/beast_core/text/StringArray.h @@ -24,6 +24,9 @@ #ifndef BEAST_STRINGARRAY_H_INCLUDED #define BEAST_STRINGARRAY_H_INCLUDED +namespace beast +{ + //============================================================================== /** A special array for holding a list of strings. @@ -404,5 +407,6 @@ private: Array strings; }; +} // namespace beast #endif // BEAST_STRINGARRAY_H_INCLUDED diff --git a/src/beast/modules/beast_core/text/StringPairArray.cpp b/src/beast/modules/beast_core/text/StringPairArray.cpp index 70084c4def..db1227e170 100644 --- a/src/beast/modules/beast_core/text/StringPairArray.cpp +++ b/src/beast/modules/beast_core/text/StringPairArray.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + StringPairArray::StringPairArray (const bool ignoreCase_) : ignoreCase (ignoreCase_) { @@ -142,3 +145,5 @@ void StringPairArray::minimiseStorageOverheads() keys.minimiseStorageOverheads(); values.minimiseStorageOverheads(); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/text/StringPairArray.h b/src/beast/modules/beast_core/text/StringPairArray.h index 141c552265..7200e12005 100644 --- a/src/beast/modules/beast_core/text/StringPairArray.h +++ b/src/beast/modules/beast_core/text/StringPairArray.h @@ -24,6 +24,9 @@ #ifndef BEAST_STRINGPAIRARRAY_H_INCLUDED #define BEAST_STRINGPAIRARRAY_H_INCLUDED +namespace beast +{ + //============================================================================== /** A container for holding a set of strings which are keyed by another string. @@ -152,5 +155,6 @@ private: bool ignoreCase; }; +} // namespace beast #endif // BEAST_STRINGPAIRARRAY_H_INCLUDED diff --git a/src/beast/modules/beast_core/text/StringPool.cpp b/src/beast/modules/beast_core/text/StringPool.cpp index b86188244f..5e43a2cf15 100644 --- a/src/beast/modules/beast_core/text/StringPool.cpp +++ b/src/beast/modules/beast_core/text/StringPool.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + StringPool::StringPool() noexcept {} StringPool::~StringPool() {} @@ -107,3 +110,5 @@ String::CharPointerType StringPool::operator[] (const int index) const noexcept { return strings [index].getCharPointer(); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/text/StringPool.h b/src/beast/modules/beast_core/text/StringPool.h index aa311c6682..cdd948f601 100644 --- a/src/beast/modules/beast_core/text/StringPool.h +++ b/src/beast/modules/beast_core/text/StringPool.h @@ -24,6 +24,9 @@ #ifndef BEAST_STRINGPOOL_H_INCLUDED #define BEAST_STRINGPOOL_H_INCLUDED +namespace beast +{ + //============================================================================== /** A StringPool holds a set of shared strings, which reduces storage overheads and improves @@ -82,5 +85,6 @@ private: CriticalSection lock; }; +} // namespace beast #endif // BEAST_STRINGPOOL_H_INCLUDED diff --git a/src/beast/modules/beast_core/thread/DeadlineTimer.cpp b/src/beast/modules/beast_core/thread/DeadlineTimer.cpp index 88bbc9e822..f96b77a8b8 100644 --- a/src/beast/modules/beast_core/thread/DeadlineTimer.cpp +++ b/src/beast/modules/beast_core/thread/DeadlineTimer.cpp @@ -17,6 +17,9 @@ */ //============================================================================== +namespace beast +{ + class DeadlineTimer::Manager : public LeakChecked , protected Thread @@ -241,3 +244,5 @@ void DeadlineTimer::setRecurringExpiration (double secondsUntilDeadline) m_manager->activate (*this, secondsUntilDeadline, when); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/thread/DeadlineTimer.h b/src/beast/modules/beast_core/thread/DeadlineTimer.h index e8d8540a65..af4a5f69b2 100644 --- a/src/beast/modules/beast_core/thread/DeadlineTimer.h +++ b/src/beast/modules/beast_core/thread/DeadlineTimer.h @@ -20,6 +20,9 @@ #ifndef BEAST_DEADLINETIMER_H_INCLUDED #define BEAST_DEADLINETIMER_H_INCLUDED +namespace beast +{ + /** Provides periodic or one time notifications at a specified time interval. */ class DeadlineTimer @@ -108,4 +111,6 @@ private: double m_secondsRecurring; // non zero if recurring }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/thread/MutexTraits.h b/src/beast/modules/beast_core/thread/MutexTraits.h index 9de13e042a..b6ec878e98 100644 --- a/src/beast/modules/beast_core/thread/MutexTraits.h +++ b/src/beast/modules/beast_core/thread/MutexTraits.h @@ -20,6 +20,9 @@ #ifndef BEAST_CORE_THREAD_MUTEXTRAITS_H_INCLUDED #define BEAST_CORE_THREAD_MUTEXTRAITS_H_INCLUDED +namespace beast +{ + /** Adapt a Mutex type to meet the boost::Mutex concept requirements. The default implementation assumes adherance to the boost::Mutex concepts, with one important exception. We make the member functions const, for @@ -72,4 +75,6 @@ struct MutexTraits } }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/thread/Workers.cpp b/src/beast/modules/beast_core/thread/Workers.cpp index f6ef90ae39..71cf22f417 100644 --- a/src/beast/modules/beast_core/thread/Workers.cpp +++ b/src/beast/modules/beast_core/thread/Workers.cpp @@ -17,6 +17,9 @@ */ //============================================================================== +namespace beast +{ + Workers::Workers (Callback& callback, String const& threadNames, int numberOfThreads) : m_callback (callback) , m_threadNames (threadNames) @@ -299,3 +302,5 @@ public: }; static WorkersTests workersTests; + +} // namespace beast diff --git a/src/beast/modules/beast_core/thread/Workers.h b/src/beast/modules/beast_core/thread/Workers.h index ff2a31fba8..c09e94d0fb 100644 --- a/src/beast/modules/beast_core/thread/Workers.h +++ b/src/beast/modules/beast_core/thread/Workers.h @@ -20,6 +20,9 @@ #ifndef BEAST_WORKERS_H_INCLUDED #define BEAST_WORKERS_H_INCLUDED +namespace beast +{ + /** A group of threads that process tasks. */ class Workers @@ -143,4 +146,6 @@ private: LockFreeStack m_paused; // holds just paused workers }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/thread/detail/ScopedLock.h b/src/beast/modules/beast_core/thread/detail/ScopedLock.h index e7665f6ddf..4d3dbc0b67 100644 --- a/src/beast/modules/beast_core/thread/detail/ScopedLock.h +++ b/src/beast/modules/beast_core/thread/detail/ScopedLock.h @@ -22,6 +22,9 @@ #include "../MutexTraits.h" +namespace beast +{ + namespace detail { @@ -249,4 +252,6 @@ private: } // namespace detail +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/thread/detail/TrackedMutex.h b/src/beast/modules/beast_core/thread/detail/TrackedMutex.h index cb835c20b9..536a3ff229 100644 --- a/src/beast/modules/beast_core/thread/detail/TrackedMutex.h +++ b/src/beast/modules/beast_core/thread/detail/TrackedMutex.h @@ -20,6 +20,9 @@ #ifndef BEAST_CORE_THREAD_DETAIL_TRACKEDMUTEX_H_INCLUDED #define BEAST_CORE_THREAD_DETAIL_TRACKEDMUTEX_H_INCLUDED +namespace beast +{ + class TrackedMutex; namespace detail @@ -93,4 +96,6 @@ struct TrackedMutexBasics } // namespace detail +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/thread/impl/TrackedMutex.cpp b/src/beast/modules/beast_core/thread/impl/TrackedMutex.cpp index 0978d402a7..502476556f 100644 --- a/src/beast/modules/beast_core/thread/impl/TrackedMutex.cpp +++ b/src/beast/modules/beast_core/thread/impl/TrackedMutex.cpp @@ -17,6 +17,9 @@ */ //============================================================================== +namespace beast +{ + namespace detail { @@ -559,3 +562,4 @@ static TrackedMutexUnitTests trackedMutexUnitTests; } // namespace detail +} // namespace beast diff --git a/src/beast/modules/beast_core/thread/impl/TrackedMutex.h b/src/beast/modules/beast_core/thread/impl/TrackedMutex.h index 30e797f28d..0946d40c75 100644 --- a/src/beast/modules/beast_core/thread/impl/TrackedMutex.h +++ b/src/beast/modules/beast_core/thread/impl/TrackedMutex.h @@ -20,6 +20,9 @@ #ifndef BEAST_CORE_THREAD_IMPL_TRACKEDMUTEX_H_INCLUDED #define BEAST_CORE_THREAD_IMPL_TRACKEDMUTEX_H_INCLUDED +namespace beast +{ + /** Common types and member functions for a TrackedMutex */ class TrackedMutex : public detail::TrackedMutexBasics::ThreadLockList::Node @@ -165,4 +168,6 @@ private: SharedState mutable m_state; }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/thread/impl/TrackedMutexType.h b/src/beast/modules/beast_core/thread/impl/TrackedMutexType.h index 654ffe52b0..5e0528dd25 100644 --- a/src/beast/modules/beast_core/thread/impl/TrackedMutexType.h +++ b/src/beast/modules/beast_core/thread/impl/TrackedMutexType.h @@ -20,6 +20,9 @@ #ifndef BEAST_CORE_THREAD_TRACKEDMUTEXTYPE_H_INCLUDED #define BEAST_CORE_THREAD_TRACKEDMUTEXTYPE_H_INCLUDED +namespace beast +{ + /** A template that gives a Mutex diagnostic tracking capabilities. */ template class TrackedMutexType @@ -92,4 +95,6 @@ private: Mutex const m_mutex; }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/thread/impl/UntrackedMutexType.h b/src/beast/modules/beast_core/thread/impl/UntrackedMutexType.h index 3768bb66a5..22c53d27d5 100644 --- a/src/beast/modules/beast_core/thread/impl/UntrackedMutexType.h +++ b/src/beast/modules/beast_core/thread/impl/UntrackedMutexType.h @@ -20,6 +20,9 @@ #ifndef BEAST_CORE_THREAD_IMPL_UNTRACKEDMUTEX_H_INCLUDED #define BEAST_CORE_THREAD_IMPL_UNTRACKEDMUTEX_H_INCLUDED +namespace beast +{ + /** A drop-in replacement for TrackedMutex without the tracking. */ template @@ -79,4 +82,6 @@ private: Mutex mutable m_mutex; }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/threads/ChildProcess.cpp b/src/beast/modules/beast_core/threads/ChildProcess.cpp index 3aafba1b66..a7a68fe709 100644 --- a/src/beast/modules/beast_core/threads/ChildProcess.cpp +++ b/src/beast/modules/beast_core/threads/ChildProcess.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + ChildProcess::ChildProcess() {} ChildProcess::~ChildProcess() {} @@ -96,3 +99,5 @@ public: }; static ChildProcessTests childProcessTests; + +} // namespace beast diff --git a/src/beast/modules/beast_core/threads/ChildProcess.h b/src/beast/modules/beast_core/threads/ChildProcess.h index 142f34d63c..1561274606 100644 --- a/src/beast/modules/beast_core/threads/ChildProcess.h +++ b/src/beast/modules/beast_core/threads/ChildProcess.h @@ -24,6 +24,8 @@ #ifndef BEAST_CHILDPROCESS_H_INCLUDED #define BEAST_CHILDPROCESS_H_INCLUDED +namespace beast +{ //============================================================================== /** @@ -94,5 +96,6 @@ private: ScopedPointer activeProcess; }; +} // namespace beast #endif // BEAST_CHILDPROCESS_H_INCLUDED diff --git a/src/beast/modules/beast_core/threads/CriticalSection.h b/src/beast/modules/beast_core/threads/CriticalSection.h index a130cb318b..b51003e0bc 100644 --- a/src/beast/modules/beast_core/threads/CriticalSection.h +++ b/src/beast/modules/beast_core/threads/CriticalSection.h @@ -24,6 +24,9 @@ #ifndef BEAST_CRITICALSECTION_H_INCLUDED #define BEAST_CRITICALSECTION_H_INCLUDED +namespace beast +{ + //============================================================================== /** A re-entrant mutex. @@ -252,5 +255,6 @@ typedef CriticalSection::ScopedUnlockType ScopedUnlock; */ typedef CriticalSection::ScopedTryLockType ScopedTryLock; +} // namespace beast #endif // BEAST_CRITICALSECTION_H_INCLUDED diff --git a/src/beast/modules/beast_core/threads/DynamicLibrary.h b/src/beast/modules/beast_core/threads/DynamicLibrary.h index 679195924e..e1bec186ae 100644 --- a/src/beast/modules/beast_core/threads/DynamicLibrary.h +++ b/src/beast/modules/beast_core/threads/DynamicLibrary.h @@ -24,6 +24,9 @@ #ifndef BEAST_DYNAMICLIBRARY_H_INCLUDED #define BEAST_DYNAMICLIBRARY_H_INCLUDED +namespace beast +{ + /** Handles the opening and closing of DLLs. @@ -74,5 +77,6 @@ private: void* handle; }; +} // namespace beast #endif // BEAST_DYNAMICLIBRARY_H_INCLUDED diff --git a/src/beast/modules/beast_core/threads/HighResolutionTimer.cpp b/src/beast/modules/beast_core/threads/HighResolutionTimer.cpp index 68cd34988d..6298bb8831 100644 --- a/src/beast/modules/beast_core/threads/HighResolutionTimer.cpp +++ b/src/beast/modules/beast_core/threads/HighResolutionTimer.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + HighResolutionTimer::HighResolutionTimer() { pimpl = new Pimpl (*this); } HighResolutionTimer::~HighResolutionTimer() { stopTimer(); } @@ -29,3 +32,5 @@ void HighResolutionTimer::stopTimer() { pimpl->stop(); } bool HighResolutionTimer::isTimerRunning() const noexcept { return pimpl->periodMs != 0; } int HighResolutionTimer::getTimerInterval() const noexcept { return pimpl->periodMs; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/threads/HighResolutionTimer.h b/src/beast/modules/beast_core/threads/HighResolutionTimer.h index 9cc391611c..f27ed16270 100644 --- a/src/beast/modules/beast_core/threads/HighResolutionTimer.h +++ b/src/beast/modules/beast_core/threads/HighResolutionTimer.h @@ -24,6 +24,9 @@ #ifndef BEAST_HIGHRESOLUTIONTIMER_H_INCLUDED #define BEAST_HIGHRESOLUTIONTIMER_H_INCLUDED +namespace beast +{ + /** A high-resolution periodic timer. @@ -98,5 +101,6 @@ private: ScopedPointer pimpl; }; +} // namespace beast #endif // BEAST_HIGHRESOLUTIONTIMER_H_INCLUDED diff --git a/src/beast/modules/beast_core/threads/InterProcessLock.h b/src/beast/modules/beast_core/threads/InterProcessLock.h index 412550ce05..a06c5d5685 100644 --- a/src/beast/modules/beast_core/threads/InterProcessLock.h +++ b/src/beast/modules/beast_core/threads/InterProcessLock.h @@ -24,6 +24,9 @@ #ifndef BEAST_INTERPROCESSLOCK_H_INCLUDED #define BEAST_INTERPROCESSLOCK_H_INCLUDED +namespace beast +{ + //============================================================================== /** Acts as a critical section which processes can use to block each other. @@ -114,5 +117,6 @@ private: String name; }; +} // namespace beast #endif // BEAST_INTERPROCESSLOCK_H_INCLUDED diff --git a/src/beast/modules/beast_core/threads/Process.h b/src/beast/modules/beast_core/threads/Process.h index d49bd27d7a..ef6e242f8c 100644 --- a/src/beast/modules/beast_core/threads/Process.h +++ b/src/beast/modules/beast_core/threads/Process.h @@ -24,6 +24,9 @@ #ifndef BEAST_PROCESS_H_INCLUDED #define BEAST_PROCESS_H_INCLUDED +namespace beast +{ + //============================================================================== /** Represents the current executable's process. @@ -137,5 +140,6 @@ private: Process(); }; +} // namespace beast #endif // BEAST_PROCESS_H_INCLUDED diff --git a/src/beast/modules/beast_core/threads/ScopedLock.h b/src/beast/modules/beast_core/threads/ScopedLock.h index e30d68efe5..c0b7ec02c5 100644 --- a/src/beast/modules/beast_core/threads/ScopedLock.h +++ b/src/beast/modules/beast_core/threads/ScopedLock.h @@ -24,6 +24,9 @@ #ifndef BEAST_SCOPEDLOCK_H_INCLUDED #define BEAST_SCOPEDLOCK_H_INCLUDED +namespace beast +{ + //============================================================================== /** Automatically locks and unlocks a mutex object. @@ -240,5 +243,7 @@ private: const bool lockWasSuccessful; }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/threads/SpinDelay.cpp b/src/beast/modules/beast_core/threads/SpinDelay.cpp index 959dc42f60..51ae11794f 100644 --- a/src/beast/modules/beast_core/threads/SpinDelay.cpp +++ b/src/beast/modules/beast_core/threads/SpinDelay.cpp @@ -17,6 +17,9 @@ */ //============================================================================== +namespace beast +{ + SpinDelay::SpinDelay () : m_count (0) { @@ -27,3 +30,5 @@ void SpinDelay::pause () if (++m_count > 20) Thread::yield (); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/threads/SpinDelay.h b/src/beast/modules/beast_core/threads/SpinDelay.h index 4965445ed0..8930c9f04f 100644 --- a/src/beast/modules/beast_core/threads/SpinDelay.h +++ b/src/beast/modules/beast_core/threads/SpinDelay.h @@ -20,6 +20,9 @@ #ifndef BEAST_SPINDELAY_H_INCLUDED #define BEAST_SPINDELAY_H_INCLUDED +namespace beast +{ + /** A simple delay used to synchronize threads. */ class BEAST_API SpinDelay @@ -33,4 +36,6 @@ private: int m_count; }; +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/time/AtExitHook.cpp b/src/beast/modules/beast_core/time/AtExitHook.cpp index e983b7f28d..b6d5a3fa2d 100644 --- a/src/beast/modules/beast_core/time/AtExitHook.cpp +++ b/src/beast/modules/beast_core/time/AtExitHook.cpp @@ -17,6 +17,9 @@ */ //============================================================================== +namespace beast +{ + // Manages the list of hooks, and calls // whoever is in the list at exit time. // @@ -133,3 +136,5 @@ AtExitHook::~AtExitHook () { Manager::get().erase (m_item); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/time/AtExitHook.h b/src/beast/modules/beast_core/time/AtExitHook.h index 26801d23d9..703e1733c0 100644 --- a/src/beast/modules/beast_core/time/AtExitHook.h +++ b/src/beast/modules/beast_core/time/AtExitHook.h @@ -20,6 +20,9 @@ #ifndef BEAST_CORE_ATEXITHOOK_H_INCLUDED #define BEAST_CORE_ATEXITHOOK_H_INCLUDED +namespace beast +{ + /** Hook for performing activity on program exit. These hooks execute when objects with static storage duration are @@ -85,4 +88,6 @@ private: }; /** @} */ +} // namespace beast + #endif diff --git a/src/beast/modules/beast_core/time/PerformanceCounter.cpp b/src/beast/modules/beast_core/time/PerformanceCounter.cpp index 6231e11b1e..3781df0c71 100644 --- a/src/beast/modules/beast_core/time/PerformanceCounter.cpp +++ b/src/beast/modules/beast_core/time/PerformanceCounter.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + PerformanceCounter::PerformanceCounter (const String& name_, const int runsPerPrintout, const File& loggingFile) @@ -88,3 +91,5 @@ void PerformanceCounter::printStatistics() totalTime = 0; } } + +} // namespace beast diff --git a/src/beast/modules/beast_core/time/PerformanceCounter.h b/src/beast/modules/beast_core/time/PerformanceCounter.h index 504dd2f126..f726c6bf10 100644 --- a/src/beast/modules/beast_core/time/PerformanceCounter.h +++ b/src/beast/modules/beast_core/time/PerformanceCounter.h @@ -24,6 +24,9 @@ #ifndef BEAST_PERFORMANCECOUNTER_H_INCLUDED #define BEAST_PERFORMANCECOUNTER_H_INCLUDED +namespace beast +{ + //============================================================================== /** A timer for measuring performance of code and dumping the results to a file. @@ -98,4 +101,6 @@ private: File outputFile; }; +} // namespace beast + #endif // BEAST_PERFORMANCECOUNTER_H_INCLUDED diff --git a/src/beast/modules/beast_core/time/Time.cpp b/src/beast/modules/beast_core/time/Time.cpp index c84c98eaf6..c6437fbafe 100644 --- a/src/beast/modules/beast_core/time/Time.cpp +++ b/src/beast/modules/beast_core/time/Time.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + namespace TimeHelpers { static struct tm millisToLocal (const int64 millis) noexcept @@ -439,3 +442,5 @@ bool operator< (Time time1, Time time2) { return time1.toMilliseconds() < bool operator> (Time time1, Time time2) { return time1.toMilliseconds() > time2.toMilliseconds(); } bool operator<= (Time time1, Time time2) { return time1.toMilliseconds() <= time2.toMilliseconds(); } bool operator>= (Time time1, Time time2) { return time1.toMilliseconds() >= time2.toMilliseconds(); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/time/Time.h b/src/beast/modules/beast_core/time/Time.h index 9628333f8f..5c40698e7c 100644 --- a/src/beast/modules/beast_core/time/Time.h +++ b/src/beast/modules/beast_core/time/Time.h @@ -24,6 +24,9 @@ #ifndef BEAST_TIME_H_INCLUDED #define BEAST_TIME_H_INCLUDED +namespace beast +{ + //============================================================================== /** Holds an absolute date and time. @@ -409,5 +412,6 @@ BEAST_API bool operator> (Time time1, Time time2); /** Compares two Time objects. */ BEAST_API bool operator>= (Time time1, Time time2); +} // namespace beast #endif // BEAST_TIME_H_INCLUDED diff --git a/src/beast/modules/beast_core/xml/XmlDocument.cpp b/src/beast/modules/beast_core/xml/XmlDocument.cpp index 9e2db7496a..f6d79440c9 100644 --- a/src/beast/modules/beast_core/xml/XmlDocument.cpp +++ b/src/beast/modules/beast_core/xml/XmlDocument.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + XmlDocument::XmlDocument (const String& documentText) : originalText (documentText), input (nullptr), @@ -868,4 +871,6 @@ String XmlDocument::getParameterEntity (const String& entity) } return entity; -} \ No newline at end of file +} + +} // namespace beast diff --git a/src/beast/modules/beast_core/xml/XmlDocument.h b/src/beast/modules/beast_core/xml/XmlDocument.h index 5e9a85692b..6317b45e0d 100644 --- a/src/beast/modules/beast_core/xml/XmlDocument.h +++ b/src/beast/modules/beast_core/xml/XmlDocument.h @@ -24,6 +24,9 @@ #ifndef BEAST_XMLDOCUMENT_H_INCLUDED #define BEAST_XMLDOCUMENT_H_INCLUDED +namespace beast +{ + //============================================================================== /** Parses a text-based XML document and creates an XmlElement object from it. @@ -169,5 +172,6 @@ private: ScopedPointer inputSource; }; -#endif +} // namespace beast +#endif diff --git a/src/beast/modules/beast_core/xml/XmlElement.cpp b/src/beast/modules/beast_core/xml/XmlElement.cpp index cfa5de5a28..5aab136679 100644 --- a/src/beast/modules/beast_core/xml/XmlElement.cpp +++ b/src/beast/modules/beast_core/xml/XmlElement.cpp @@ -21,6 +21,9 @@ */ //============================================================================== +namespace beast +{ + XmlElement::XmlAttributeNode::XmlAttributeNode (const XmlAttributeNode& other) noexcept : name (other.name), value (other.value) @@ -819,3 +822,5 @@ void XmlElement::deleteAllTextElements() noexcept child = next; } } + +} // namespace beast diff --git a/src/beast/modules/beast_core/xml/XmlElement.h b/src/beast/modules/beast_core/xml/XmlElement.h index 4875d69832..34de5227a1 100644 --- a/src/beast/modules/beast_core/xml/XmlElement.h +++ b/src/beast/modules/beast_core/xml/XmlElement.h @@ -24,6 +24,9 @@ #ifndef BEAST_XMLELEMENT_H_INCLUDED #define BEAST_XMLELEMENT_H_INCLUDED +namespace beast +{ + //============================================================================== /** A handy macro to make it easy to iterate all the child elements in an XmlElement. @@ -722,5 +725,6 @@ private: void reorderChildElements (XmlElement**, int) noexcept; }; +} // namespace beast #endif // BEAST_XMLELEMENT_H_INCLUDED diff --git a/src/beast/modules/beast_core/zip/GZIPCompressorOutputStream.cpp b/src/beast/modules/beast_core/zip/GZIPCompressorOutputStream.cpp index 683133d79b..c3583ced4b 100644 --- a/src/beast/modules/beast_core/zip/GZIPCompressorOutputStream.cpp +++ b/src/beast/modules/beast_core/zip/GZIPCompressorOutputStream.cpp @@ -26,6 +26,9 @@ ============================================================================== */ +namespace beast +{ + class GZIPCompressorOutputStream::GZIPCompressorHelper : public Uncopyable { public: @@ -206,3 +209,5 @@ public: }; static GZIPTests gzipTests; + +} // namespace beast diff --git a/src/beast/modules/beast_core/zip/GZIPCompressorOutputStream.h b/src/beast/modules/beast_core/zip/GZIPCompressorOutputStream.h index 88a0e25cef..c14c759c23 100644 --- a/src/beast/modules/beast_core/zip/GZIPCompressorOutputStream.h +++ b/src/beast/modules/beast_core/zip/GZIPCompressorOutputStream.h @@ -29,6 +29,9 @@ #ifndef BEAST_GZIPCOMPRESSOROUTPUTSTREAM_H_INCLUDED #define BEAST_GZIPCOMPRESSOROUTPUTSTREAM_H_INCLUDED +namespace beast +{ + //============================================================================== /** A stream which uses zlib to compress the data written into it. @@ -97,4 +100,6 @@ private: ScopedPointer helper; }; +} // namespace beast + #endif // BEAST_GZIPCOMPRESSOROUTPUTSTREAM_H_INCLUDED diff --git a/src/beast/modules/beast_core/zip/GZIPDecompressorInputStream.cpp b/src/beast/modules/beast_core/zip/GZIPDecompressorInputStream.cpp index b044649714..b10eb42a74 100644 --- a/src/beast/modules/beast_core/zip/GZIPDecompressorInputStream.cpp +++ b/src/beast/modules/beast_core/zip/GZIPDecompressorInputStream.cpp @@ -26,6 +26,9 @@ ============================================================================== */ +namespace beast +{ + #if BEAST_MSVC #pragma warning (push) #pragma warning (disable: 4309 4305 4365) @@ -290,3 +293,5 @@ unsigned long beast_crc32 (unsigned long crc, const unsigned char* buf, unsigned { return zlibNamespace::crc32 (crc, buf, len); } + +} // namespace beast diff --git a/src/beast/modules/beast_core/zip/GZIPDecompressorInputStream.h b/src/beast/modules/beast_core/zip/GZIPDecompressorInputStream.h index 14a525f394..904c0de270 100644 --- a/src/beast/modules/beast_core/zip/GZIPDecompressorInputStream.h +++ b/src/beast/modules/beast_core/zip/GZIPDecompressorInputStream.h @@ -29,6 +29,9 @@ #ifndef BEAST_GZIPDECOMPRESSORINPUTSTREAM_H_INCLUDED #define BEAST_GZIPDECOMPRESSORINPUTSTREAM_H_INCLUDED +namespace beast +{ + //============================================================================== /** This stream will decompress a source-stream using zlib. @@ -94,4 +97,6 @@ private: ScopedPointer helper; }; +} // namespace beast + #endif // BEAST_GZIPDECOMPRESSORINPUTSTREAM_H_INCLUDED diff --git a/src/beast/modules/beast_core/zip/ZipFile.cpp b/src/beast/modules/beast_core/zip/ZipFile.cpp index bc3c6f0b4f..3bc341ff98 100644 --- a/src/beast/modules/beast_core/zip/ZipFile.cpp +++ b/src/beast/modules/beast_core/zip/ZipFile.cpp @@ -26,6 +26,9 @@ ============================================================================== */ +namespace beast +{ + class ZipFile::ZipEntryHolder { public: @@ -593,3 +596,5 @@ bool ZipFile::Builder::writeToStream (OutputStream& target, double* const progre return true; } + +} // namespace beast diff --git a/src/beast/modules/beast_core/zip/ZipFile.h b/src/beast/modules/beast_core/zip/ZipFile.h index 7fd08b10be..078beab4c0 100644 --- a/src/beast/modules/beast_core/zip/ZipFile.h +++ b/src/beast/modules/beast_core/zip/ZipFile.h @@ -29,6 +29,9 @@ #ifndef BEAST_ZIPFILE_H_INCLUDED #define BEAST_ZIPFILE_H_INCLUDED +namespace beast +{ + //============================================================================== /** Decodes a ZIP file from a stream. @@ -236,4 +239,6 @@ private: void init(); }; +} // namespace beast + #endif // BEAST_ZIPFILE_H_INCLUDED diff --git a/src/ripple/common/KeyCache.h b/src/ripple/common/KeyCache.h index 1a333d6e7e..28e006cf08 100644 --- a/src/ripple/common/KeyCache.h +++ b/src/ripple/common/KeyCache.h @@ -48,14 +48,14 @@ class KeyCache { public: typedef Key key_type; - typedef abstract_clock clock_type; + typedef beast::abstract_clock clock_type; private: struct Stats { template Stats (std::string const& prefix, Handler const& handler, - insight::Collector::ptr const& collector) + beast::insight::Collector::ptr const& collector) : hook (collector->make_hook (handler)) , size (collector->make_gauge (prefix, "size")) , hit_rate (collector->make_gauge (prefix, "hit_rate")) @@ -63,9 +63,9 @@ private: , misses (0) { } - insight::Hook hook; - insight::Gauge size; - insight::Gauge hit_rate; + beast::insight::Hook hook; + beast::insight::Gauge size; + beast::insight::Gauge hit_rate; std::size_t hits; std::size_t misses; @@ -102,7 +102,7 @@ public: @param age The initial expiration time. */ KeyCache (std::string const& name, clock_type& clock, - insight::Collector::ptr const& collector, size_type target_size = 0, + beast::insight::Collector::ptr const& collector, size_type target_size = 0, clock_type::rep expiration_seconds = 120) : m_stats (name, std::bind (&KeyCache::collect_metrics, this), @@ -120,7 +120,7 @@ public: size_type target_size = 0, clock_type::rep expiration_seconds = 120) : m_stats (name, std::bind (&KeyCache::collect_metrics, this), - insight::NullCollector::New ()) + beast::insight::NullCollector::New ()) , m_clock (clock) , m_name (name) , m_target_size (target_size) @@ -289,7 +289,7 @@ private: m_stats.size.set (size ()); { - insight::Gauge::value_type hit_rate (0); + beast::insight::Gauge::value_type hit_rate (0); { lock_guard lock (m_mutex); auto const total (m_stats.hits + m_stats.misses); diff --git a/src/ripple/common/TaggedCache.h b/src/ripple/common/TaggedCache.h index fded04dadc..40b7b876f4 100644 --- a/src/ripple/common/TaggedCache.h +++ b/src/ripple/common/TaggedCache.h @@ -65,13 +65,13 @@ public: // VFALCO TODO Use std::shared_ptr, std::weak_ptr typedef boost::weak_ptr weak_mapped_ptr; typedef boost::shared_ptr mapped_ptr; - typedef abstract_clock clock_type; + typedef beast::abstract_clock clock_type; public: // VFALCO TODO Change expiration_seconds to clock_type::duration TaggedCache (std::string const& name, int size, - clock_type::rep expiration_seconds, clock_type& clock, Journal journal, - insight::Collector::ptr const& collector = insight::NullCollector::New ()) + clock_type::rep expiration_seconds, clock_type& clock, beast::Journal journal, + beast::insight::Collector::ptr const& collector = beast::insight::NullCollector::New ()) : m_journal (journal) , m_clock (clock) , m_stats (name, @@ -473,7 +473,7 @@ private: m_stats.size.set (getCacheSize ()); { - insight::Gauge::value_type hit_rate (0); + beast::insight::Gauge::value_type hit_rate (0); { lock_guard lock (m_mutex); auto const total (m_hits + m_misses); @@ -489,15 +489,15 @@ private: { template Stats (std::string const& prefix, Handler const& handler, - insight::Collector::ptr const& collector) + beast::insight::Collector::ptr const& collector) : hook (collector->make_hook (handler)) , size (collector->make_gauge (prefix, "size")) , hit_rate (collector->make_gauge (prefix, "hit_rate")) { } - insight::Hook hook; - insight::Gauge size; - insight::Gauge hit_rate; + beast::insight::Hook hook; + beast::insight::Gauge size; + beast::insight::Gauge hit_rate; }; class Entry @@ -526,7 +526,7 @@ private: typedef std::unordered_map cache_type; typedef typename cache_type::iterator cache_iterator; - Journal m_journal; + beast::Journal m_journal; clock_type& m_clock; Stats m_stats; @@ -544,8 +544,8 @@ private: // Number of items cached int m_cache_count; cache_type m_cache; // Hold strong reference to recent objects - uint64 m_hits; - uint64 m_misses; + beast::uint64 m_hits; + beast::uint64 m_misses; }; } diff --git a/src/ripple/common/impl/KeyCache.cpp b/src/ripple/common/impl/KeyCache.cpp index 4de523a45b..4484bb2077 100644 --- a/src/ripple/common/impl/KeyCache.cpp +++ b/src/ripple/common/impl/KeyCache.cpp @@ -21,14 +21,14 @@ namespace ripple { -class KeyCacheTests : public UnitTest +class KeyCacheTests : public beast::UnitTest { public: void runTest () { beginTestCase ("Insert"); - manual_clock clock; + beast::manual_clock clock; clock.set (0); typedef std::string Key; diff --git a/src/ripple/common/impl/MultiSocketType.h b/src/ripple/common/impl/MultiSocketType.h index 372c3387b5..ac91d3ab65 100644 --- a/src/ripple/common/impl/MultiSocketType.h +++ b/src/ripple/common/impl/MultiSocketType.h @@ -56,8 +56,11 @@ private: State m_state; boost::asio::ssl::context& m_ssl_context; int m_verify_mode; - std::unique_ptr m_stream; - std::unique_ptr m_ssl_stream; // the ssl portion of our stream if it exists + std::unique_ptr < + beast::asio::abstract_socket> m_stream; + std::unique_ptr < + beast::asio::abstract_socket + > m_ssl_stream; // the ssl portion of our stream if it exists bool m_needsShutdown; StreamSocket m_next_layer; ProxyInfo m_proxyInfo; @@ -73,7 +76,8 @@ public: typedef typename next_layer_type::lowest_layer_type lowest_layer_type; template - MultiSocketType (Arg& arg, boost::asio::ssl::context& ssl_context, int flags) + MultiSocketType (Arg& arg, + boost::asio::ssl::context& ssl_context, int flags) : m_flags (flags) , m_state (stateNone) , m_ssl_context (ssl_context) @@ -97,25 +101,28 @@ protected: // //-------------------------------------------------------------------------- - Flag getFlags () override + Flag + getFlags () override { return m_origFlags; } - beast::IP::Endpoint local_endpoint() override + beast::IP::Endpoint + local_endpoint() override { - return IPAddressConversion::from_asio ( + return beast::IPAddressConversion::from_asio ( m_next_layer.local_endpoint()); } - beast::IP::Endpoint remote_endpoint() override + beast::IP::Endpoint + remote_endpoint() override { if (m_proxyInfoSet) { if (m_proxyInfo.protocol == "TCP4") { - return IP::Endpoint ( - IP::AddressV4 ( + return beast::IP::Endpoint ( + beast::IP::AddressV4 ( m_proxyInfo.destAddress.value [0], m_proxyInfo.destAddress.value [1], m_proxyInfo.destAddress.value [2], @@ -125,26 +132,28 @@ protected: // VFALCO TODO IPv6 support bassertfalse; - return IP::Endpoint(); + return beast::IP::Endpoint(); } try { - return IPAddressConversion::from_asio ( + return beast::IPAddressConversion::from_asio ( m_next_layer.remote_endpoint()); } catch (...) { - return IP::Endpoint (); + return beast::IP::Endpoint (); } } - ProxyInfo getProxyInfo () override + ProxyInfo + getProxyInfo () override { return m_proxyInfo; } - SSL* ssl_handle () override + SSL* + ssl_handle () override { return m_native_ssl_handle; } @@ -177,7 +186,8 @@ protected: { char const* const name (typeid (next_layer_type).name ()); if (strcmp (name, type_name) == 0) - return const_cast (static_cast (&m_next_layer)); + return const_cast ( + static_cast (&m_next_layer)); return nullptr; } @@ -220,7 +230,8 @@ protected: return m_next_layer.lowest_layer ().cancel (ec); } - error_code shutdown (abstract_socket::shutdown_type what, error_code& ec) override + error_code shutdown (abstract_socket::shutdown_type what, + error_code& ec) override { return m_next_layer.lowest_layer ().shutdown (what, ec); } @@ -274,7 +285,8 @@ protected: { char const* const name (typeid (next_layer_type).name ()); if (strcmp (name, type_name) == 0) - return const_cast (static_cast (&m_next_layer)); + return const_cast ( + static_cast (&m_next_layer)); return nullptr; } @@ -375,7 +387,8 @@ protected: static Flag cleaned_flags (Flag flags) { // Can't set both client and server - check_precondition (! flags.set (Flag::client_role | Flag::server_role)); + check_precondition (! flags.set ( + Flag::client_role | Flag::server_role)); if (flags.set (Flag::client_role)) { @@ -740,8 +753,8 @@ protected: case stateExpectPROXY: { - typedef beast::asio::HandshakeDetectorType < - next_layer_type, beast::asio::HandshakeDetectLogicPROXY> op_type; + typedef beast::asio::HandshakeDetectorType op_type; op_type op; @@ -775,8 +788,8 @@ protected: case stateDetectSSL: { - typedef beast::asio::HandshakeDetectorType < - next_layer_type, beast::asio::HandshakeDetectLogicSSL3> op_type; + typedef beast::asio::HandshakeDetectorType op_type; op_type op; @@ -790,7 +803,8 @@ protected: if (op.getLogic ().success ()) { // Convert the ssl flag to ssl_required - m_flags = m_flags.with (Flag::ssl_required).without (Flag::ssl); + m_flags = m_flags.with ( + Flag::ssl_required).without (Flag::ssl); } else { @@ -912,7 +926,7 @@ protected: // We can't use io_service::wrap because that calls dispatch // instead of post. // - m_owner.get_io_service().post (asio::wrap_handler ( + m_owner.get_io_service().post (beast::asio::wrap_handler ( std::bind (&AsyncOp::on_final, this->shared_from_this(), ec), m_handler)); } @@ -953,9 +967,10 @@ protected: // m_owner.m_state = stateReady; m_owner.stream ().async_handshake (m_type, - asio::wrap_handler (std::bind (&AsyncOp::on_complete, - this->shared_from_this(), beast::asio::placeholders::error), - m_handler, m_first_time)); + beast::asio::wrap_handler (std::bind ( + &AsyncOp::on_complete, this->shared_from_this(), + beast::asio::placeholders::error), + m_handler, m_first_time)); } return; @@ -965,14 +980,18 @@ protected: { if (m_proxy.getLogic ().success ()) { - m_owner.m_proxyInfo = m_proxy.getLogic ().getInfo (); + m_owner.m_proxyInfo = + m_proxy.getLogic ().getInfo (); m_owner.m_proxyInfoSet = true; // Strip off the PROXY flag. - m_owner.m_flags = m_owner.m_flags.without (Flag::proxy); + m_owner.m_flags = m_owner.m_flags.without ( + Flag::proxy); - // Update handshake state with the leftover bytes. - ec = m_owner.initHandshake (m_type, m_buffer.data ()); + // Update handshake state with the + // leftover bytes. + ec = m_owner.initHandshake (m_type, + m_buffer.data ()); break; } @@ -981,9 +1000,11 @@ protected: break; } - m_proxy.async_detect (m_stream, m_buffer, asio::wrap_handler ( - std::bind (&AsyncOp::on_complete, this->shared_from_this(), - beast::asio::placeholders::error), m_handler, m_first_time)); + m_proxy.async_detect (m_stream, m_buffer, + beast::asio::wrap_handler (std::bind ( + &AsyncOp::on_complete, this->shared_from_this(), + beast::asio::placeholders::error), + m_handler, m_first_time)); } return; @@ -1001,17 +1022,21 @@ protected: else { // Not SSL, strip the ssl flag - m_owner.m_flags = m_owner.m_flags.without (Flag::ssl); + m_owner.m_flags = m_owner.m_flags.without ( + Flag::ssl); } // Update handshake state with the leftover bytes. - ec = m_owner.initHandshake (m_type, m_buffer.data ()); + ec = m_owner.initHandshake (m_type, + m_buffer.data ()); break; } - m_ssl.async_detect (m_stream, m_buffer, asio::wrap_handler ( - std::bind (&AsyncOp::on_complete, this->shared_from_this(), - beast::asio::placeholders::error), m_handler, m_first_time)); + m_ssl.async_detect (m_stream, m_buffer, + beast::asio::wrap_handler (std::bind ( + &AsyncOp::on_complete, this->shared_from_this(), + beast::asio::placeholders::error), + m_handler, m_first_time)); } return; @@ -1024,7 +1049,8 @@ protected: } } - bassert (ec || (m_owner.m_state == stateReady && m_owner.m_needsShutdown)); + bassert (ec || (m_owner.m_state == stateReady && + m_owner.m_needsShutdown)); on_final (ec); } diff --git a/src/ripple/common/impl/ResolverAsio.cpp b/src/ripple/common/impl/ResolverAsio.cpp index 3fde574f72..960612cbf8 100644 --- a/src/ripple/common/impl/ResolverAsio.cpp +++ b/src/ripple/common/impl/ResolverAsio.cpp @@ -36,13 +36,13 @@ class ResolverAsioImpl public: typedef std::pair HostAndPort; - Journal m_journal; + beast::Journal m_journal; boost::asio::io_service& m_io_service; boost::asio::io_service::strand m_strand; boost::asio::ip::tcp::resolver m_resolver; - WaitableEvent m_stop_complete; + beast::WaitableEvent m_stop_complete; std::atomic m_stop_called; std::atomic m_stopped; @@ -66,7 +66,7 @@ public: std::deque m_work; ResolverAsioImpl (boost::asio::io_service& io_service, - Journal journal) + beast::Journal journal) : m_journal (journal) , m_io_service (io_service) , m_strand (io_service) @@ -171,7 +171,7 @@ public: if (ec == boost::asio::error::operation_aborted) return; - std::vector addresses; + std::vector addresses; // If we get an error message back, we don't return any // results that we may have gotten. @@ -179,7 +179,7 @@ public: { while (iter != boost::asio::ip::tcp::resolver::iterator()) { - addresses.push_back (IPAddressConversion::from_asio (*iter)); + addresses.push_back (beast::IPAddressConversion::from_asio (*iter)); ++iter; } } diff --git a/src/ripple/common/impl/RippleSSLContext.cpp b/src/ripple/common/impl/RippleSSLContext.cpp index 0efd0e04d0..93f5dec1b4 100644 --- a/src/ripple/common/impl/RippleSSLContext.cpp +++ b/src/ripple/common/impl/RippleSSLContext.cpp @@ -168,7 +168,7 @@ public: { for (;;) { - X509* const x = PEM_read_X509 (f, NULL, NULL, NULL); + X509* const x = PEM_read_X509 (f, nullptr, nullptr, nullptr); if (x == nullptr) break; @@ -295,25 +295,20 @@ RippleSSLContext::RippleSSLContext (ContextType& context) RippleSSLContext* RippleSSLContext::createBare () { std::unique_ptr context (new RippleSSLContextImp ()); - return context.release (); } RippleSSLContext* RippleSSLContext::createWebSocket () { std::unique_ptr context (new RippleSSLContextImp ()); - context->initCommon (); - return context.release (); } RippleSSLContext* RippleSSLContext::createAnonymous (std::string const& cipherList) { std::unique_ptr context (new RippleSSLContextImp ()); - context->initAnonymous (cipherList); - return context.release (); } @@ -321,9 +316,7 @@ RippleSSLContext* RippleSSLContext::createAuthenticated ( std::string key_file, std::string cert_file, std::string chain_file) { std::unique_ptr context (new RippleSSLContextImp ()); - context->initAuthenticated (key_file, cert_file, chain_file); - return context.release (); } diff --git a/src/ripple/common/impl/TaggedCache.cpp b/src/ripple/common/impl/TaggedCache.cpp index 5c303e393d..286ef16ec9 100644 --- a/src/ripple/common/impl/TaggedCache.cpp +++ b/src/ripple/common/impl/TaggedCache.cpp @@ -31,17 +31,17 @@ then canonicalize a new object with the same key, make sure you get the original object. */ -class TaggedCacheTests : public UnitTest +class TaggedCacheTests : public beast::UnitTest { public: void runTest () { //Journal const j (journal()); - Journal const j; + beast::Journal const j; beginTestCase ("Insert"); - manual_clock clock; + beast::manual_clock clock; clock.set (0); typedef int Key; diff --git a/src/ripple/common/impl/counted_bind.cpp b/src/ripple/common/impl/counted_bind.cpp index 9ebcc718f6..37a4e3f303 100644 --- a/src/ripple/common/impl/counted_bind.cpp +++ b/src/ripple/common/impl/counted_bind.cpp @@ -21,12 +21,10 @@ namespace ripple { -using namespace beast; - class TrackedHandler { public: - explicit TrackedHandler (Journal journal) + explicit TrackedHandler (beast::Journal journal) : m_journal (journal) { m_journal.info << "Constructor"; @@ -62,7 +60,7 @@ public: } private: - Journal m_journal; + beast::Journal m_journal; }; //------------------------------------------------------------------------------ @@ -121,14 +119,14 @@ HandlerWrapper < //------------------------------------------------------------------------------ -class CountedBindTests : public UnitTest +class CountedBindTests : public beast::UnitTest { public: void runTest () { beginTestCase ("Move"); - Journal const j (journal()); + beast::Journal const j (journal()); { j.info << "w1"; diff --git a/src/ripple/http/api/Handler.h b/src/ripple/http/api/Handler.h index f067456991..d4155292f4 100644 --- a/src/ripple/http/api/Handler.h +++ b/src/ripple/http/api/Handler.h @@ -21,7 +21,6 @@ #define RIPPLE_HTTP_HANDLER_H_INCLUDED namespace ripple { -using namespace beast; namespace HTTP { @@ -55,7 +54,7 @@ struct Handler virtual void onStopped (Server& server) = 0; }; -} -} +} // namespace HTTP +} // namespace ripple #endif diff --git a/src/ripple/http/api/Port.h b/src/ripple/http/api/Port.h index 11ab62339b..6b610876ae 100644 --- a/src/ripple/http/api/Port.h +++ b/src/ripple/http/api/Port.h @@ -21,7 +21,6 @@ #define RIPPLE_HTTP_PORT_H_INCLUDED namespace ripple { -using namespace beast; namespace HTTP { @@ -38,11 +37,11 @@ struct Port Port (); Port (Port const& other); Port& operator= (Port const& other); - Port (uint16 port_, IP::Endpoint const& addr_, + Port (beast::uint16 port_, beast::IP::Endpoint const& addr_, Security security_, beast::asio::SSLContext* context_); - uint16 port; - IP::Endpoint addr; + beast::uint16 port; + beast::IP::Endpoint addr; Security security; beast::asio::SSLContext* context; }; @@ -57,7 +56,7 @@ bool operator>= (Port const& lhs, Port const& rhs); /** A set of listening ports settings. */ typedef std::vector Ports; -} -} +} // namespace HTTP +} // namespace ripple #endif diff --git a/src/ripple/http/api/ScopedStream.h b/src/ripple/http/api/ScopedStream.h index f21049f1e4..fdeb088f40 100644 --- a/src/ripple/http/api/ScopedStream.h +++ b/src/ripple/http/api/ScopedStream.h @@ -23,7 +23,6 @@ #include namespace ripple { -using namespace beast; namespace HTTP { @@ -64,7 +63,7 @@ private: std::ostringstream mutable m_ostream; }; -} -} +} // namespace HTTP +} // namespace ripple #endif diff --git a/src/ripple/http/api/Server.h b/src/ripple/http/api/Server.h index f4c8b6a66c..a657d414e9 100644 --- a/src/ripple/http/api/Server.h +++ b/src/ripple/http/api/Server.h @@ -24,7 +24,6 @@ #include namespace ripple { -using namespace beast; namespace HTTP { @@ -35,7 +34,7 @@ class Server { public: /** Create the server using the specified handler. */ - Server (Handler& handler, Journal journal); + Server (Handler& handler, beast::Journal journal); /** Destroy the server. This blocks until the server stops. @@ -43,7 +42,7 @@ public: virtual ~Server (); /** Returns the Journal associated with the server. */ - Journal const& journal () const; + beast::Journal const& journal () const; /** Returns the listening ports settings. Thread safety: @@ -78,7 +77,7 @@ private: std::unique_ptr m_impl; }; -} -} +} // namespace HTTP +} // namespace ripple #endif diff --git a/src/ripple/http/api/Session.h b/src/ripple/http/api/Session.h index 26b01ea7a8..cb80e41b4d 100644 --- a/src/ripple/http/api/Session.h +++ b/src/ripple/http/api/Session.h @@ -23,7 +23,6 @@ #include namespace ripple { -using namespace beast; namespace HTTP { @@ -32,7 +31,7 @@ namespace HTTP { Some fields are input parameters, some are output parameters, and all only become defined during specific callbacks. */ -class Session : public Uncopyable +class Session : public beast::Uncopyable { public: /** A user-definable pointer. @@ -42,19 +41,19 @@ public: void* tag; /** Returns the Journal to use for logging. */ - virtual Journal journal() = 0; + virtual beast::Journal journal() = 0; /** Returns the remote address of the connection. */ - virtual IP::Endpoint remoteAddress() = 0; + virtual beast::IP::Endpoint remoteAddress() = 0; /** Returns `true` if the full HTTP headers have been received. */ virtual bool headersComplete() = 0; /** Returns the currently known set of headers. */ - virtual HTTPHeaders headers() = 0; + virtual beast::HTTPHeaders headers() = 0; /** Returns the complete HTTP request when it is known. */ - virtual SharedPtr const& request() = 0; + virtual beast::SharedPtr const& request() = 0; /** Returns the entire Content-Body, if the request is complete. */ virtual std::string content() = 0; @@ -111,7 +110,7 @@ public: virtual void close() = 0; }; -} -} +} // namespace HTTP +} // ripple #endif diff --git a/src/ripple/http/impl/Door.h b/src/ripple/http/impl/Door.h index a04bf074fa..caf30bd404 100644 --- a/src/ripple/http/impl/Door.h +++ b/src/ripple/http/impl/Door.h @@ -25,13 +25,13 @@ namespace HTTP { /** A listening socket. */ class Door - : public SharedObject + : public beast::SharedObject , public beast::asio::AsyncObject - , public List ::Node - , public LeakChecked + , public beast::List ::Node + , public beast::LeakChecked { public: - typedef SharedPtr Ptr; + typedef beast::SharedPtr Ptr; ServerImpl& m_impl; acceptor m_acceptor; diff --git a/src/ripple/http/impl/Peer.h b/src/ripple/http/impl/Peer.h index 253f0fa4c2..8566458d33 100644 --- a/src/ripple/http/impl/Peer.h +++ b/src/ripple/http/impl/Peer.h @@ -32,11 +32,11 @@ typedef beast::asio::SharedArg SharedBuffer; /** Represents an active connection. */ class Peer - : public SharedObject + : public beast::SharedObject , public beast::asio::AsyncObject , public Session - , public List ::Node - , public LeakChecked + , public beast::List ::Node + , public beast::LeakChecked { public: enum @@ -55,19 +55,19 @@ public: }; - typedef SharedPtr Ptr; + typedef beast::SharedPtr Ptr; ServerImpl& m_impl; boost::asio::io_service::strand m_strand; boost::asio::deadline_timer m_data_timer; boost::asio::deadline_timer m_request_timer; std::unique_ptr m_socket; - MemoryBlock m_buffer; - HTTPRequestParser m_parser; + beast::MemoryBlock m_buffer; + beast::HTTPRequestParser m_parser; int m_writesPending; bool m_closed; bool m_callClose; - SharedPtr m_detach_ref; + beast::SharedPtr m_detach_ref; boost::optional m_work; int m_errorCode; std::atomic m_detached; @@ -117,12 +117,12 @@ public: // Session // - Journal journal() + beast::Journal journal() { return m_impl.journal(); } - IP::Endpoint remoteAddress() + beast::IP::Endpoint remoteAddress() { return from_asio (get_socket().remote_endpoint()); } @@ -132,12 +132,12 @@ public: return m_parser.headersComplete(); } - HTTPHeaders headers() + beast::HTTPHeaders headers() { - return HTTPHeaders (m_parser.fields()); + return beast::HTTPHeaders (m_parser.fields()); } - SharedPtr const& request() + beast::SharedPtr const& request() { return m_parser.request(); } @@ -147,7 +147,7 @@ public: std::string content() { std::string s; - DynamicBuffer const& body ( + beast::DynamicBuffer const& body ( m_parser.request()->body ()); s.resize (body.size ()); boost::asio::buffer_copy ( diff --git a/src/ripple/http/impl/Port.cpp b/src/ripple/http/impl/Port.cpp index 8c6d2c429a..9d27439892 100644 --- a/src/ripple/http/impl/Port.cpp +++ b/src/ripple/http/impl/Port.cpp @@ -45,8 +45,8 @@ Port& Port::operator= (Port const& other) } Port::Port ( - uint16 port_, - IP::Endpoint const& addr_, + beast::uint16 port_, + beast::IP::Endpoint const& addr_, Security security_, beast::asio::SSLContext* context_) : port (port_) diff --git a/src/ripple/http/impl/Server.cpp b/src/ripple/http/impl/Server.cpp index 8da0ac95a0..79a2235f94 100644 --- a/src/ripple/http/impl/Server.cpp +++ b/src/ripple/http/impl/Server.cpp @@ -20,7 +20,7 @@ namespace ripple { namespace HTTP { -Server::Server (Handler& handler, Journal journal) +Server::Server (Handler& handler, beast::Journal journal) : m_impl (new ServerImpl (*this, handler, journal)) { } @@ -30,7 +30,7 @@ Server::~Server () stop(); } -Journal const& Server::journal () const +beast::Journal const& Server::journal () const { return m_impl->journal(); } diff --git a/src/ripple/http/impl/ServerImpl.cpp b/src/ripple/http/impl/ServerImpl.cpp index 0a9d86bfb7..a8a4d3ae5e 100644 --- a/src/ripple/http/impl/ServerImpl.cpp +++ b/src/ripple/http/impl/ServerImpl.cpp @@ -20,7 +20,7 @@ namespace ripple { namespace HTTP { -ServerImpl::ServerImpl (Server& server, Handler& handler, Journal journal) +ServerImpl::ServerImpl (Server& server, Handler& handler, beast::Journal journal) : Thread ("HTTP::Server") , m_server (server) , m_handler (handler) @@ -37,7 +37,7 @@ ServerImpl::~ServerImpl () stopThread (); } -Journal const& ServerImpl::journal() const +beast::Journal const& ServerImpl::journal() const { return m_journal; } diff --git a/src/ripple/http/impl/ServerImpl.h b/src/ripple/http/impl/ServerImpl.h index c8ca4160a4..71e3256c0f 100644 --- a/src/ripple/http/impl/ServerImpl.h +++ b/src/ripple/http/impl/ServerImpl.h @@ -26,7 +26,7 @@ namespace HTTP { class Door; class Peer; -class ServerImpl : public Thread +class ServerImpl : public beast::Thread { public: struct State @@ -35,28 +35,28 @@ public: Ports ports; // All allocated Peer objects - List peers; + beast::List peers; // All allocated Door objects - List doors; + beast::List doors; }; - typedef SharedData SharedState; - typedef std::vector > Doors; + typedef beast::SharedData SharedState; + typedef std::vector > Doors; Server& m_server; Handler& m_handler; - Journal m_journal; + beast::Journal m_journal; boost::asio::io_service m_io_service; boost::asio::io_service::strand m_strand; boost::optional m_work; - WaitableEvent m_stopped; + beast::WaitableEvent m_stopped; SharedState m_state; Doors m_doors; - ServerImpl (Server& server, Handler& handler, Journal journal); + ServerImpl (Server& server, Handler& handler, beast::Journal journal); ~ServerImpl (); - Journal const& journal() const; + beast::Journal const& journal() const; Ports const& getPorts () const; void setPorts (Ports const& ports); bool stopping () const; diff --git a/src/ripple/http/impl/Types.h b/src/ripple/http/impl/Types.h index 9fa70499c6..e404176632 100644 --- a/src/ripple/http/impl/Types.h +++ b/src/ripple/http/impl/Types.h @@ -48,7 +48,7 @@ inline endpoint_t to_asio (Port const& port) { if (port.addr.is_v4()) { - IP::AddressV4 v4 (port.addr.to_v4()); + beast::IP::AddressV4 v4 (port.addr.to_v4()); std::string const& s (to_string (v4)); return endpoint_t (address().from_string (s), port.port); } @@ -57,10 +57,10 @@ inline endpoint_t to_asio (Port const& port) return endpoint_t (); } -inline IP::Endpoint from_asio (endpoint_t const& endpoint) +inline beast::IP::Endpoint from_asio (endpoint_t const& endpoint) { std::stringstream ss (to_string (endpoint)); - IP::Endpoint ep; + beast::IP::Endpoint ep; ss >> ep; return ep; } diff --git a/src/ripple/json/impl/Tests.cpp b/src/ripple/json/impl/Tests.cpp index 0048918284..343aabc86e 100644 --- a/src/ripple/json/impl/Tests.cpp +++ b/src/ripple/json/impl/Tests.cpp @@ -18,9 +18,8 @@ //============================================================================== namespace ripple { -using namespace beast; -class JsonCppTests : public UnitTest +class JsonCppTests : public beast::UnitTest { public: void testBadJson () @@ -50,4 +49,4 @@ public: static JsonCppTests jsonCppTests; -} +} // namespace ripple diff --git a/src/ripple/json/impl/json_writer.cpp b/src/ripple/json/impl/json_writer.cpp index 2dca4aceac..3aef05a515 100644 --- a/src/ripple/json/impl/json_writer.cpp +++ b/src/ripple/json/impl/json_writer.cpp @@ -100,7 +100,7 @@ std::string valueToString ( bool value ) std::string valueToQuotedString ( const char* value ) { // Not sure how to handle unicode... - if (strpbrk (value, "\"\\\b\f\n\r\t") == NULL && !containsControlCharacter ( value )) + if (strpbrk (value, "\"\\\b\f\n\r\t") == nullptr && !containsControlCharacter ( value )) return std::string ("\"") + value + "\""; // We have to walk value and escape any special characters. @@ -591,7 +591,7 @@ StyledWriter::normalizeEOL ( const std::string& text ) // ////////////////////////////////////////////////////////////////// StyledStreamWriter::StyledStreamWriter ( std::string indentation ) - : document_ (NULL) + : document_ (nullptr) , rightMargin_ ( 74 ) , indentation_ ( indentation ) { @@ -608,7 +608,7 @@ StyledStreamWriter::write ( std::ostream& out, const Value& root ) writeValue ( root ); writeCommentAfterValueOnSameLine ( root ); *document_ << "\n"; - document_ = NULL; // Forget the stream, for safety. + document_ = nullptr; // Forget the stream, for safety. } diff --git a/src/ripple/peerfinder/api/Config.h b/src/ripple/peerfinder/api/Config.h index 902e30abdc..f6186b72d3 100644 --- a/src/ripple/peerfinder/api/Config.h +++ b/src/ripple/peerfinder/api/Config.h @@ -51,7 +51,7 @@ struct Config bool autoConnect; /** The listening port number. */ - uint16 listeningPort; + beast::uint16 listeningPort; /** The set of features we advertise. */ std::string features; @@ -68,7 +68,7 @@ struct Config void applyTuning (); /** Write the configuration into a property stream */ - void onWrite (PropertyStream::Map& map); + void onWrite (beast::PropertyStream::Map& map); }; } diff --git a/src/ripple/peerfinder/api/Endpoint.h b/src/ripple/peerfinder/api/Endpoint.h index 37229b6339..8324253737 100644 --- a/src/ripple/peerfinder/api/Endpoint.h +++ b/src/ripple/peerfinder/api/Endpoint.h @@ -28,15 +28,15 @@ struct Endpoint { Endpoint (); - Endpoint (IP::Endpoint const& ep, int hops_); + Endpoint (beast::IP::Endpoint const& ep, int hops_); int hops; - IP::Endpoint address; + beast::IP::Endpoint address; }; bool operator< (Endpoint const& lhs, Endpoint const& rhs); -} -} +} // namespace PeerFinder +} // namespace ripple #endif diff --git a/src/ripple/peerfinder/api/Manager.h b/src/ripple/peerfinder/api/Manager.h index 7039bc409a..b76e900f81 100644 --- a/src/ripple/peerfinder/api/Manager.h +++ b/src/ripple/peerfinder/api/Manager.h @@ -28,8 +28,8 @@ namespace PeerFinder { /** Maintains a set of IP addresses used for getting into the network. */ class Manager - : public Stoppable - , public PropertyStream::Source + : public beast::Stoppable + , public beast::PropertyStream::Source { protected: explicit Manager (Stoppable& parent); @@ -39,10 +39,10 @@ public: static Manager* New ( Stoppable& parent, SiteFiles::Manager& siteFiles, - File const& pathToDbFileOrDirectory, + beast::File const& pathToDbFileOrDirectory, Callback& callback, clock_type& clock, - Journal journal); + beast::Journal journal); /** Destroy the object. Any pending source fetch operations are aborted. @@ -64,7 +64,7 @@ public: file, along with the set of corresponding IP addresses. */ virtual void addFixedPeer (std::string const& name, - std::vector const& addresses) = 0; + std::vector const& addresses) = 0; /** Add a set of strings as fallback IP::Endpoint sources. @param name A label used for diagnostics. @@ -87,15 +87,15 @@ public: Usually this is because of a detected self-connection. */ virtual Slot::ptr new_inbound_slot ( - IP::Endpoint const& local_endpoint, - IP::Endpoint const& remote_endpoint) = 0; + beast::IP::Endpoint const& local_endpoint, + beast::IP::Endpoint const& remote_endpoint) = 0; /** Create a new outbound slot with the specified remote endpoint. If nullptr is returned, then the slot could not be assigned. Usually this is because of a duplicate connection. */ virtual Slot::ptr new_outbound_slot ( - IP::Endpoint const& remote_endpoint) = 0; + beast::IP::Endpoint const& remote_endpoint) = 0; /** Called when an outbound connection attempt succeeds. The local endpoint must be valid. If the caller receives an error @@ -104,7 +104,7 @@ public: instead of on_connected. */ virtual void on_connected (Slot::ptr const& slot, - IP::Endpoint const& local_endpoint) = 0; + beast::IP::Endpoint const& local_endpoint) = 0; /** Called when a handshake is completed. */ virtual void on_handshake (Slot::ptr const& slot, diff --git a/src/ripple/peerfinder/api/Slot.h b/src/ripple/peerfinder/api/Slot.h index 00fcbe750e..2e25db1326 100644 --- a/src/ripple/peerfinder/api/Slot.h +++ b/src/ripple/peerfinder/api/Slot.h @@ -64,10 +64,10 @@ public: virtual State state () const = 0; /** The remote endpoint of socket. */ - virtual IP::Endpoint const& remote_endpoint () const = 0; + virtual beast::IP::Endpoint const& remote_endpoint () const = 0; /** The local endpoint of the socket, when known. */ - virtual boost::optional const& local_endpoint () const = 0; + virtual boost::optional const& local_endpoint () const = 0; /** The peer's public key, when known. The public key is established when the handshake is complete. diff --git a/src/ripple/peerfinder/api/Types.h b/src/ripple/peerfinder/api/Types.h index f82ddd48a4..4a846a999c 100644 --- a/src/ripple/peerfinder/api/Types.h +++ b/src/ripple/peerfinder/api/Types.h @@ -26,7 +26,7 @@ namespace ripple { namespace PeerFinder { /** Represents a set of addresses. */ -typedef std::vector IPAddresses; +typedef std::vector IPAddresses; /** A set of Endpoint used for connecting. */ typedef std::vector Endpoints; diff --git a/src/ripple/peerfinder/impl/Bootcache.cpp b/src/ripple/peerfinder/impl/Bootcache.cpp index 06aceb50c5..e59726bba4 100644 --- a/src/ripple/peerfinder/impl/Bootcache.cpp +++ b/src/ripple/peerfinder/impl/Bootcache.cpp @@ -25,7 +25,7 @@ namespace PeerFinder { Bootcache::Bootcache ( Store& store, clock_type& clock, - Journal journal) + beast::Journal journal) : m_store (store) , m_clock (clock) , m_journal (journal) @@ -88,21 +88,21 @@ Bootcache::load () { clear(); auto const n (m_store.load ( - [this](IP::Endpoint const& endpoint, int valence) + [this](beast::IP::Endpoint const& endpoint, int valence) { auto const result (this->m_map.insert ( value_type (endpoint, valence))); if (! result.second) { if (this->m_journal.error) - this->m_journal.error << leftw (18) << + this->m_journal.error << beast::leftw (18) << "Bootcache discard " << endpoint; } })); if (n > 0) { - if (m_journal.info) m_journal.info << leftw (18) << + if (m_journal.info) m_journal.info << beast::leftw (18) << "Bootcache loaded " << n << ((n > 1) ? " addresses" : " address"); prune (); @@ -110,13 +110,13 @@ Bootcache::load () } bool -Bootcache::insert (IP::Endpoint const& endpoint) +Bootcache::insert (beast::IP::Endpoint const& endpoint) { auto const result (m_map.insert ( value_type (endpoint, 0))); if (result.second) { - if (m_journal.trace) m_journal.trace << leftw (18) << + if (m_journal.trace) m_journal.trace << beast::leftw (18) << "Bootcache insert " << endpoint; prune (); flagForUpdate(); @@ -125,7 +125,7 @@ Bootcache::insert (IP::Endpoint const& endpoint) } void -Bootcache::on_success (IP::Endpoint const& endpoint) +Bootcache::on_success (beast::IP::Endpoint const& endpoint) { auto result (m_map.insert ( value_type (endpoint, 1))); @@ -145,7 +145,7 @@ Bootcache::on_success (IP::Endpoint const& endpoint) assert (result.second); } Entry const& entry (result.first->right); - if (m_journal.info) m_journal.info << leftw (18) << + if (m_journal.info) m_journal.info << beast::leftw (18) << "Bootcache connect " << endpoint << " with " << entry.valence() << ((entry.valence() > 1) ? " successes" : " success"); @@ -153,7 +153,7 @@ Bootcache::on_success (IP::Endpoint const& endpoint) } void -Bootcache::on_failure (IP::Endpoint const& endpoint) +Bootcache::on_failure (beast::IP::Endpoint const& endpoint) { auto result (m_map.insert ( value_type (endpoint, -1))); @@ -174,7 +174,7 @@ Bootcache::on_failure (IP::Endpoint const& endpoint) } Entry const& entry (result.first->right); auto const n (std::abs (entry.valence())); - if (m_journal.debug) m_journal.debug << leftw (18) << + if (m_journal.debug) m_journal.debug << beast::leftw (18) << "Bootcache failed " << endpoint << " with " << n << ((n > 1) ? " attempts" : " attempt"); @@ -190,9 +190,9 @@ Bootcache::periodicActivity () //-------------------------------------------------------------------------- void -Bootcache::onWrite (PropertyStream::Map& map) +Bootcache::onWrite (beast::PropertyStream::Map& map) { - map ["entries"] = uint32 (m_map.size()); + map ["entries"] = beast::uint32 (m_map.size()); } // Checks the cache size and prunes if its over the limit. @@ -214,15 +214,15 @@ Bootcache::prune () count-- > 0 && iter != m_map.right.begin(); ++pruned) { --iter; - IP::Endpoint const& endpoint (iter->get_left()); + beast::IP::Endpoint const& endpoint (iter->get_left()); Entry const& entry (iter->get_right()); - if (m_journal.trace) m_journal.trace << leftw (18) << + if (m_journal.trace) m_journal.trace << beast::leftw (18) << "Bootcache pruned" << endpoint << " at valence " << entry.valence(); iter = m_map.right.erase (iter); } - if (m_journal.debug) m_journal.debug << leftw (18) << + if (m_journal.debug) m_journal.debug << beast::leftw (18) << "Bootcache pruned " << pruned << " entries total"; } diff --git a/src/ripple/peerfinder/impl/Bootcache.h b/src/ripple/peerfinder/impl/Bootcache.h index 3e6df6988a..abd3bf77b1 100644 --- a/src/ripple/peerfinder/impl/Bootcache.h +++ b/src/ripple/peerfinder/impl/Bootcache.h @@ -74,16 +74,16 @@ private: int m_valence; }; - typedef boost::bimaps::unordered_set_of left_t; + typedef boost::bimaps::unordered_set_of left_t; typedef boost::bimaps::multiset_of right_t; typedef boost::bimap map_type; typedef map_type::value_type value_type; struct Transform : std::unary_function < map_type::right_map::const_iterator::value_type const&, - IP::Endpoint const&> + beast::IP::Endpoint const&> { - IP::Endpoint const& operator() ( + beast::IP::Endpoint const& operator() ( map_type::right_map:: const_iterator::value_type const& v) const { @@ -96,7 +96,7 @@ private: Store& m_store; clock_type& m_clock; - Journal m_journal; + beast::Journal m_journal; // Time after which we can update the database again clock_type::time_point m_whenUpdate; @@ -113,7 +113,7 @@ public: Bootcache ( Store& store, clock_type& clock, - Journal journal); + beast::Journal journal); ~Bootcache (); @@ -136,19 +136,19 @@ public: void load (); /** Add the address to the cache. */ - bool insert (IP::Endpoint const& endpoint); + bool insert (beast::IP::Endpoint const& endpoint); /** Called when an outbound connection handshake completes. */ - void on_success (IP::Endpoint const& endpoint); + void on_success (beast::IP::Endpoint const& endpoint); /** Called when an outbound connection attempt fails to handshake. */ - void on_failure (IP::Endpoint const& endpoint); + void on_failure (beast::IP::Endpoint const& endpoint); /** Stores the cache in the persistent database on a timer. */ void periodicActivity (); /** Write the cache state to the property stream. */ - void onWrite (PropertyStream::Map& map); + void onWrite (beast::PropertyStream::Map& map); private: void prune (); diff --git a/src/ripple/peerfinder/impl/Checker.cpp b/src/ripple/peerfinder/impl/Checker.cpp index 80937b9866..7325df7352 100644 --- a/src/ripple/peerfinder/impl/Checker.cpp +++ b/src/ripple/peerfinder/impl/Checker.cpp @@ -25,18 +25,18 @@ namespace PeerFinder { class CheckerImp : public Checker - , private Thread - , private LeakChecked + , private beast::Thread + , private beast::LeakChecked { private: class Request; struct State { - List list; + beast::List list; }; - typedef SharedData SharedState; + typedef beast::SharedData SharedState; SharedState m_state; boost::asio::io_service m_io_service; @@ -45,12 +45,12 @@ private: //-------------------------------------------------------------------------- class Request - : public SharedObject - , public List ::Node - , private LeakChecked + : public beast::SharedObject + , public beast::List ::Node + , private beast::LeakChecked { public: - typedef SharedPtr Ptr; + typedef beast::SharedPtr Ptr; typedef boost::asio::ip::tcp Protocol; typedef boost::system::error_code error_code; typedef Protocol::socket socket_type; @@ -58,14 +58,14 @@ private: CheckerImp& m_owner; boost::asio::io_service& m_io_service; - IP::Endpoint m_address; - asio::shared_handler m_handler; + beast::IP::Endpoint m_address; + beast::asio::shared_handler m_handler; socket_type m_socket; boost::system::error_code m_error; bool m_canAccept; Request (CheckerImp& owner, boost::asio::io_service& io_service, - IP::Endpoint const& address, asio::shared_handler < + beast::IP::Endpoint const& address, beast::asio::shared_handler < void (Result)> const& handler) : m_owner (owner) , m_io_service (io_service) @@ -76,10 +76,10 @@ private: { m_owner.add (*this); - m_socket.async_connect (IPAddressConversion::to_asio_endpoint ( - m_address), asio::wrap_handler (std::bind ( + m_socket.async_connect (beast::IPAddressConversion::to_asio_endpoint ( + m_address), beast::asio::wrap_handler (std::bind ( &Request::handle_connect, Ptr(this), - asio::placeholders::error), m_handler)); + beast::asio::placeholders::error), m_handler)); } ~Request () @@ -149,13 +149,13 @@ public: void cancel () { SharedState::Access state (m_state); - for (List ::iterator iter (state->list.begin()); + for (beast::List ::iterator iter (state->list.begin()); iter != state->list.end(); ++iter) iter->cancel(); } - void async_test (IP::Endpoint const& endpoint, - asio::shared_handler handler) + void async_test (beast::IP::Endpoint const& endpoint, + beast::asio::shared_handler handler) { new Request (*this, m_io_service, endpoint, handler); } diff --git a/src/ripple/peerfinder/impl/Checker.h b/src/ripple/peerfinder/impl/Checker.h index 17f304dd00..6d0feff030 100644 --- a/src/ripple/peerfinder/impl/Checker.h +++ b/src/ripple/peerfinder/impl/Checker.h @@ -56,7 +56,7 @@ public: { } /** The original address. */ - IP::Endpoint address; + beast::IP::Endpoint address; /** The error code from the operation. */ boost::system::error_code error; @@ -70,8 +70,8 @@ public: /** Performs an async connection test on the specified endpoint. The port must be non-zero. */ - virtual void async_test (IP::Endpoint const& endpoint, - asio::shared_handler handler) = 0; + virtual void async_test (beast::IP::Endpoint const& endpoint, + beast::asio::shared_handler handler) = 0; }; } diff --git a/src/ripple/peerfinder/impl/CheckerAdapter.h b/src/ripple/peerfinder/impl/CheckerAdapter.h index 6c52a74a5f..616b8cf040 100644 --- a/src/ripple/peerfinder/impl/CheckerAdapter.h +++ b/src/ripple/peerfinder/impl/CheckerAdapter.h @@ -28,8 +28,8 @@ namespace PeerFinder { // Ensures that all Logic member function entry points are // called while holding a lock on the recursive mutex. // -typedef ScopedWrapperContext < - RecursiveMutex, RecursiveMutex::ScopedLockType> SerializedContext; +typedef beast::ScopedWrapperContext < + beast::RecursiveMutex, beast::RecursiveMutex::ScopedLockType> SerializedContext; /** Adapts a ServiceQueue to dispatch Checker handler completions. This lets the Logic have its Checker handler get dispatched @@ -40,19 +40,19 @@ class CheckerAdapter : public Checker { private: SerializedContext& m_context; - ServiceQueue& m_queue; + beast::ServiceQueue& m_queue; std::unique_ptr m_checker; struct Handler { SerializedContext& m_context; - ServiceQueue& m_queue; - asio::shared_handler m_handler; + beast::ServiceQueue& m_queue; + beast::asio::shared_handler m_handler; Handler ( SerializedContext& context, - ServiceQueue& queue, - asio::shared_handler const& handler) + beast::ServiceQueue& queue, + beast::asio::shared_handler const& handler) : m_context (context) , m_queue (queue) , m_handler (handler) @@ -70,7 +70,7 @@ private: }; public: - CheckerAdapter (SerializedContext& context, ServiceQueue& queue) + CheckerAdapter (SerializedContext& context, beast::ServiceQueue& queue) : m_context (context) , m_queue (queue) , m_checker (Checker::New()) @@ -88,8 +88,8 @@ public: m_checker->cancel(); } - void async_test (IP::Endpoint const& endpoint, - asio::shared_handler handler) + void async_test (beast::IP::Endpoint const& endpoint, + beast::asio::shared_handler handler) { m_checker->async_test (endpoint, Handler ( m_context, m_queue, handler)); diff --git a/src/ripple/peerfinder/impl/Config.cpp b/src/ripple/peerfinder/impl/Config.cpp index 03dfd1a6c4..90e716293a 100644 --- a/src/ripple/peerfinder/impl/Config.cpp +++ b/src/ripple/peerfinder/impl/Config.cpp @@ -43,7 +43,7 @@ void Config::applyTuning () outPeers = calcOutPeers (); } -void Config::onWrite (PropertyStream::Map &map) +void Config::onWrite (beast::PropertyStream::Map &map) { map ["max_peers"] = maxPeers; map ["out_peers"] = outPeers; diff --git a/src/ripple/peerfinder/impl/ConnectHandouts.cpp b/src/ripple/peerfinder/impl/ConnectHandouts.cpp index 52b3bb1506..472ca3150c 100644 --- a/src/ripple/peerfinder/impl/ConnectHandouts.cpp +++ b/src/ripple/peerfinder/impl/ConnectHandouts.cpp @@ -31,14 +31,14 @@ ConnectHandouts::ConnectHandouts ( } bool -ConnectHandouts::try_insert (IP::Endpoint const& endpoint) +ConnectHandouts::try_insert (beast::IP::Endpoint const& endpoint) { if (full ()) return false; // Make sure the address isn't already in our list if (std::any_of (m_list.begin(), m_list.end(), - [&endpoint](IP::Endpoint const& other) + [&endpoint](beast::IP::Endpoint const& other) { // Ignore port for security reasons return other.address() == diff --git a/src/ripple/peerfinder/impl/ConnectHandouts.h b/src/ripple/peerfinder/impl/ConnectHandouts.h index 06d4c60125..818749a240 100644 --- a/src/ripple/peerfinder/impl/ConnectHandouts.h +++ b/src/ripple/peerfinder/impl/ConnectHandouts.h @@ -33,9 +33,9 @@ class ConnectHandouts public: // Keeps track of addresses we have made outgoing connections // to, for the purposes of not connecting to them too frequently. - typedef beast::aged_set Squelches; + typedef beast::aged_set Squelches; - typedef std::vector list_type; + typedef std::vector list_type; private: std::size_t m_needed; @@ -70,7 +70,7 @@ public: return m_list; } - bool try_insert (IP::Endpoint const& endpoint); + bool try_insert (beast::IP::Endpoint const& endpoint); }; } diff --git a/src/ripple/peerfinder/impl/Counts.h b/src/ripple/peerfinder/impl/Counts.h index 9ff0ccc842..eb8255ac4a 100644 --- a/src/ripple/peerfinder/impl/Counts.h +++ b/src/ripple/peerfinder/impl/Counts.h @@ -225,7 +225,7 @@ public: } /** Output statistics. */ - void onWrite (PropertyStream::Map& map) + void onWrite (beast::PropertyStream::Map& map) { map ["accept"] = acceptCount (); map ["connect"] = connectCount (); diff --git a/src/ripple/peerfinder/impl/Endpoint.cpp b/src/ripple/peerfinder/impl/Endpoint.cpp index 8756919db6..bcd2062d05 100644 --- a/src/ripple/peerfinder/impl/Endpoint.cpp +++ b/src/ripple/peerfinder/impl/Endpoint.cpp @@ -27,7 +27,7 @@ Endpoint::Endpoint () { } -Endpoint::Endpoint (IP::Endpoint const& ep, int hops_) +Endpoint::Endpoint (beast::IP::Endpoint const& ep, int hops_) : hops (hops_) , address (ep) { diff --git a/src/ripple/peerfinder/impl/Livecache.cpp b/src/ripple/peerfinder/impl/Livecache.cpp index bea513cfa0..a26a31e1f8 100644 --- a/src/ripple/peerfinder/impl/Livecache.cpp +++ b/src/ripple/peerfinder/impl/Livecache.cpp @@ -30,19 +30,19 @@ namespace detail { //------------------------------------------------------------------------------ -class LivecacheTests : public UnitTest +class LivecacheTests : public beast::UnitTest { public: - manual_clock m_clock; + beast::manual_clock m_clock; // Add the address as an endpoint template - void add (uint32 index, uint16 port, C& c) + void add (beast::uint32 index, beast::uint16 port, C& c) { Endpoint ep; ep.hops = 0; - ep.address = IP::Endpoint ( - IP::AddressV4 (index), port); + ep.address = beast::IP::Endpoint ( + beast::IP::AddressV4 (index), port); c.insert (ep); } @@ -50,7 +50,7 @@ public: { beginTestCase ("fetch"); - Livecache <> c (m_clock, Journal()); + Livecache <> c (m_clock, beast::Journal()); add (1, 1, c); add (2, 1, c); diff --git a/src/ripple/peerfinder/impl/Livecache.h b/src/ripple/peerfinder/impl/Livecache.h index e26711ea86..43b22bfb07 100644 --- a/src/ripple/peerfinder/impl/Livecache.h +++ b/src/ripple/peerfinder/impl/Livecache.h @@ -139,7 +139,7 @@ public: } private: - explicit Hop (typename maybe_const < + explicit Hop (typename beast::maybe_const < IsConst, list_type>::type& list) : m_list (list) { @@ -147,14 +147,14 @@ public: friend class LivecacheBase; - std::reference_wrapper ::type> m_list; }; protected: // Work-around to call Hop's private constructor from Livecache template - static Hop make_hop (typename maybe_const < + static Hop make_hop (typename beast::maybe_const < IsConst, list_type>::type& list) { return Hop (list); @@ -181,15 +181,15 @@ template > class Livecache : protected detail::LivecacheBase { private: - typedef aged_map < - IP::Endpoint, + typedef beast::aged_map < + beast::IP::Endpoint, Element, std::chrono::seconds, - std::less , + std::less , Allocator > cache_type; - Journal m_journal; + beast::Journal m_journal; cache_type m_cache; public: @@ -198,7 +198,7 @@ public: /** Create the cache. */ Livecache ( clock_type& clock, - Journal journal, + beast::Journal journal, Allocator alloc = Allocator()); // @@ -224,7 +224,7 @@ public: : public std::unary_function < typename lists_type::value_type, Hop > { - Hop operator() (typename maybe_const < + Hop operator() (typename beast::maybe_const < IsConst, typename lists_type::value_type>::type& list) const { return make_hop (list); @@ -355,10 +355,10 @@ public: void insert (Endpoint const& ep); /** Produce diagnostic output. */ - void dump (Journal::ScopedStream& ss) const; + void dump (beast::Journal::ScopedStream& ss) const; /** Output statistics. */ - void onWrite (PropertyStream::Map& map); + void onWrite (beast::PropertyStream::Map& map); }; //------------------------------------------------------------------------------ @@ -366,7 +366,7 @@ public: template Livecache ::Livecache ( clock_type& clock, - Journal journal, + beast::Journal journal, Allocator alloc) : m_journal (journal) , m_cache (clock, alloc) @@ -391,7 +391,7 @@ Livecache ::expire() } if (n > 0) { - if (m_journal.debug) m_journal.debug << leftw (18) << + if (m_journal.debug) m_journal.debug << beast::leftw (18) << "Livecache expired " << n << ((n > 1) ? " entries" : " entry"); } @@ -413,7 +413,7 @@ void Livecache ::insert (Endpoint const& ep) if (result.second) { hops.insert (e); - if (m_journal.debug) m_journal.debug << leftw (18) << + if (m_journal.debug) m_journal.debug << beast::leftw (18) << "Livecache insert " << ep.address << " at hops " << ep.hops; return; @@ -423,7 +423,7 @@ void Livecache ::insert (Endpoint const& ep) // Drop duplicates at higher hops std::size_t const excess ( ep.hops - e.endpoint.hops); - if (m_journal.trace) m_journal.trace << leftw(18) << + if (m_journal.trace) m_journal.trace << beast::leftw(18) << "Livecache drop " << ep.address << " at hops +" << excess; return; @@ -435,13 +435,13 @@ void Livecache ::insert (Endpoint const& ep) if (ep.hops < e.endpoint.hops) { hops.reinsert (e, ep.hops); - if (m_journal.debug) m_journal.debug << leftw (18) << + if (m_journal.debug) m_journal.debug << beast::leftw (18) << "Livecache update " << ep.address << " at hops " << ep.hops; } else { - if (m_journal.trace) m_journal.trace << leftw (18) << + if (m_journal.trace) m_journal.trace << beast::leftw (18) << "Livecache refresh " << ep.address << " at hops " << ep.hops; } @@ -449,7 +449,7 @@ void Livecache ::insert (Endpoint const& ep) template void -Livecache ::dump (Journal::ScopedStream& ss) const +Livecache ::dump (beast::Journal::ScopedStream& ss) const { ss << std::endl << std::endl << "Livecache (size " << m_cache.size() << ")"; @@ -464,17 +464,17 @@ Livecache ::dump (Journal::ScopedStream& ss) const template void -Livecache ::onWrite (PropertyStream::Map& map) +Livecache ::onWrite (beast::PropertyStream::Map& map) { typename cache_type::time_point const expired ( m_cache.clock().now() - Tuning::liveCacheSecondsToLive); map ["size"] = size (); map ["hist"] = hops.histogram(); - PropertyStream::Set set ("entries", map); + beast::PropertyStream::Set set ("entries", map); for (auto iter (m_cache.cbegin()); iter != m_cache.cend(); ++iter) { auto const& e (iter->second); - PropertyStream::Map item (set); + beast::PropertyStream::Map item (set); item ["hops"] = e.endpoint.hops; item ["address"] = e.endpoint.address.to_string (); std::stringstream ss; diff --git a/src/ripple/peerfinder/impl/Logic.h b/src/ripple/peerfinder/impl/Logic.h index 6dda1af63a..c4af73591c 100644 --- a/src/ripple/peerfinder/impl/Logic.h +++ b/src/ripple/peerfinder/impl/Logic.h @@ -46,29 +46,29 @@ public: // Maps remote endpoints to slots. Since a slot has a // remote endpoint upon construction, this holds all counts. // - typedef std::map > Slots; - typedef std::map FixedSlots; + typedef std::map FixedSlots; // A set of unique Ripple public keys typedef std::set Keys; // A set of non-unique IPAddresses without ports, used // to filter duplicates when making outgoing connections. - typedef std::multiset ConnectedAddresses; + typedef std::multiset ConnectedAddresses; struct State { State ( Store* store, clock_type& clock, - Journal journal) + beast::Journal journal) : stopping (false) , counts () - , livecache (clock, Journal ( + , livecache (clock, beast::Journal ( journal, Reporting::livecache)) - , bootcache (*store, clock, Journal ( + , bootcache (*store, clock, beast::Journal ( journal, Reporting::bootcache)) { } @@ -78,7 +78,7 @@ public: // The source we are currently fetching. // This is used to cancel I/O during program exit. - SharedPtr fetchSource; + beast::SharedPtr fetchSource; // Configuration settings Config config; @@ -107,9 +107,9 @@ public: Keys keys; }; - typedef SharedData SharedState; + typedef beast::SharedData SharedState; - Journal m_journal; + beast::Journal m_journal; SharedState m_state; clock_type& m_clock; Callback& m_callback; @@ -117,7 +117,7 @@ public: Checker& m_checker; // A list of dynamic sources to consult as a fallback - std::vector > m_sources; + std::vector > m_sources; clock_type::time_point m_whenBroadcast; @@ -130,7 +130,7 @@ public: Callback& callback, Store& store, Checker& checker, - Journal journal) + beast::Journal journal) : m_journal (journal, Reporting::logic) , m_state (&store, std::ref (clock), journal) , m_clock (clock) @@ -180,7 +180,7 @@ public: } void addFixedPeer (std::string const& name, - std::vector const& addresses) + std::vector const& addresses) { SharedState::Access state (m_state); @@ -199,7 +199,7 @@ public: if (result.second) { - if (m_journal.debug) m_journal.debug << leftw (18) << + if (m_journal.debug) m_journal.debug << beast::leftw (18) << "Logic add fixed" << "'" << name << "' at " << remote_address; return; @@ -210,8 +210,8 @@ public: //-------------------------------------------------------------------------- // Called when the Checker completes a connectivity test - void checkComplete (IP::Endpoint const& address, - IP::Endpoint const & checkedAddress, Checker::Result const& result) + void checkComplete (beast::IP::Endpoint const& address, + beast::IP::Endpoint const & checkedAddress, Checker::Result const& result) { if (result.error == boost::asio::error::operation_aborted) return; @@ -223,7 +223,7 @@ public: if (iter == state->slots.end()) { // The slot disconnected before we finished the check - if (m_journal.debug) m_journal.debug << leftw (18) << + if (m_journal.debug) m_journal.debug << beast::leftw (18) << "Logic tested " << address << " but the connection was closed"; return; @@ -239,12 +239,12 @@ public: if (slot.canAccept) { - if (m_journal.debug) m_journal.debug << leftw (18) << + if (m_journal.debug) m_journal.debug << beast::leftw (18) << "Logic testing " << address << " succeeded"; } else { - if (m_journal.info) m_journal.info << leftw (18) << + if (m_journal.info) m_journal.info << beast::leftw (18) << "Logic testing " << address << " failed"; } } @@ -254,7 +254,7 @@ public: slot.checked = true; slot.canAccept = false; - if (m_journal.error) m_journal.error << leftw (18) << + if (m_journal.error) m_journal.error << beast::leftw (18) << "Logic testing " << iter->first << " with error, " << result.error.message(); } @@ -265,10 +265,10 @@ public: //-------------------------------------------------------------------------- - SlotImp::ptr new_inbound_slot (IP::Endpoint const& local_endpoint, - IP::Endpoint const& remote_endpoint) + SlotImp::ptr new_inbound_slot (beast::IP::Endpoint const& local_endpoint, + beast::IP::Endpoint const& remote_endpoint) { - if (m_journal.debug) m_journal.debug << leftw (18) << + if (m_journal.debug) m_journal.debug << beast::leftw (18) << "Logic accept" << remote_endpoint << " on local " << local_endpoint; @@ -282,7 +282,7 @@ public: Slot::ptr const& self (iter->second); assert ((self->local_endpoint () == boost::none) || (self->local_endpoint () == remote_endpoint)); - if (m_journal.warning) m_journal.warning << leftw (18) << + if (m_journal.warning) m_journal.warning << beast::leftw (18) << "Logic dropping " << remote_endpoint << " as self connect"; return SlotImp::ptr (); @@ -307,9 +307,9 @@ public: return result.first->second; } - SlotImp::ptr new_outbound_slot (IP::Endpoint const& remote_endpoint) + SlotImp::ptr new_outbound_slot (beast::IP::Endpoint const& remote_endpoint) { - if (m_journal.debug) m_journal.debug << leftw (18) << + if (m_journal.debug) m_journal.debug << beast::leftw (18) << "Logic connect " << remote_endpoint; SharedState::Access state (m_state); @@ -318,7 +318,7 @@ public: if (state->slots.find (remote_endpoint) != state->slots.end ()) { - if (m_journal.warning) m_journal.warning << leftw (18) << + if (m_journal.warning) m_journal.warning << beast::leftw (18) << "Logic dropping " << remote_endpoint << " as duplicate connect"; return SlotImp::ptr (); @@ -345,9 +345,9 @@ public: } void on_connected (SlotImp::ptr const& slot, - IP::Endpoint const& local_endpoint) + beast::IP::Endpoint const& local_endpoint) { - if (m_journal.trace) m_journal.trace << leftw (18) << + if (m_journal.trace) m_journal.trace << beast::leftw (18) << "Logic connected" << slot->remote_endpoint () << " on local " << local_endpoint; @@ -366,7 +366,7 @@ public: { Slot::ptr const& self (iter->second); assert (self->local_endpoint () == slot->remote_endpoint ()); - if (m_journal.warning) m_journal.warning << leftw (18) << + if (m_journal.warning) m_journal.warning << beast::leftw (18) << "Logic dropping " << slot->remote_endpoint () << " as self connect"; m_callback.disconnect (slot, false); @@ -383,7 +383,7 @@ public: void on_handshake (SlotImp::ptr const& slot, RipplePublicKey const& key, bool cluster) { - if (m_journal.debug) m_journal.debug << leftw (18) << + if (m_journal.debug) m_journal.debug << beast::leftw (18) << "Logic handshake " << slot->remote_endpoint () << " with " << (cluster ? "clustered " : "") << "key " << key; @@ -434,7 +434,7 @@ public: auto iter (state->fixed.find (slot->remote_endpoint())); assert (iter != state->fixed.end ()); iter->second.success (m_clock.now ()); - if (m_journal.trace) m_journal.trace << leftw (18) << + if (m_journal.trace) m_journal.trace << beast::leftw (18) << "Logic fixed " << slot->remote_endpoint () << " success"; } @@ -468,7 +468,7 @@ public: // Enforce hop limit if (ep.hops > Tuning::maxHops) { - if (m_journal.warning) m_journal.warning << leftw (18) << + if (m_journal.warning) m_journal.warning << beast::leftw (18) << "Endpoints drop " << ep.address << " for excess hops " << ep.hops; iter = list.erase (iter); @@ -487,7 +487,7 @@ public: } else { - if (m_journal.warning) m_journal.warning << leftw (18) << + if (m_journal.warning) m_journal.warning << beast::leftw (18) << "Endpoints drop " << ep.address << " for extra self"; iter = list.erase (iter); @@ -498,7 +498,7 @@ public: // Discard invalid addresses if (! is_valid_address (ep.address)) { - if (m_journal.warning) m_journal.warning << leftw (18) << + if (m_journal.warning) m_journal.warning << beast::leftw (18) << "Endpoints drop " << ep.address << " as invalid"; iter = list.erase (iter); @@ -512,7 +512,7 @@ public: return ep.address == other.address; })) { - if (m_journal.warning) m_journal.warning << leftw (18) << + if (m_journal.warning) m_journal.warning << beast::leftw (18) << "Endpoints drop " << ep.address << " as duplicate"; iter = list.erase (iter); @@ -530,7 +530,7 @@ public: void on_endpoints (SlotImp::ptr const& slot, Endpoints list) { - if (m_journal.trace) m_journal.trace << leftw (18) << + if (m_journal.trace) m_journal.trace << beast::leftw (18) << "Endpoints from " << slot->remote_endpoint () << " contained " << list.size () << ((list.size() > 1) ? " entries" : " entry"); @@ -563,7 +563,7 @@ public: { if (slot->connectivityCheckInProgress) { - if (m_journal.warning) m_journal.warning << leftw (18) << + if (m_journal.warning) m_journal.warning << beast::leftw (18) << "Logic testing " << ep.address << " already in progress"; continue; } @@ -578,7 +578,7 @@ public: // m_checker.async_test (ep.address, bind ( &Logic::checkComplete, this, slot->remote_endpoint (), - ep.address, _1)); + ep.address, beast::_1)); // Note that we simply discard the first Endpoint // that the neighbor sends when we perform the @@ -656,7 +656,7 @@ public: auto iter (state->fixed.find (slot->remote_endpoint())); assert (iter != state->fixed.end ()); iter->second.failure (m_clock.now ()); - if (m_journal.debug) m_journal.debug << leftw (18) << + if (m_journal.debug) m_journal.debug << beast::leftw (18) << "Logic fixed " << slot->remote_endpoint () << " failed"; } @@ -664,7 +664,7 @@ public: switch (slot->state()) { case Slot::accept: - if (m_journal.trace) m_journal.trace << leftw (18) << + if (m_journal.trace) m_journal.trace << beast::leftw (18) << "Logic accept " << slot->remote_endpoint () << " failed"; break; @@ -678,12 +678,12 @@ public: break; case Slot::active: - if (m_journal.trace) m_journal.trace << leftw (18) << + if (m_journal.trace) m_journal.trace << beast::leftw (18) << "Logic close " << slot->remote_endpoint(); break; case Slot::closing: - if (m_journal.trace) m_journal.trace << leftw (18) << + if (m_journal.trace) m_journal.trace << beast::leftw (18) << "Logic finished " << slot->remote_endpoint(); break; @@ -699,14 +699,14 @@ public: remove (slot, state); - if (m_journal.trace) m_journal.trace << leftw (18) << + if (m_journal.trace) m_journal.trace << beast::leftw (18) << "Logic cancel " << slot->remote_endpoint(); } //-------------------------------------------------------------------------- // Returns `true` if the address matches a fixed slot address - bool fixed (IP::Endpoint const& endpoint, SharedState::Access& state) const + bool fixed (beast::IP::Endpoint const& endpoint, SharedState::Access& state) const { for (auto const& entry : state->fixed) if (entry.first == endpoint) @@ -716,7 +716,7 @@ public: // Returns `true` if the address matches a fixed slot address // Note that this does not use the port information in the IP::Endpoint - bool fixed (IP::Address const& address, SharedState::Access& state) const + bool fixed (beast::IP::Address const& address, SharedState::Access& state) const { for (auto const& entry : state->fixed) if (entry.first.address () == address) @@ -796,7 +796,7 @@ public: if (! h.list().empty ()) { - if (m_journal.debug) m_journal.debug << leftw (18) << + if (m_journal.debug) m_journal.debug << beast::leftw (18) << "Logic connect " << h.list().size() << " fixed"; m_callback.connect (h.list()); return; @@ -804,7 +804,7 @@ public: if (state->counts.attempts() > 0) { - if (m_journal.debug) m_journal.debug << leftw (18) << + if (m_journal.debug) m_journal.debug << beast::leftw (18) << "Logic waiting on " << state->counts.attempts() << " attempts"; return; @@ -829,7 +829,7 @@ public: state->livecache.hops.rend()); if (! h.list().empty ()) { - if (m_journal.debug) m_journal.debug << leftw (18) << + if (m_journal.debug) m_journal.debug << beast::leftw (18) << "Logic connect " << h.list().size () << " live " << ((h.list().size () > 1) ? "endpoints" : "endpoint"); m_callback.connect (h.list()); @@ -837,7 +837,7 @@ public: } else if (state->counts.attempts() > 0) { - if (m_journal.debug) m_journal.debug << leftw (18) << + if (m_journal.debug) m_journal.debug << beast::leftw (18) << "Logic waiting on " << state->counts.attempts() << " attempts"; return; @@ -866,7 +866,7 @@ public: if (! h.list().empty ()) { - if (m_journal.debug) m_journal.debug << leftw (18) << + if (m_journal.debug) m_journal.debug << beast::leftw (18) << "Logic connect " << h.list().size () << " boot " << ((h.list().size () > 1) ? "addresses" : "address"); m_callback.connect (h.list()); @@ -878,12 +878,12 @@ public: //-------------------------------------------------------------------------- - void addStaticSource (SharedPtr const& source) + void addStaticSource (beast::SharedPtr const& source) { fetch (source); } - void addSource (SharedPtr const& source) + void addSource (beast::SharedPtr const& source) { m_sources.push_back (source); } @@ -934,7 +934,7 @@ public: // Add one address. // Returns `true` if the address is new. // - bool addBootcacheAddress (IP::Endpoint const& address, + bool addBootcacheAddress (beast::IP::Endpoint const& address, SharedState::Access& state) { return state->bootcache.insert (address); @@ -956,7 +956,7 @@ public: } // Fetch bootcache addresses from the specified source. - void fetch (SharedPtr const& source) + void fetch (beast::SharedPtr const& source) { Source::Results results; @@ -984,14 +984,14 @@ public: if (! results.error) { int const count (addBootcacheAddresses (results.addresses)); - if (m_journal.info) m_journal.info << leftw (18) << + if (m_journal.info) m_journal.info << beast::leftw (18) << "Logic added " << count << " new " << ((count == 1) ? "address" : "addresses") << " from " << source->name(); } else { - if (m_journal.error) m_journal.error << leftw (18) << + if (m_journal.error) m_journal.error << beast::leftw (18) << "Logic failed " << "'" << source->name() << "' fetch, " << results.error.message(); } @@ -1004,7 +1004,7 @@ public: //-------------------------------------------------------------------------- // Returns true if the IP::Endpoint contains no invalid data. - bool is_valid_address (IP::Endpoint const& address) + bool is_valid_address (beast::IP::Endpoint const& address) { if (is_unspecified (address)) return false; @@ -1028,7 +1028,7 @@ public: if (! h.list().empty ()) { - if (m_journal.trace) m_journal.trace << leftw (18) << + if (m_journal.trace) m_journal.trace << beast::leftw (18) << "Logic redirect " << slot->remote_endpoint() << " with " << h.list().size() << ((h.list().size() == 1) ? " address" : " addresses"); @@ -1036,7 +1036,7 @@ public: } else { - if (m_journal.warning) m_journal.warning << leftw (18) << + if (m_journal.warning) m_journal.warning << beast::leftw (18) << "Logic deferred " << slot->remote_endpoint(); } } @@ -1086,8 +1086,8 @@ public: { Endpoint ep; ep.hops = 0; - ep.address = IP::Endpoint ( - IP::AddressV4 ()).at_port ( + ep.address = beast::IP::Endpoint ( + beast::IP::AddressV4 ()).at_port ( state->config.listeningPort); for (auto& t : targets) t.insert (ep); @@ -1104,7 +1104,7 @@ public: { SlotImp::ptr const& slot (t.slot()); auto const& list (t.list()); - if (m_journal.trace) m_journal.trace << leftw (18) << + if (m_journal.trace) m_journal.trace << beast::leftw (18) << "Logic sending " << slot->remote_endpoint() << " with " << list.size() << ((list.size() == 1) ? " endpoint" : " endpoints"); @@ -1118,11 +1118,11 @@ public: // //-------------------------------------------------------------------------- - void writeSlots (PropertyStream::Set& set, Slots const& slots) + void writeSlots (beast::PropertyStream::Set& set, Slots const& slots) { for (auto const& entry : slots) { - PropertyStream::Map item (set); + beast::PropertyStream::Map item (set); SlotImp const& slot (*entry.second); if (slot.local_endpoint () != boost::none) item ["local_address"] = to_string (*slot.local_endpoint ()); @@ -1138,38 +1138,38 @@ public: } } - void onWrite (PropertyStream::Map& map) + void onWrite (beast::PropertyStream::Map& map) { SharedState::Access state (m_state); // VFALCO NOTE These ugly casts are needed because // of how std::size_t is declared on some linuxes // - map ["bootcache"] = uint32 (state->bootcache.size()); - map ["fixed"] = uint32 (state->fixed.size()); + map ["bootcache"] = beast::uint32 (state->bootcache.size()); + map ["fixed"] = beast::uint32 (state->fixed.size()); { - PropertyStream::Set child ("peers", map); + beast::PropertyStream::Set child ("peers", map); writeSlots (child, state->slots); } { - PropertyStream::Map child ("counts", map); + beast::PropertyStream::Map child ("counts", map); state->counts.onWrite (child); } { - PropertyStream::Map child ("config", map); + beast::PropertyStream::Map child ("config", map); state->config.onWrite (child); } { - PropertyStream::Map child ("livecache", map); + beast::PropertyStream::Map child ("livecache", map); state->livecache.onWrite (child); } { - PropertyStream::Map child ("bootcache", map); + beast::PropertyStream::Map child ("bootcache", map); state->bootcache.onWrite (child); } } diff --git a/src/ripple/peerfinder/impl/Manager.cpp b/src/ripple/peerfinder/impl/Manager.cpp index d3a3d04711..6cf57bbce0 100644 --- a/src/ripple/peerfinder/impl/Manager.cpp +++ b/src/ripple/peerfinder/impl/Manager.cpp @@ -22,32 +22,32 @@ namespace PeerFinder { class ManagerImp : public Manager - , public Thread + , public beast::Thread , public SiteFiles::Listener - , public DeadlineTimer::Listener - , public LeakChecked + , public beast::DeadlineTimer::Listener + , public beast::LeakChecked { public: - ServiceQueue m_queue; + beast::ServiceQueue m_queue; SiteFiles::Manager& m_siteFiles; - File m_databaseFile; + beast::File m_databaseFile; clock_type& m_clock; - Journal m_journal; + beast::Journal m_journal; StoreSqdb m_store; SerializedContext m_context; CheckerAdapter m_checker; Logic m_logic; - DeadlineTimer m_secondsTimer; + beast::DeadlineTimer m_secondsTimer; //-------------------------------------------------------------------------- ManagerImp ( Stoppable& stoppable, SiteFiles::Manager& siteFiles, - File const& pathToDbFileOrDirectory, + beast::File const& pathToDbFileOrDirectory, Callback& callback, clock_type& clock, - Journal journal) + beast::Journal journal) : Manager (stoppable) , Thread ("PeerFinder") , m_siteFiles (siteFiles) @@ -78,12 +78,12 @@ public: { m_queue.dispatch ( m_context.wrap ( - bind (&Logic::setConfig, &m_logic, + std::bind (&Logic::setConfig, &m_logic, config))); } void addFixedPeer (std::string const& name, - std::vector const& addresses) + std::vector const& addresses) { m_queue.dispatch ( m_context.wrap ( @@ -96,7 +96,7 @@ public: { m_queue.dispatch ( m_context.wrap ( - bind (&Logic::addStaticSource, &m_logic, + std::bind (&Logic::addStaticSource, &m_logic, SourceStrings::New (name, strings)))); } @@ -108,19 +108,19 @@ public: //-------------------------------------------------------------------------- Slot::ptr new_inbound_slot ( - IP::Endpoint const& local_endpoint, - IP::Endpoint const& remote_endpoint) + beast::IP::Endpoint const& local_endpoint, + beast::IP::Endpoint const& remote_endpoint) { return m_logic.new_inbound_slot (local_endpoint, remote_endpoint); } - Slot::ptr new_outbound_slot (IP::Endpoint const& remote_endpoint) + Slot::ptr new_outbound_slot (beast::IP::Endpoint const& remote_endpoint) { return m_logic.new_outbound_slot (remote_endpoint); } void on_connected (Slot::ptr const& slot, - IP::Endpoint const& local_endpoint) + beast::IP::Endpoint const& local_endpoint) { SlotImp::ptr impl (std::dynamic_pointer_cast (slot)); m_logic.on_connected (impl, local_endpoint); @@ -170,9 +170,9 @@ public: section.data().begin()); iter != section.data().end(); ++iter) { std::string const& s (*iter); - IP::Endpoint addr (IP::Endpoint::from_string (s)); + beast::IP::Endpoint addr (beast::IP::Endpoint::from_string (s)); if (is_unspecified (addr)) - addr = IP::Endpoint::from_string_altform(s); + addr = beast::IP::Endpoint::from_string_altform(s); if (! is_unspecified (addr)) { // add IP::Endpoint to bootstrap cache @@ -191,9 +191,9 @@ public: section.data().begin()); iter != section.data().end(); ++iter) { std::string const& s (*iter); - IP::Endpoint addr (IP::Endpoint::from_string (s)); + beast::IP::Endpoint addr (beast::IP::Endpoint::from_string (s)); if (is_unspecified (addr)) - addr = IP::Endpoint::from_string_altform(s); + addr = beast::IP::Endpoint::from_string_altform(s); if (! is_unspecified (addr)) { // add IP::Endpoint to fixed peers @@ -233,7 +233,7 @@ public: m_secondsTimer.cancel(); m_queue.dispatch ( m_context.wrap ( - bind (&Thread::signalThreadShouldExit, this))); + std::bind (&Thread::signalThreadShouldExit, this))); } //-------------------------------------------------------------------------- @@ -242,7 +242,7 @@ public: // //-------------------------------------------------------------------------- - void onWrite (PropertyStream::Map& map) + void onWrite (beast::PropertyStream::Map& map) { SerializedContext::Scope scope (m_context); @@ -251,13 +251,13 @@ public: //-------------------------------------------------------------------------- - void onDeadlineTimer (DeadlineTimer& timer) + void onDeadlineTimer (beast::DeadlineTimer& timer) { if (timer == m_secondsTimer) { m_queue.dispatch ( m_context.wrap ( - bind (&Logic::periodicActivity, &m_logic))); + std::bind (&Logic::periodicActivity, &m_logic))); m_secondsTimer.setExpiration (Tuning::secondsPerConnect); } @@ -267,7 +267,7 @@ public: { m_journal.debug << "Initializing"; - Error error (m_store.open (m_databaseFile)); + beast::Error error (m_store.open (m_databaseFile)); if (error) { @@ -306,17 +306,17 @@ public: Manager::Manager (Stoppable& parent) : Stoppable ("PeerFinder", parent) - , PropertyStream::Source ("peerfinder") + , beast::PropertyStream::Source ("peerfinder") { } Manager* Manager::New ( Stoppable& parent, SiteFiles::Manager& siteFiles, - File const& databaseFile, + beast::File const& databaseFile, Callback& callback, clock_type& clock, - Journal journal) + beast::Journal journal) { return new ManagerImp (parent, siteFiles, databaseFile, callback, clock, journal); diff --git a/src/ripple/peerfinder/impl/Reporting.h b/src/ripple/peerfinder/impl/Reporting.h index f0f488e0e1..c11b891ae7 100644 --- a/src/ripple/peerfinder/impl/Reporting.h +++ b/src/ripple/peerfinder/impl/Reporting.h @@ -45,23 +45,23 @@ struct Reporting // // Reports from Network (and children) - static Journal::Severity const network = Journal::kWarning; + static beast::Journal::Severity const network = beast::Journal::kWarning; // Reports from simulation Node (and children) - static Journal::Severity const node = Journal::kAll; + static beast::Journal::Severity const node = beast::Journal::kAll; // // // // Reports from Logic - static Journal::Severity const logic = Journal::kAll; + static beast::Journal::Severity const logic = beast::Journal::kAll; // Reports from Livecache - static Journal::Severity const livecache = Journal::kAll; + static beast::Journal::Severity const livecache = beast::Journal::kAll; // Reports from Bootcache - static Journal::Severity const bootcache = Journal::kAll; + static beast::Journal::Severity const bootcache = beast::Journal::kAll; }; } diff --git a/src/ripple/peerfinder/impl/SlotImp.cpp b/src/ripple/peerfinder/impl/SlotImp.cpp index 592cc07c44..df5161ed06 100644 --- a/src/ripple/peerfinder/impl/SlotImp.cpp +++ b/src/ripple/peerfinder/impl/SlotImp.cpp @@ -22,8 +22,8 @@ namespace ripple { namespace PeerFinder { -SlotImp::SlotImp (IP::Endpoint const& local_endpoint, - IP::Endpoint const& remote_endpoint, bool fixed, +SlotImp::SlotImp (beast::IP::Endpoint const& local_endpoint, + beast::IP::Endpoint const& remote_endpoint, bool fixed, clock_type& clock) : recent (clock) , m_inbound (true) @@ -38,7 +38,7 @@ SlotImp::SlotImp (IP::Endpoint const& local_endpoint, { } -SlotImp::SlotImp (IP::Endpoint const& remote_endpoint, +SlotImp::SlotImp (beast::IP::Endpoint const& remote_endpoint, bool fixed, clock_type& clock) : recent (clock) , m_inbound (false) @@ -97,7 +97,7 @@ SlotImp::recent_t::recent_t (clock_type& clock) } void -SlotImp::recent_t::insert (IP::Endpoint const& ep, int hops) +SlotImp::recent_t::insert (beast::IP::Endpoint const& ep, int hops) { auto const result (cache.emplace (ep, hops)); if (! result.second) @@ -112,7 +112,7 @@ SlotImp::recent_t::insert (IP::Endpoint const& ep, int hops) } bool -SlotImp::recent_t::filter (IP::Endpoint const& ep, int hops) +SlotImp::recent_t::filter (beast::IP::Endpoint const& ep, int hops) { auto const iter (cache.find (ep)); if (iter == cache.end()) diff --git a/src/ripple/peerfinder/impl/SlotImp.h b/src/ripple/peerfinder/impl/SlotImp.h index 5294097bbe..940971c480 100644 --- a/src/ripple/peerfinder/impl/SlotImp.h +++ b/src/ripple/peerfinder/impl/SlotImp.h @@ -33,18 +33,18 @@ namespace PeerFinder { class SlotImp : public Slot { private: - typedef beast::aged_unordered_map recent_type; + typedef beast::aged_unordered_map recent_type; public: typedef std::shared_ptr ptr; // inbound - SlotImp (IP::Endpoint const& local_endpoint, - IP::Endpoint const& remote_endpoint, bool fixed, + SlotImp (beast::IP::Endpoint const& local_endpoint, + beast::IP::Endpoint const& remote_endpoint, bool fixed, clock_type& clock); // outbound - SlotImp (IP::Endpoint const& remote_endpoint, + SlotImp (beast::IP::Endpoint const& remote_endpoint, bool fixed, clock_type& clock); bool inbound () const @@ -67,12 +67,12 @@ public: return m_state; } - IP::Endpoint const& remote_endpoint () const + beast::IP::Endpoint const& remote_endpoint () const { return m_remote_endpoint; } - boost::optional const& local_endpoint () const + boost::optional const& local_endpoint () const { return m_local_endpoint; } @@ -82,12 +82,12 @@ public: return m_public_key; } - void local_endpoint (IP::Endpoint const& endpoint) + void local_endpoint (beast::IP::Endpoint const& endpoint) { m_local_endpoint = endpoint; } - void remote_endpoint (IP::Endpoint const& endpoint) + void remote_endpoint (beast::IP::Endpoint const& endpoint) { m_remote_endpoint = endpoint; } @@ -122,10 +122,10 @@ public: We also insert messages that we send to the slot to prevent sending a slot the same address too frequently. */ - void insert (IP::Endpoint const& ep, int hops); + void insert (beast::IP::Endpoint const& ep, int hops); /** Returns `true` if we should not send endpoint to the slot. */ - bool filter (IP::Endpoint const& ep, int hops); + bool filter (beast::IP::Endpoint const& ep, int hops); private: void expire (); @@ -144,8 +144,8 @@ private: bool const m_fixed; bool m_cluster; State m_state; - IP::Endpoint m_remote_endpoint; - boost::optional m_local_endpoint; + beast::IP::Endpoint m_remote_endpoint; + boost::optional m_local_endpoint; boost::optional m_public_key; public: diff --git a/src/ripple/peerfinder/impl/Source.h b/src/ripple/peerfinder/impl/Source.h index 1a28ffae9c..8510de450e 100644 --- a/src/ripple/peerfinder/impl/Source.h +++ b/src/ripple/peerfinder/impl/Source.h @@ -31,14 +31,14 @@ namespace PeerFinder { be updated automatically. Another solution is to use a custom DNS server that hands out peer IP addresses when name lookups are performed. */ -class Source : public SharedObject +class Source : public beast::SharedObject { public: /** The results of a fetch. */ struct Results { // error_code on a failure - ErrorCode error; + beast::ErrorCode error; // list of fetched endpoints IPAddresses addresses; @@ -47,7 +47,7 @@ public: virtual ~Source () { } virtual std::string const& name () = 0; virtual void cancel () { } - virtual void fetch (Results& results, Journal journal) = 0; + virtual void fetch (Results& results, beast::Journal journal) = 0; }; } diff --git a/src/ripple/peerfinder/impl/SourceStrings.cpp b/src/ripple/peerfinder/impl/SourceStrings.cpp index 9b929eb73f..9028b66a5b 100644 --- a/src/ripple/peerfinder/impl/SourceStrings.cpp +++ b/src/ripple/peerfinder/impl/SourceStrings.cpp @@ -38,15 +38,15 @@ public: return m_name; } - void fetch (Results& results, Journal journal) + void fetch (Results& results, beast::Journal journal) { results.addresses.resize (0); results.addresses.reserve (m_strings.size()); for (int i = 0; i < m_strings.size (); ++i) { - IP::Endpoint ep (IP::Endpoint::from_string (m_strings [i])); + beast::IP::Endpoint ep (beast::IP::Endpoint::from_string (m_strings [i])); if (is_unspecified (ep)) - ep = IP::Endpoint::from_string_altform (m_strings [i]); + ep = beast::IP::Endpoint::from_string_altform (m_strings [i]); if (! is_unspecified (ep)) results.addresses.push_back (ep); } @@ -59,7 +59,8 @@ private: //------------------------------------------------------------------------------ -SharedPtr SourceStrings::New (std::string const& name, Strings const& strings) +beast::SharedPtr +SourceStrings::New (std::string const& name, Strings const& strings) { return new SourceStringsImp (name, strings); } diff --git a/src/ripple/peerfinder/impl/SourceStrings.h b/src/ripple/peerfinder/impl/SourceStrings.h index 5d40da9051..96a84d5724 100644 --- a/src/ripple/peerfinder/impl/SourceStrings.h +++ b/src/ripple/peerfinder/impl/SourceStrings.h @@ -29,7 +29,7 @@ class SourceStrings : public Source public: typedef std::vector Strings; - static SharedPtr New (std::string const& name, Strings const& strings); + static beast::SharedPtr New (std::string const& name, Strings const& strings); }; } diff --git a/src/ripple/peerfinder/impl/Store.h b/src/ripple/peerfinder/impl/Store.h index 5881d989f8..1727a7c576 100644 --- a/src/ripple/peerfinder/impl/Store.h +++ b/src/ripple/peerfinder/impl/Store.h @@ -30,13 +30,13 @@ public: virtual ~Store () { } // load the bootstrap cache - typedef std::function load_callback; + typedef std::function load_callback; virtual std::size_t load (load_callback const& cb) = 0; // save the bootstrap cache struct Entry { - IP::Endpoint endpoint; + beast::IP::Endpoint endpoint; int valence; }; virtual void save (std::vector const& v) = 0; diff --git a/src/ripple/peerfinder/impl/StoreSqdb.h b/src/ripple/peerfinder/impl/StoreSqdb.h index e7457a1da7..c247c861fd 100644 --- a/src/ripple/peerfinder/impl/StoreSqdb.h +++ b/src/ripple/peerfinder/impl/StoreSqdb.h @@ -26,11 +26,11 @@ namespace PeerFinder { /** Database persistence for PeerFinder using SQLite */ class StoreSqdb : public Store - , public LeakChecked + , public beast::LeakChecked { private: - Journal m_journal; - sqdb::session m_session; + beast::Journal m_journal; + beast::sqdb::session m_session; public: enum @@ -39,7 +39,7 @@ public: currentSchemaVersion = 4 }; - explicit StoreSqdb (Journal journal = Journal()) + explicit StoreSqdb (beast::Journal journal = beast::Journal()) : m_journal (journal) { } @@ -48,9 +48,9 @@ public: { } - Error open (File const& file) + beast::Error open (beast::File const& file) { - Error error (m_session.open (file.getFullPathName ())); + beast::Error error (m_session.open (file.getFullPathName ())); m_journal.info << "Opening database at '" << file.getFullPathName() << "'"; @@ -68,24 +68,24 @@ public: std::size_t load (load_callback const& cb) { std::size_t n (0); - Error error; + beast::Error error; std::string s; int valence; - sqdb::statement st = (m_session.prepare << + beast::sqdb::statement st = (m_session.prepare << "SELECT " " address, " " valence " "FROM PeerFinder_BootstrapCache " - , sqdb::into (s) - , sqdb::into (valence) + , beast::sqdb::into (s) + , beast::sqdb::into (valence) ); if (st.execute_and_fetch (error)) { do { - IP::Endpoint const endpoint ( - IP::Endpoint::from_string (s)); + beast::IP::Endpoint const endpoint ( + beast::IP::Endpoint::from_string (s)); if (! is_unspecified (endpoint)) { @@ -111,8 +111,8 @@ public: // void save (std::vector const& v) { - Error error; - sqdb::transaction tr (m_session); + beast::Error error; + beast::sqdb::transaction tr (m_session); m_session.once (error) << "DELETE FROM PeerFinder_BootstrapCache"; if (! error) @@ -120,15 +120,15 @@ public: std::string s; int valence; - sqdb::statement st = (m_session.prepare << + beast::sqdb::statement st = (m_session.prepare << "INSERT INTO PeerFinder_BootstrapCache ( " " address, " " valence " ") VALUES ( " " ?, ? " ");" - , sqdb::use (s) - , sqdb::use (valence) + , beast::sqdb::use (s) + , beast::sqdb::use (valence) ); for (auto const& e : v) @@ -154,11 +154,11 @@ public: // Convert any existing entries from an older schema to the // current one, if appropriate. // - Error update () + beast::Error update () { - Error error; + beast::Error error; - sqdb::transaction tr (m_session); + beast::sqdb::transaction tr (m_session); // get version int version (0); @@ -169,7 +169,7 @@ public: " version " "FROM SchemaVersion WHERE " " name = 'PeerFinder'" - ,sqdb::into (version) + ,beast::sqdb::into (version) ; if (! error) @@ -219,7 +219,7 @@ public: if (! error) m_session.once (error) << "SELECT COUNT(*) FROM PeerFinder_BootstrapCache " - ,sqdb::into (count) + ,beast::sqdb::into (count) ; std::vector list; @@ -229,13 +229,13 @@ public: list.reserve (count); std::string s; int valence; - sqdb::statement st = (m_session.prepare << + beast::sqdb::statement st = (m_session.prepare << "SELECT " " address, " " valence " "FROM PeerFinder_BootstrapCache " - , sqdb::into (s) - , sqdb::into (valence) + , beast::sqdb::into (s) + , beast::sqdb::into (valence) ); if (st.execute_and_fetch (error)) @@ -243,7 +243,7 @@ public: do { Store::Entry entry; - entry.endpoint = IP::Endpoint::from_string (s); + entry.endpoint = beast::IP::Endpoint::from_string (s); if (! is_unspecified (entry.endpoint)) { entry.valence = valence; @@ -263,15 +263,15 @@ public: { std::string s; int valence; - sqdb::statement st = (m_session.prepare << + beast::sqdb::statement st = (m_session.prepare << "INSERT INTO PeerFinder_BootstrapCache_Next ( " " address, " " valence " ") VALUES ( " " ?, ?" ");" - , sqdb::use (s) - , sqdb::use (valence) + , beast::sqdb::use (s) + , beast::sqdb::use (valence) ); for (auto iter (list.cbegin()); @@ -340,7 +340,7 @@ public: ") VALUES ( " " 'PeerFinder', ? " ")" - ,sqdb::use(version); + ,beast::sqdb::use(version); } if (! error) @@ -356,10 +356,10 @@ public: } private: - Error init () + beast::Error init () { - Error error; - sqdb::transaction tr (m_session); + beast::Error error; + beast::sqdb::transaction tr (m_session); if (! error) m_session.once (error) << @@ -403,13 +403,13 @@ private: return error; } - void report (Error const& error, char const* fileName, int lineNumber) + void report (beast::Error const& error, char const* fileName, int lineNumber) { if (error) { m_journal.error << "Failure: '"<< error.getReasonText() << "' " << - " at " << Debug::getSourceLocation (fileName, lineNumber); + " at " << beast::Debug::getSourceLocation (fileName, lineNumber); } } }; diff --git a/src/ripple/peerfinder/ripple_peerfinder.cpp b/src/ripple/peerfinder/ripple_peerfinder.cpp index 40713a5871..2f982d4a8d 100644 --- a/src/ripple/peerfinder/ripple_peerfinder.cpp +++ b/src/ripple/peerfinder/ripple_peerfinder.cpp @@ -44,10 +44,6 @@ #include "impl/iosformat.h" // VFALCO NOTE move to beast -namespace ripple { -using namespace beast; -} - #ifndef NDEBUG # define consistency_check(cond) bassert(cond) #else diff --git a/src/ripple/peerfinder/ripple_peerfinder.h b/src/ripple/peerfinder/ripple_peerfinder.h index 5b23ab75f4..38281e6b0a 100644 --- a/src/ripple/peerfinder/ripple_peerfinder.h +++ b/src/ripple/peerfinder/ripple_peerfinder.h @@ -24,10 +24,6 @@ #include "../sitefiles/ripple_sitefiles.h" -namespace ripple { -using namespace beast; -} - #include "../types/api/RipplePublicKey.h" #include "api/Slot.h" diff --git a/src/ripple/peerfinder/sim/Predicates.h b/src/ripple/peerfinder/sim/Predicates.h index 848359fe91..fab20cb831 100644 --- a/src/ripple/peerfinder/sim/Predicates.h +++ b/src/ripple/peerfinder/sim/Predicates.h @@ -59,7 +59,7 @@ is_remote_node_pred is_remote_node (Node const* node) class is_remote_endpoint { public: - explicit is_remote_endpoint (IP::Endpoint const& address) + explicit is_remote_endpoint (beast::IP::Endpoint const& address) : m_endpoint (address) { } template @@ -68,7 +68,7 @@ public: return link.remote_endpoint() == m_endpoint; } private: - IP::Endpoint const m_endpoint; + beast::IP::Endpoint const m_endpoint; }; } diff --git a/src/ripple/peerfinder/sim/WrappedSink.h b/src/ripple/peerfinder/sim/WrappedSink.h index d32fa993f5..b4d7c45bda 100644 --- a/src/ripple/peerfinder/sim/WrappedSink.h +++ b/src/ripple/peerfinder/sim/WrappedSink.h @@ -24,16 +24,16 @@ namespace ripple { namespace PeerFinder { /** Wraps a Journal::Sink to prefix it's output. */ -class WrappedSink : public Journal::Sink +class WrappedSink : public beast::Journal::Sink { public: - WrappedSink (std::string const& prefix, Journal::Sink& sink) + WrappedSink (std::string const& prefix, beast::Journal::Sink& sink) : m_prefix (prefix) , m_sink (sink) { } - bool active (Journal::Severity level) const + bool active (beast::Journal::Severity level) const { return m_sink.active (level); } bool console () const @@ -42,14 +42,15 @@ public: void console (bool output) { m_sink.console (output); } - Journal::Severity severity() const + beast::Journal::Severity severity() const { return m_sink.severity(); } - void severity (Journal::Severity level) + void severity (beast::Journal::Severity level) { m_sink.severity (level); } - void write (Journal::Severity level, std::string const& text) + void write (beast::Journal::Severity level, std::string const& text) { + using beast::Journal; std::string s (m_prefix); switch (level) { @@ -68,7 +69,7 @@ public: private: std::string const m_prefix; - Journal::Sink& m_sink; + beast::Journal::Sink& m_sink; }; } diff --git a/src/ripple/resource/api/Gossip.h b/src/ripple/resource/api/Gossip.h index 9e4216fea0..74968cde6a 100644 --- a/src/ripple/resource/api/Gossip.h +++ b/src/ripple/resource/api/Gossip.h @@ -30,7 +30,7 @@ struct Gossip struct Item { int balance; - IP::Endpoint address; + beast::IP::Endpoint address; }; std::vector items; diff --git a/src/ripple/resource/api/Manager.h b/src/ripple/resource/api/Manager.h index 670a6f9d62..118d92fd66 100644 --- a/src/ripple/resource/api/Manager.h +++ b/src/ripple/resource/api/Manager.h @@ -26,7 +26,7 @@ namespace ripple { namespace Resource { /** Tracks load and resource consumption. */ -class Manager : public PropertyStream::Source +class Manager : public beast::PropertyStream::Source { protected: Manager (); @@ -35,10 +35,10 @@ public: virtual ~Manager() = 0; /** Create a new endpoint keyed by inbound IP address. */ - virtual Consumer newInboundEndpoint (IP::Endpoint const& address) = 0; + virtual Consumer newInboundEndpoint (beast::IP::Endpoint const& address) = 0; /** Create a new endpoint keyed by outbound IP address and port. */ - virtual Consumer newOutboundEndpoint (IP::Endpoint const& address) = 0; + virtual Consumer newOutboundEndpoint (beast::IP::Endpoint const& address) = 0; /** Create a new endpoint keyed by name. */ virtual Consumer newAdminEndpoint (std::string const& name) = 0; @@ -59,8 +59,8 @@ public: //------------------------------------------------------------------------------ std::unique_ptr make_Manager ( - insight::Collector::ptr const& collector, - Journal journal); + beast::insight::Collector::ptr const& collector, + beast::Journal journal); } } diff --git a/src/ripple/resource/impl/Entry.h b/src/ripple/resource/impl/Entry.h index 3cb5210fb4..021c603f9c 100644 --- a/src/ripple/resource/impl/Entry.h +++ b/src/ripple/resource/impl/Entry.h @@ -23,10 +23,10 @@ namespace ripple { namespace Resource { -typedef abstract_clock clock_type; +typedef beast::abstract_clock clock_type; // An entry in the table -struct Entry : public List ::Node +struct Entry : public beast::List ::Node { // Dummy argument is necessary for zero-copy construction of elements Entry (int) diff --git a/src/ripple/resource/impl/Key.h b/src/ripple/resource/impl/Key.h index bc24404b81..45ef30dc7b 100644 --- a/src/ripple/resource/impl/Key.h +++ b/src/ripple/resource/impl/Key.h @@ -27,7 +27,7 @@ namespace Resource { struct Key { Kind kind; - IP::Endpoint address; + beast::IP::Endpoint address; std::string name; struct hasher @@ -51,7 +51,7 @@ struct Key } private: - std::hash m_addr_hash; + std::hash m_addr_hash; boost::hash m_name_hash; }; diff --git a/src/ripple/resource/impl/Logic.h b/src/ripple/resource/impl/Logic.h index 711f98998c..932864e009 100644 --- a/src/ripple/resource/impl/Logic.h +++ b/src/ripple/resource/impl/Logic.h @@ -26,7 +26,7 @@ namespace Resource { class Logic { public: - typedef abstract_clock clock_type; + typedef beast::abstract_clock clock_type; typedef boost::unordered_map Imports; typedef boost::unordered_map Table; @@ -36,44 +36,44 @@ public: Table table; // List of all active inbound entries - List inbound; + beast::List inbound; // List of all active outbound entries - List outbound; + beast::List outbound; // List of all active admin entries - List admin; + beast::List admin; // List of all inactve entries - List inactive; + beast::List inactive; // All imported gossip data Imports import_table; }; - typedef SharedData SharedState; + typedef beast::SharedData SharedState; struct Stats { - Stats (insight::Collector::ptr const& collector) + Stats (beast::insight::Collector::ptr const& collector) { warn = collector->make_meter ("warn"); drop = collector->make_meter ("drop"); } - insight::Meter warn; - insight::Meter drop; + beast::insight::Meter warn; + beast::insight::Meter drop; }; SharedState m_state; Stats m_stats; - abstract_clock & m_clock; - Journal m_journal; + beast::abstract_clock & m_clock; + beast::Journal m_journal; //-------------------------------------------------------------------------- - Logic (insight::Collector::ptr const& collector, - clock_type& clock, Journal journal) + Logic (beast::insight::Collector::ptr const& collector, + clock_type& clock, beast::Journal journal) : m_stats (collector) , m_clock (clock) , m_journal (journal) @@ -92,7 +92,7 @@ public: state->table.clear(); } - Consumer newInboundEndpoint (IP::Endpoint const& address) + Consumer newInboundEndpoint (beast::IP::Endpoint const& address) { if (isWhitelisted (address)) return newAdminEndpoint (to_string (address)); @@ -125,7 +125,7 @@ public: return Consumer (*this, *entry); } - Consumer newOutboundEndpoint (IP::Endpoint const& address) + Consumer newOutboundEndpoint (beast::IP::Endpoint const& address) { if (isWhitelisted (address)) return newAdminEndpoint (to_string (address)); @@ -232,7 +232,7 @@ public: Json::Value ret (Json::objectValue); SharedState::Access state (m_state); - for (List ::iterator iter (state->inbound.begin()); + for (beast::List ::iterator iter (state->inbound.begin()); iter != state->inbound.end(); ++iter) { int localBalance = iter->local_balance.value (now); @@ -245,7 +245,7 @@ public: } } - for (List ::iterator iter (state->outbound.begin()); + for (beast::List ::iterator iter (state->outbound.begin()); iter != state->outbound.end(); ++iter) { int localBalance = iter->local_balance.value (now); @@ -258,7 +258,7 @@ public: } } - for (List ::iterator iter (state->admin.begin()); + for (beast::List ::iterator iter (state->admin.begin()); iter != state->admin.end(); ++iter) { int localBalance = iter->local_balance.value (now); @@ -284,7 +284,7 @@ public: gossip.items.reserve (state->inbound.size()); - for (List ::iterator iter (state->inbound.begin()); + for (beast::List ::iterator iter (state->inbound.begin()); iter != state->inbound.end(); ++iter) { Gossip::Item item; @@ -358,7 +358,7 @@ public: //-------------------------------------------------------------------------- - bool isWhitelisted (IP::Endpoint const& address) + bool isWhitelisted (beast::IP::Endpoint const& address) { if (! is_public (address)) return true; @@ -374,7 +374,7 @@ public: clock_type::rep const now (m_clock.elapsed()); - for (List ::iterator iter ( + for (beast::List ::iterator iter ( state->inactive.begin()); iter != state->inactive.end();) { if (iter->whenExpires <= now) @@ -565,13 +565,13 @@ public: void writeList ( clock_type::rep const now, - PropertyStream::Set& items, - List & list) + beast::PropertyStream::Set& items, + beast::List & list) { - for (List ::iterator iter (list.begin()); + for (beast::List ::iterator iter (list.begin()); iter != list.end(); ++iter) { - PropertyStream::Map item (items); + beast::PropertyStream::Map item (items); if (iter->refcount != 0) item ["count"] = iter->refcount; item ["name"] = iter->to_string(); @@ -581,29 +581,29 @@ public: } } - void onWrite (PropertyStream::Map& map) + void onWrite (beast::PropertyStream::Map& map) { clock_type::rep const now (m_clock.elapsed()); SharedState::Access state (m_state); { - PropertyStream::Set s ("inbound", map); + beast::PropertyStream::Set s ("inbound", map); writeList (now, s, state->inbound); } { - PropertyStream::Set s ("outbound", map); + beast::PropertyStream::Set s ("outbound", map); writeList (now, s, state->outbound); } { - PropertyStream::Set s ("admin", map); + beast::PropertyStream::Set s ("admin", map); writeList (now, s, state->admin); } { - PropertyStream::Set s ("inactive", map); + beast::PropertyStream::Set s ("inactive", map); writeList (now, s, state->inactive); } } diff --git a/src/ripple/resource/impl/Manager.cpp b/src/ripple/resource/impl/Manager.cpp index 5506d6fae5..301a7b24f3 100644 --- a/src/ripple/resource/impl/Manager.cpp +++ b/src/ripple/resource/impl/Manager.cpp @@ -22,14 +22,14 @@ namespace Resource { class ManagerImp : public Manager - , public Thread + , public beast::Thread { public: - Journal m_journal; + beast::Journal m_journal; Logic m_logic; - ManagerImp (insight::Collector::ptr const& collector, - Journal journal) + ManagerImp (beast::insight::Collector::ptr const& collector, + beast::Journal journal) : Thread ("Resource::Manager") , m_journal (journal) , m_logic (collector, get_seconds_clock (), journal) @@ -42,12 +42,12 @@ public: stopThread (); } - Consumer newInboundEndpoint (IP::Endpoint const& address) + Consumer newInboundEndpoint (beast::IP::Endpoint const& address) { return m_logic.newInboundEndpoint (address); } - Consumer newOutboundEndpoint (IP::Endpoint const& address) + Consumer newOutboundEndpoint (beast::IP::Endpoint const& address) { return m_logic.newOutboundEndpoint (address); } @@ -81,7 +81,7 @@ public: //-------------------------------------------------------------------------- - void onWrite (PropertyStream::Map& map) + void onWrite (beast::PropertyStream::Map& map) { m_logic.onWrite (map); } @@ -102,7 +102,7 @@ public: //------------------------------------------------------------------------------ Manager::Manager () - : PropertyStream::Source ("resource") + : beast::PropertyStream::Source ("resource") { } @@ -113,8 +113,8 @@ Manager::~Manager () //------------------------------------------------------------------------------ std::unique_ptr make_Manager ( - insight::Collector::ptr const& collector, - Journal journal) + beast::insight::Collector::ptr const& collector, + beast::Journal journal) { return std::make_unique (collector, journal); } diff --git a/src/ripple/resource/impl/Tests.cpp b/src/ripple/resource/impl/Tests.cpp index 7364866b25..5d820d12ba 100644 --- a/src/ripple/resource/impl/Tests.cpp +++ b/src/ripple/resource/impl/Tests.cpp @@ -20,21 +20,21 @@ namespace ripple { namespace Resource { -class Tests : public UnitTest +class Tests : public beast::UnitTest { public: class TestLogic - : private boost::base_from_member > + : private boost::base_from_member > , public Logic { private: typedef boost::base_from_member < - manual_clock > clock_type; + beast::manual_clock > clock_type; public: - explicit TestLogic (Journal journal) - : Logic (insight::NullCollector::New(), member, journal) + explicit TestLogic (beast::Journal journal) + : Logic (beast::insight::NullCollector::New(), member, journal) { } @@ -43,7 +43,7 @@ public: ++member; } - manual_clock & clock () + beast::manual_clock & clock () { return member; } @@ -60,8 +60,8 @@ public: { Gossip::Item item; item.balance = 100 + random().nextInt (500); - item.address = IP::Endpoint ( - IP::AddressV4 (207, 127, 82, v + i)); + item.address = beast::IP::Endpoint ( + beast::IP::AddressV4 (207, 127, 82, v + i)); gossip.items.push_back (item); } } @@ -73,15 +73,15 @@ public: maxLoopCount = 10000 }; - void testDrop (Journal j) + void testDrop (beast::Journal j) { beginTestCase ("Warn/drop"); Tests::TestLogic logic (j); Charge const fee (dropThreshold + 1); - IP::Endpoint const addr ( - IP::Endpoint::from_string ("207.127.82.2")); + beast::IP::Endpoint const addr ( + beast::IP::Endpoint::from_string ("207.127.82.2")); { Consumer c (logic.newInboundEndpoint (addr)); @@ -144,7 +144,7 @@ public: } } - void testImports (Journal j) + void testImports (beast::Journal j) { beginTestCase ("Imports"); @@ -156,12 +156,12 @@ public: createGossip (g[i]); for (int i = 0; i < 5; ++i) - logic.importConsumers (String::fromNumber (i).toStdString(), g[i]); + logic.importConsumers (beast::String::fromNumber (i).toStdString(), g[i]); pass(); } - void testImport (Journal j) + void testImport (beast::Journal j) { beginTestCase ("Import"); @@ -170,8 +170,8 @@ public: Gossip g; Gossip::Item item; item.balance = 100; - item.address = IP::Endpoint ( - IP::AddressV4 (207, 127, 82, 1)); + item.address = beast::IP::Endpoint ( + beast::IP::AddressV4 (207, 127, 82, 1)); g.items.push_back (item); logic.importConsumers ("g", g); @@ -179,14 +179,14 @@ public: pass(); } - void testCharges (Journal j) + void testCharges (beast::Journal j) { beginTestCase ("Charge"); TestLogic logic (j); { - IP::Endpoint address (IP::Endpoint::from_string ("207.127.82.1")); + beast::IP::Endpoint address (beast::IP::Endpoint::from_string ("207.127.82.1")); Consumer c (logic.newInboundEndpoint (address)); Charge fee (1000); j.info << @@ -202,7 +202,7 @@ public: } { - IP::Endpoint address (IP::Endpoint::from_string ("207.127.82.2")); + beast::IP::Endpoint address (beast::IP::Endpoint::from_string ("207.127.82.2")); Consumer c (logic.newInboundEndpoint (address)); Charge fee (1000); j.info << @@ -223,7 +223,7 @@ public: void runTest () { //Journal j (journal()); - Journal j; + beast::Journal j; testDrop (j); testCharges (j); diff --git a/src/ripple/resource/ripple_resource.h b/src/ripple/resource/ripple_resource.h index daa6c1e5f0..03c346b9d8 100644 --- a/src/ripple/resource/ripple_resource.h +++ b/src/ripple/resource/ripple_resource.h @@ -22,10 +22,6 @@ #include "../beast/modules/beast_core/beast_core.h" -namespace ripple { -using namespace beast; -} - #include "../json/ripple_json.h" # include "api/Types.h" diff --git a/src/ripple/sitefiles/api/Manager.h b/src/ripple/sitefiles/api/Manager.h index 555d02ea4e..4bb16d164d 100644 --- a/src/ripple/sitefiles/api/Manager.h +++ b/src/ripple/sitefiles/api/Manager.h @@ -25,15 +25,15 @@ namespace SiteFiles { /** Fetches and maintains a collection of ripple.txt files from domains. */ class Manager - : public Stoppable - , public PropertyStream::Source + : public beast::Stoppable + , public beast::PropertyStream::Source { protected: explicit Manager (Stoppable& parent); public: /** Create a new Manager. */ - static Manager* New (Stoppable& parent, Journal journal); + static Manager* New (beast::Stoppable& parent, beast::Journal journal); /** Destroy the object. Any pending fetch operations are aborted. diff --git a/src/ripple/sitefiles/impl/Logic.h b/src/ripple/sitefiles/impl/Logic.h index 584bfb3a1d..2e771def19 100644 --- a/src/ripple/sitefiles/impl/Logic.h +++ b/src/ripple/sitefiles/impl/Logic.h @@ -60,7 +60,7 @@ class Logic { public: typedef std::set Listeners; - typedef boost::unordered_map SiteFiles; + typedef boost::unordered_map SiteFiles; struct State { @@ -72,13 +72,13 @@ public: SiteFiles files; }; - typedef SharedData SharedState; + typedef beast::SharedData SharedState; SharedState m_state; - Journal m_journal; + beast::Journal m_journal; std::unique_ptr m_client; - explicit Logic (Journal journal) + explicit Logic (beast::Journal journal) : m_journal (journal) , m_client (beast::asio::HTTPClientBase::New (journal)) { @@ -116,7 +116,7 @@ public: void addURL (std::string const& urlstr) { - ParsedURL const p (urlstr); + beast::ParsedURL const p (urlstr); if (p.error()) { @@ -125,7 +125,7 @@ public: return; } - URL const& url (p.url()); + beast::URL const& url (p.url()); auto const result (m_client->get (url)); @@ -141,7 +141,7 @@ public: return; } - HTTPResponse const& response (*result.second); + beast::HTTPResponse const& response (*result.second); processResponse (url, response); } @@ -152,7 +152,7 @@ public: // //-------------------------------------------------------------------------- - void processResponse (URL const& url, HTTPResponse const& response) + void processResponse (beast::URL const& url, beast::HTTPResponse const& response) { SharedState::Access state (m_state); @@ -286,7 +286,7 @@ public: } } - void parse (SiteFile& siteFile, HTTPResponse const& response) + void parse (SiteFile& siteFile, beast::HTTPResponse const& response) { std::string const s (response.body().to_string()); parse (siteFile, s.begin(), s.end()); diff --git a/src/ripple/sitefiles/impl/Manager.cpp b/src/ripple/sitefiles/impl/Manager.cpp index b32bdfc5f5..46455e68b0 100644 --- a/src/ripple/sitefiles/impl/Manager.cpp +++ b/src/ripple/sitefiles/impl/Manager.cpp @@ -20,23 +20,23 @@ namespace ripple { namespace SiteFiles { -typedef ScopedWrapperContext < - RecursiveMutex, RecursiveMutex::ScopedLockType> SerializedContext; +typedef beast::ScopedWrapperContext < + beast::RecursiveMutex, beast::RecursiveMutex::ScopedLockType> SerializedContext; class ManagerImp : public Manager - , public Thread - , public DeadlineTimer::Listener - , public LeakChecked + , public beast::Thread + , public beast::DeadlineTimer::Listener + , public beast::LeakChecked { public: Logic m_logic; - Journal m_journal; - ServiceQueue m_queue; + beast::Journal m_journal; + beast::ServiceQueue m_queue; //-------------------------------------------------------------------------- - ManagerImp (Stoppable& stoppable, Journal journal) + ManagerImp (Stoppable& stoppable, beast::Journal journal) : Manager (stoppable) , Thread ("SiteFiles") , m_logic (journal) @@ -101,7 +101,7 @@ public: // //-------------------------------------------------------------------------- - void onWrite (PropertyStream::Map& map) + void onWrite (beast::PropertyStream::Map& map) { //SerializedContext::Scope scope (m_context); @@ -110,7 +110,7 @@ public: //-------------------------------------------------------------------------- - void onDeadlineTimer (DeadlineTimer& timer) + void onDeadlineTimer (beast::DeadlineTimer& timer) { } @@ -128,11 +128,11 @@ public: Manager::Manager (Stoppable& parent) : Stoppable ("PeerFinder", parent) - , PropertyStream::Source ("peerfinder") + , beast::PropertyStream::Source ("peerfinder") { } -Manager* Manager::New (Stoppable& parent, Journal journal) +Manager* Manager::New (Stoppable& parent, beast::Journal journal) { return new ManagerImp (parent, journal); } diff --git a/src/ripple/sitefiles/ripple_sitefiles.h b/src/ripple/sitefiles/ripple_sitefiles.h index 0b5a3e7f78..32929cf803 100644 --- a/src/ripple/sitefiles/ripple_sitefiles.h +++ b/src/ripple/sitefiles/ripple_sitefiles.h @@ -29,10 +29,6 @@ #include "../beast/beast/Threads.h" #include "../beast/beast/Utility.h" -namespace ripple { -using namespace beast; -} - # include "api/Section.h" # include "api/SiteFile.h" # include "api/Listener.h" diff --git a/src/ripple/sslutil/api/CAutoBN_CTX.h b/src/ripple/sslutil/api/CAutoBN_CTX.h index 96b9a5caa5..b21d03d764 100644 --- a/src/ripple/sslutil/api/CAutoBN_CTX.h +++ b/src/ripple/sslutil/api/CAutoBN_CTX.h @@ -29,7 +29,7 @@ namespace ripple { -class CAutoBN_CTX : public Uncopyable +class CAutoBN_CTX : public beast::Uncopyable { protected: BN_CTX* pctx; diff --git a/src/ripple/sslutil/api/CBigNum.h b/src/ripple/sslutil/api/CBigNum.h index 543b5cdc6a..9805ba4c78 100644 --- a/src/ripple/sslutil/api/CBigNum.h +++ b/src/ripple/sslutil/api/CBigNum.h @@ -42,11 +42,11 @@ public: CBigNum (short n); CBigNum (int n); CBigNum (long n); - CBigNum (int64 n); + CBigNum (beast::int64 n); CBigNum (unsigned char n); CBigNum (unsigned short n); CBigNum (unsigned int n); - CBigNum (uint64 n); + CBigNum (beast::uint64 n); explicit CBigNum (uint256 n); explicit CBigNum (Blob const& vch); CBigNum (unsigned char const* begin, unsigned char const* end); @@ -55,9 +55,9 @@ public: void setuint (unsigned int n); unsigned int getuint () const; int getint () const; - void setint64 (int64 n); - uint64 getuint64 () const; - void setuint64 (uint64 n); + void setint64 (beast::int64 n); + beast::uint64 getuint64 () const; + void setuint64 (beast::uint64 n); void setuint256 (uint256 const& n); uint256 getuint256 (); void setvch (unsigned char const* begin, unsigned char const* end); @@ -111,10 +111,10 @@ bool operator> (const CBigNum& a, const CBigNum& b); //------------------------------------------------------------------------------ // VFALCO I believe only STAmount uses these -int BN_add_word64 (BIGNUM* a, uint64 w); -int BN_sub_word64 (BIGNUM* a, uint64 w); -int BN_mul_word64 (BIGNUM* a, uint64 w); -uint64 BN_div_word64 (BIGNUM* a, uint64 w); +int BN_add_word64 (BIGNUM* a, beast::uint64 w); +int BN_sub_word64 (BIGNUM* a, beast::uint64 w); +int BN_mul_word64 (BIGNUM* a, beast::uint64 w); +beast::uint64 BN_div_word64 (BIGNUM* a, beast::uint64 w); } diff --git a/src/ripple/sslutil/impl/CBigNum.cpp b/src/ripple/sslutil/impl/CBigNum.cpp index c36d702066..9e80f89298 100644 --- a/src/ripple/sslutil/impl/CBigNum.cpp +++ b/src/ripple/sslutil/impl/CBigNum.cpp @@ -81,7 +81,7 @@ CBigNum::CBigNum (long n) if (n >= 0) setulong (n); else setint64 (n); } -CBigNum::CBigNum (int64 n) +CBigNum::CBigNum (beast::int64 n) { BN_init (this); setint64 (n); @@ -101,7 +101,7 @@ CBigNum::CBigNum (unsigned int n) BN_init (this); setulong (n); } -CBigNum::CBigNum (uint64 n) +CBigNum::CBigNum (beast::uint64 n) { BN_init (this); setuint64 (n); @@ -144,13 +144,13 @@ int CBigNum::getint () const return (n > INT_MAX ? INT_MIN : - (int)n); } -void CBigNum::setint64 (int64 n) +void CBigNum::setint64 (beast::int64 n) { unsigned char pch[sizeof (n) + 6]; unsigned char* p = pch + 4; bool fNegative = false; - if (n < (int64)0) + if (n < (beast::int64)0) { n = -n; fNegative = true; @@ -187,10 +187,10 @@ void CBigNum::setint64 (int64 n) BN_mpi2bn (pch, p - pch, this); } -uint64 CBigNum::getuint64 () const +beast::uint64 CBigNum::getuint64 () const { #if (ULONG_MAX > UINT_MAX) - return static_cast (getulong ()); + return static_cast (getulong ()); #else int len = BN_num_bytes (this); @@ -201,14 +201,14 @@ uint64 CBigNum::getuint64 () const memset (buf, 0, sizeof (buf)); BN_bn2bin (this, buf + 8 - len); return - static_cast (buf[0]) << 56 | static_cast (buf[1]) << 48 | - static_cast (buf[2]) << 40 | static_cast (buf[3]) << 32 | - static_cast (buf[4]) << 24 | static_cast (buf[5]) << 16 | - static_cast (buf[6]) << 8 | static_cast (buf[7]); + static_cast (buf[0]) << 56 | static_cast (buf[1]) << 48 | + static_cast (buf[2]) << 40 | static_cast (buf[3]) << 32 | + static_cast (buf[4]) << 24 | static_cast (buf[5]) << 16 | + static_cast (buf[6]) << 8 | static_cast (buf[7]); #endif } -void CBigNum::setuint64 (uint64 n) +void CBigNum::setuint64 (beast::uint64 n) { #if (ULONG_MAX > UINT_MAX) setulong (static_cast (n)); @@ -266,7 +266,7 @@ void CBigNum::setvch (Blob const& vch) Blob CBigNum::getvch () const { - unsigned int nSize = BN_bn2mpi (this, NULL); + unsigned int nSize = BN_bn2mpi (this, nullptr); if (nSize < 4) return Blob (); @@ -296,7 +296,7 @@ CBigNum& CBigNum::SetCompact (unsigned int nCompact) unsigned int CBigNum::GetCompact () const { - unsigned int nSize = BN_bn2mpi (this, NULL); + unsigned int nSize = BN_bn2mpi (this, nullptr); Blob vch (nSize); nSize -= 4; BN_bn2mpi (this, &vch[0]); @@ -553,7 +553,7 @@ const CBigNum operator/ (const CBigNum& a, const CBigNum& b) CAutoBN_CTX pctx; CBigNum r; - if (!BN_div (&r, NULL, &a, &b, pctx)) + if (!BN_div (&r, nullptr, &a, &b, pctx)) throw bignum_error ("CBigNum::operator/ : BN_div failed"); return r; @@ -619,52 +619,52 @@ bool operator> (const CBigNum& a, const CBigNum& b) #if (ULONG_MAX > UINT_MAX) -int BN_add_word64 (BIGNUM* bn, uint64 word) +int BN_add_word64 (BIGNUM* bn, beast::uint64 word) { return BN_add_word (bn, word); } -int BN_sub_word64 (BIGNUM* bn, uint64 word) +int BN_sub_word64 (BIGNUM* bn, beast::uint64 word) { return BN_sub_word (bn, word); } -int BN_mul_word64 (BIGNUM* bn, uint64 word) +int BN_mul_word64 (BIGNUM* bn, beast::uint64 word) { return BN_mul_word (bn, word); } -uint64 BN_div_word64 (BIGNUM* bn, uint64 word) +beast::uint64 BN_div_word64 (BIGNUM* bn, beast::uint64 word) { return BN_div_word (bn, word); } #else -int BN_add_word64 (BIGNUM* a, uint64 w) +int BN_add_word64 (BIGNUM* a, beast::uint64 w) { CBigNum bn (w); return BN_add (a, &bn, a); } -int BN_sub_word64 (BIGNUM* a, uint64 w) +int BN_sub_word64 (BIGNUM* a, beast::uint64 w) { CBigNum bn (w); return BN_sub (a, &bn, a); } -int BN_mul_word64 (BIGNUM* a, uint64 w) +int BN_mul_word64 (BIGNUM* a, beast::uint64 w) { CBigNum bn (w); CAutoBN_CTX ctx; return BN_mul (a, &bn, a, ctx); } -uint64 BN_div_word64 (BIGNUM* a, uint64 w) +beast::uint64 BN_div_word64 (BIGNUM* a, beast::uint64 w) { CBigNum bn (w); CAutoBN_CTX ctx; - return (BN_div (a, NULL, a, &bn, ctx) == 1) ? 0 : ((uint64) - 1); + return (BN_div (a, nullptr, a, &bn, ctx) == 1) ? 0 : ((beast::uint64) - 1); } #endif diff --git a/src/ripple/sslutil/impl/ECDSACanonical.cpp b/src/ripple/sslutil/impl/ECDSACanonical.cpp index d7138b7771..9714a7b9c6 100644 --- a/src/ripple/sslutil/impl/ECDSACanonical.cpp +++ b/src/ripple/sslutil/impl/ECDSACanonical.cpp @@ -196,7 +196,7 @@ void hex_to_binary (FwdIter first, FwdIter last, Container& out) } } -class ECDSACanonicalTests : public UnitTest +class ECDSACanonicalTests : public beast::UnitTest { public: ECDSACanonicalTests () : UnitTest ("ECDSACanonical", "ripple") diff --git a/src/ripple/sslutil/ripple_sslutil.h b/src/ripple/sslutil/ripple_sslutil.h index 628e24bad8..4629fbca98 100644 --- a/src/ripple/sslutil/ripple_sslutil.h +++ b/src/ripple/sslutil/ripple_sslutil.h @@ -29,10 +29,6 @@ #include #include -namespace ripple { -using namespace beast; -} - # include "api/bignum_error.h" #include "api/CAutoBN_CTX.h" #include "api/CBigNum.h" diff --git a/src/ripple/testoverlay/api/ConfigType.h b/src/ripple/testoverlay/api/ConfigType.h index 9de80bf722..ce649154d8 100644 --- a/src/ripple/testoverlay/api/ConfigType.h +++ b/src/ripple/testoverlay/api/ConfigType.h @@ -36,7 +36,7 @@ public: // These defaults can be overridden in // Params simply by adding declarations to it. - static int64 const randomSeedValue = 42; + static beast::int64 const randomSeedValue = 42; typedef std::size_t SizeType; diff --git a/src/ripple/testoverlay/api/PeerType.h b/src/ripple/testoverlay/api/PeerType.h index 95329ca4e7..421d9501c3 100644 --- a/src/ripple/testoverlay/api/PeerType.h +++ b/src/ripple/testoverlay/api/PeerType.h @@ -27,7 +27,7 @@ namespace TestOverlay template class PeerType : public Config - , public Uncopyable + , public beast::Uncopyable { public: typedef typename Config::Peer Peer; diff --git a/src/ripple/testoverlay/api/Results.h b/src/ripple/testoverlay/api/Results.h index 25b28e67c4..a77a5a1cc1 100644 --- a/src/ripple/testoverlay/api/Results.h +++ b/src/ripple/testoverlay/api/Results.h @@ -51,8 +51,9 @@ struct Results return *this; } - String toString () const + beast::String toString () const { + using beast::String; String s; s = "steps(" + String::fromNumber (steps) + ")" + ", sent(" + String::fromNumber (sent) + ")" diff --git a/src/ripple/testoverlay/api/SimplePayload.h b/src/ripple/testoverlay/api/SimplePayload.h index eabdbbb54b..8081b6cd86 100644 --- a/src/ripple/testoverlay/api/SimplePayload.h +++ b/src/ripple/testoverlay/api/SimplePayload.h @@ -31,7 +31,7 @@ public: { } - SimplePayload (int what, String data = String::empty, int hops = 0) + SimplePayload (int what, beast::String data = beast::String::empty, int hops = 0) : m_hops (hops) , m_what (what) , m_data (data) @@ -68,7 +68,7 @@ public: return m_what; } - String data () const + beast::String data () const { return m_data; } @@ -76,7 +76,7 @@ public: private: int m_hops; int m_what; - String m_data; + beast::String m_data; }; } diff --git a/src/ripple/testoverlay/api/StateBase.h b/src/ripple/testoverlay/api/StateBase.h index dc3e23bdd9..91371dc32b 100644 --- a/src/ripple/testoverlay/api/StateBase.h +++ b/src/ripple/testoverlay/api/StateBase.h @@ -31,7 +31,7 @@ public: // Identifies messages and peers. // Always starts at 1 and increases incrementally. // - typedef uint64 UniqueID; + typedef beast::uint64 UniqueID; StateBase () : m_random (Params::randomSeedValue) @@ -40,7 +40,7 @@ public: { } - Random& random () + beast::Random& random () { return m_random; } @@ -56,7 +56,7 @@ public: } private: - Random m_random; + beast::Random m_random; UniqueID m_peerID; UniqueID m_messageID; }; diff --git a/src/ripple/testoverlay/impl/TestOverlay.cpp b/src/ripple/testoverlay/impl/TestOverlay.cpp index fe53b35de5..6a2b282859 100644 --- a/src/ripple/testoverlay/impl/TestOverlay.cpp +++ b/src/ripple/testoverlay/impl/TestOverlay.cpp @@ -19,7 +19,7 @@ namespace TestOverlay { -class Tests : public UnitTest +class Tests : public beast::UnitTest { public: template @@ -115,6 +115,7 @@ public: Results result; for (int i = 0; result.received < 249 && i < 100; ++i) { + using beast::String; String s = String ("step #") + String::fromNumber ( network.steps()) + " "; @@ -125,7 +126,7 @@ public: int const seen (network.state().seen()); - String s = "Seen = " + String::fromNumber (seen); + beast::String s = "Seen = " + beast::String::fromNumber (seen); logMessage (s); pass (); } @@ -429,7 +430,7 @@ private: //------------------------------------------------------------------------------ -class Tests2 : public UnitTest +class Tests2 : public beast::UnitTest { public: class Message : public BasicMessage diff --git a/src/ripple/testoverlay/ripple_testoverlay.h b/src/ripple/testoverlay/ripple_testoverlay.h index 558382fad0..f32eaa1acd 100644 --- a/src/ripple/testoverlay/ripple_testoverlay.h +++ b/src/ripple/testoverlay/ripple_testoverlay.h @@ -40,8 +40,6 @@ namespace ripple { -using namespace beast; - # include "api/Results.h" # include "api/SimplePayload.h" # include "api/MessageType.h" diff --git a/src/ripple/types/api/CryptoIdentifier.h b/src/ripple/types/api/CryptoIdentifier.h index 19475f7619..fa16d593fd 100644 --- a/src/ripple/types/api/CryptoIdentifier.h +++ b/src/ripple/types/api/CryptoIdentifier.h @@ -41,7 +41,7 @@ namespace ripple { representation includes an appended a four byte checksum on the data including the Token. */ -template +template class CryptoIdentifier { public: @@ -52,7 +52,7 @@ public: static size_type const size = Size; // 4 checksum bytes (optional) static std::size_t const post_size = (Checked ? 4 : 0); - static uint8 const token = Token; + static beast::uint8 const token = Token; static bool const checked = Checked; // This is what the wrapper creates, it includes the padding. @@ -64,7 +64,7 @@ public: /** Initialize from an input sequence. */ static void construct ( - uint8 const* begin, uint8 const* end, + beast::uint8 const* begin, beast::uint8 const* end, value_type& value) { value.storage()[0] = Token; @@ -72,8 +72,8 @@ public: std::copy (begin, end, value.begin()); if (Checked) { - Sha256::digest_type digest; - Sha256::hash (Sha256::hash (value.storage().cbegin(), + beast::Sha256::digest_type digest; + beast::Sha256::hash (beast::Sha256::hash (value.storage().cbegin(), value.storage().cend() - post_size), digest); // We use the first 4 bytes as a checksum std::copy (digest.begin(), digest.begin() + 4, @@ -89,9 +89,9 @@ public: static value_type createFromInteger (UnsignedIntegralType i) { static_bassert (size >= sizeof (UnsignedIntegralType)); - FixedArray data; + beast::FixedArray data; data.fill (0); - i = toNetworkByteOrder (i); + i = beast::toNetworkByteOrder (i); std::memcpy (data.end () - sizeof (i), &i, std::min (size, sizeof (i))); value_type value; construct (data.begin(), data.end(), value); @@ -104,7 +104,7 @@ public: { typename value_type::storage_type const& storage (value.storage()); // We will convert to little endian with an extra pad byte - FixedArray le; + beast::FixedArray le; std::reverse_copy (storage.begin(), storage.end(), le.begin()); // Set pad byte zero to make BIGNUM always positive le.back() = 0; @@ -127,7 +127,7 @@ public: } }; -template +template typename CryptoIdentifier ::size_type const CryptoIdentifier ::size; } diff --git a/src/ripple/types/api/HashMaps.h b/src/ripple/types/api/HashMaps.h index 0848e3533c..b35c04083c 100644 --- a/src/ripple/types/api/HashMaps.h +++ b/src/ripple/types/api/HashMaps.h @@ -29,7 +29,7 @@ namespace ripple { done by seeding the hashing function with a random number generated at program startup. */ -class HashMaps : public Uncopyable +class HashMaps : public beast::Uncopyable { public: /** Golden ratio constant used in hashing functions. diff --git a/src/ripple/types/api/IdentifierStorage.h b/src/ripple/types/api/IdentifierStorage.h index 0f64009048..37c22446e5 100644 --- a/src/ripple/types/api/IdentifierStorage.h +++ b/src/ripple/types/api/IdentifierStorage.h @@ -32,7 +32,7 @@ class IdentifierStorage public: typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; - typedef uint8 value_type; + typedef beast::uint8 value_type; typedef value_type* iterator; typedef value_type const* const_iterator; typedef value_type& reference; @@ -43,8 +43,8 @@ public: static size_type const post_size = PostSize; static size_type const storage_size = pre_size + size + post_size; - typedef FixedArray < - uint8, storage_size> storage_type; + typedef beast::FixedArray < + beast::uint8, storage_size> storage_type; /** Value hashing function. The seed prevents crafted inputs from causing degenarate parent containers. @@ -52,7 +52,7 @@ public: class hasher { public: - explicit hasher (std::size_t seedToUse = Random::getSystemRandom ().nextInt ()) + explicit hasher (std::size_t seedToUse = beast::Random::getSystemRandom ().nextInt ()) : m_seed (seedToUse) { } @@ -60,7 +60,7 @@ public: std::size_t operator() (IdentifierStorage const& storage) const { std::size_t hash; - Murmur::Hash (storage.cbegin (), storage.size, m_seed, &hash); + beast::Murmur::Hash (storage.cbegin (), storage.size, m_seed, &hash); return hash; } diff --git a/src/ripple/types/api/IdentifierType.h b/src/ripple/types/api/IdentifierType.h index d7d91c1055..bd99b96645 100644 --- a/src/ripple/types/api/IdentifierType.h +++ b/src/ripple/types/api/IdentifierType.h @@ -84,7 +84,7 @@ public: { } /** Create a copy of the value from range of bytes. */ - IdentifierType (uint8 const* begin, uint8 const* end) + IdentifierType (beast::uint8 const* begin, beast::uint8 const* end) { Traits::construct (begin, end, m_value); } /** Conversion construction from any specialized type. */ diff --git a/src/ripple/types/api/RandomNumbers.h b/src/ripple/types/api/RandomNumbers.h index db8616332c..85df93d6a3 100644 --- a/src/ripple/types/api/RandomNumbers.h +++ b/src/ripple/types/api/RandomNumbers.h @@ -39,7 +39,7 @@ public: @return `true` if enough entropy could be retrieved. */ - bool initialize (Journal::Stream stream = Journal::Stream()); + bool initialize (beast::Journal::Stream stream = beast::Journal::Stream()); /** Generate secure random numbers. @@ -77,7 +77,7 @@ private: ~RandomNumbers (); - bool platformAddEntropy (Journal::Stream stream); + bool platformAddEntropy (beast::Journal::Stream stream); void platformAddPerformanceMonitorEntropy (); diff --git a/src/ripple/types/api/RippleAccountID.h b/src/ripple/types/api/RippleAccountID.h index f8f1d782d1..e246b8d275 100644 --- a/src/ripple/types/api/RippleAccountID.h +++ b/src/ripple/types/api/RippleAccountID.h @@ -46,7 +46,7 @@ public: { value_type::storage_type const& storage (value.storage()); // We will convert to little endian with an extra pad byte - FixedArray le; + beast::FixedArray le; std::reverse_copy (storage.begin(), storage.end(), le.begin()); // Set pad byte zero to make BIGNUM always positive le.back() = 0; diff --git a/src/ripple/types/api/SimpleIdentifier.h b/src/ripple/types/api/SimpleIdentifier.h index cf16dbd220..9f8c2e6256 100644 --- a/src/ripple/types/api/SimpleIdentifier.h +++ b/src/ripple/types/api/SimpleIdentifier.h @@ -38,7 +38,7 @@ public: /** Initialize from an input sequence. */ static void construct ( - uint8 const* begin, uint8 const* end, + beast::uint8 const* begin, beast::uint8 const* end, value_type& value) { std::copy (begin, end, value.begin()); diff --git a/src/ripple/types/api/UInt160.h b/src/ripple/types/api/UInt160.h index 407810a262..2afc1d39e4 100644 --- a/src/ripple/types/api/UInt160.h +++ b/src/ripple/types/api/UInt160.h @@ -52,17 +52,17 @@ public: return *this; } - uint160 (uint64 b) + uint160 (beast::uint64 b) { *this = b; } - uint160& operator= (uint64 uHost) + uint160& operator= (beast::uint64 uHost) { zero (); // Put in least significant bits. - ((uint64*) end ())[-1] = htobe64 (uHost); + ((beast::uint64*) end ())[-1] = htobe64 (uHost); return *this; } @@ -83,12 +83,12 @@ public: base_uint256 to256 () const; }; -inline bool operator== (const uint160& a, uint64 b) +inline bool operator== (const uint160& a, beast::uint64 b) { return (base_uint160)a == b; } -inline bool operator!= (const uint160& a, uint64 b) +inline bool operator!= (const uint160& a, beast::uint64 b) { return (base_uint160)a != b; } diff --git a/src/ripple/types/api/UInt256.h b/src/ripple/types/api/UInt256.h index 3dcc55a9e6..98f8fbbcac 100644 --- a/src/ripple/types/api/UInt256.h +++ b/src/ripple/types/api/UInt256.h @@ -54,7 +54,7 @@ public: return *this; } - uint256 (uint64 b) + uint256 (beast::uint64 b) { *this = b; } @@ -70,12 +70,12 @@ public: return uint256 (data, FromVoid ()); } - uint256& operator= (uint64 uHost) + uint256& operator= (beast::uint64 uHost) { zero (); // Put in least significant bits. - ((uint64*) end ())[-1] = htobe64 (uHost); + ((beast::uint64*) end ())[-1] = htobe64 (uHost); return *this; } @@ -97,12 +97,12 @@ public: } }; -inline bool operator== (uint256 const& a, uint64 b) +inline bool operator== (uint256 const& a, beast::uint64 b) { return (base_uint256)a == b; } -inline bool operator!= (uint256 const& a, uint64 b) +inline bool operator!= (uint256 const& a, beast::uint64 b) { return (base_uint256)a != b; } @@ -200,7 +200,7 @@ inline const uint256 operator| (uint256 const& a, uint256 const& b) inline int Testuint256AdHoc (std::vector vArg) { - uint256 g (uint64 (0)); + uint256 g (beast::uint64 (0)); printf ("%s\n", g.ToString ().c_str ()); --g; diff --git a/src/ripple/types/api/base_uint.h b/src/ripple/types/api/base_uint.h index 8dc33e80f3..6ca5b1f81b 100644 --- a/src/ripple/types/api/base_uint.h +++ b/src/ripple/types/api/base_uint.h @@ -103,7 +103,8 @@ public: class hasher { public: - explicit hasher (std::size_t seedToUse = Random::getSystemRandom ().nextInt ()) + explicit hasher (std::size_t seedToUse = + beast::Random::getSystemRandom ().nextInt ()) : m_seed (seedToUse) { } @@ -111,7 +112,7 @@ public: std::size_t operator() (base_uint const& value) const { std::size_t hash; - Murmur::Hash (value.cbegin (), (BITS / 8), m_seed, &hash); + beast::Murmur::Hash (value.cbegin (), (BITS / 8), m_seed, &hash); return hash; } @@ -176,12 +177,12 @@ public: return ret; } - base_uint& operator= (uint64 uHost) + base_uint& operator= (beast::uint64 uHost) { zero (); // Put in least significant bits. - ((uint64*) end ())[-1] = htobe64 (uHost); + ((beast::uint64*) end ())[-1] = htobe64 (uHost); return *this; } @@ -237,7 +238,7 @@ public: { for (int i = WIDTH - 1; i >= 0; --i) { - uint32 prev = pn[i]; + beast::uint32 prev = pn[i]; pn[i] = htobe32 (be32toh (pn[i]) - 1); if (prev != 0) @@ -258,11 +259,11 @@ public: base_uint& operator+= (const base_uint& b) { - uint64 carry = 0; + beast::uint64 carry = 0; for (int i = WIDTH; i--;) { - uint64 n = carry + be32toh (pn[i]) + be32toh (b.pn[i]); + beast::uint64 n = carry + be32toh (pn[i]) + be32toh (b.pn[i]); pn[i] = htobe32 (n & 0xffffffff); carry = n >> 32; diff --git a/src/ripple/types/impl/Base58.cpp b/src/ripple/types/impl/Base58.cpp index 5bcb1f0e2a..7903c05eb7 100644 --- a/src/ripple/types/impl/Base58.cpp +++ b/src/ripple/types/impl/Base58.cpp @@ -176,7 +176,7 @@ bool Base58::decode (const char* psz, Blob& vchRet, Alphabet const& alphabet) // const char* p1 = strchr (alphabet.chars(), *p); - if (p1 == NULL) + if (p1 == nullptr) { while (isspace (*p)) p++; diff --git a/src/ripple/types/impl/RandomNumbers.cpp b/src/ripple/types/impl/RandomNumbers.cpp index 807bdde615..fd4d2ed47d 100644 --- a/src/ripple/types/impl/RandomNumbers.cpp +++ b/src/ripple/types/impl/RandomNumbers.cpp @@ -47,7 +47,7 @@ RandomNumbers::~RandomNumbers () { } -bool RandomNumbers::initialize (Journal::Stream stream) +bool RandomNumbers::initialize (beast::Journal::Stream stream) { assert (!m_initialized); @@ -99,19 +99,19 @@ RandomNumbers& RandomNumbers::getInstance () #if BEAST_WIN32 // Get entropy from the Windows crypto provider -bool RandomNumbers::platformAddEntropy (Journal::Stream stream) +bool RandomNumbers::platformAddEntropy (beast::Journal::Stream stream) { char name[512], rand[128]; DWORD count = 500; HCRYPTPROV cryptoHandle; - if (!CryptGetDefaultProviderA (PROV_RSA_FULL, NULL, CRYPT_MACHINE_DEFAULT, name, &count)) + if (!CryptGetDefaultProviderA (PROV_RSA_FULL, nullptr, CRYPT_MACHINE_DEFAULT, name, &count)) { stream << "Unable to get default crypto provider"; return false; } - if (!CryptAcquireContextA (&cryptoHandle, NULL, name, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) + if (!CryptAcquireContextA (&cryptoHandle, nullptr, name, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) { stream << "Unable to acquire crypto provider"; return false; @@ -132,7 +132,7 @@ bool RandomNumbers::platformAddEntropy (Journal::Stream stream) #else -bool RandomNumbers::platformAddEntropy (Journal::Stream stream) +bool RandomNumbers::platformAddEntropy (beast::Journal::Stream stream) { char rand[128]; std::ifstream reader; @@ -180,9 +180,9 @@ void RandomNumbers::platformAddPerformanceMonitorEntropy () // VFALCO TODO Remove all this fancy stuff struct { - int64 operator () () const + beast::int64 operator () () const { - return time (NULL); + return time (nullptr); } } GetTime; @@ -193,14 +193,14 @@ void RandomNumbers::platformAddPerformanceMonitorEntropy () struct { // VFALCO TODO clean this up - int64 operator () () const + beast::int64 operator () () const { - int64 nCounter = 0; + beast::int64 nCounter = 0; #if BEAST_WIN32 QueryPerformanceCounter ((LARGE_INTEGER*)&nCounter); #else timeval t; - gettimeofday (&t, NULL); + gettimeofday (&t, nullptr); nCounter = t.tv_sec * 1000000 + t.tv_usec; #endif return nCounter; @@ -208,7 +208,7 @@ void RandomNumbers::platformAddPerformanceMonitorEntropy () } GetPerformanceCounter; // Seed with CPU performance counter - int64 nCounter = GetPerformanceCounter (); + beast::int64 nCounter = GetPerformanceCounter (); RAND_add (&nCounter, sizeof (nCounter), 1.5); memset (&nCounter, 0, sizeof (nCounter)); } @@ -217,7 +217,7 @@ void RandomNumbers::platformAddPerformanceMonitorEntropy () RandAddSeed (); // This can take up to 2 seconds, so only do it every 10 minutes - static int64 nLastPerfmon; + static beast::int64 nLastPerfmon; if (GetTime () < nLastPerfmon + 10 * 60) return; @@ -230,7 +230,7 @@ void RandomNumbers::platformAddPerformanceMonitorEntropy () unsigned char pdata[250000]; memset (pdata, 0, sizeof (pdata)); unsigned long nSize = sizeof (pdata); - long ret = RegQueryValueExA (HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, pdata, &nSize); + long ret = RegQueryValueExA (HKEY_PERFORMANCE_DATA, "Global", nullptr, nullptr, pdata, &nSize); RegCloseKey (HKEY_PERFORMANCE_DATA); if (ret == ERROR_SUCCESS) diff --git a/src/ripple/types/impl/RippleAssets.cpp b/src/ripple/types/impl/RippleAssets.cpp index 83336881ef..dd34451ab7 100644 --- a/src/ripple/types/impl/RippleAssets.cpp +++ b/src/ripple/types/impl/RippleAssets.cpp @@ -40,7 +40,7 @@ namespace ripple { -class RippleAssetTests : public UnitTest +class RippleAssetTests : public beast::UnitTest { public: // Comparison, hash tests for uint60 (via base_uint) diff --git a/src/ripple/types/ripple_types.h b/src/ripple/types/ripple_types.h index ce38218e05..64f6b0c77a 100644 --- a/src/ripple/types/ripple_types.h +++ b/src/ripple/types/ripple_types.h @@ -41,10 +41,6 @@ # include #endif -namespace ripple { -using namespace beast; -} - #include "api/AgedHistory.h" # include "api/Blob.h" # include "api/Base58.h" diff --git a/src/ripple/validators/api/Manager.h b/src/ripple/validators/api/Manager.h index 759afc6632..291485e136 100644 --- a/src/ripple/validators/api/Manager.h +++ b/src/ripple/validators/api/Manager.h @@ -28,7 +28,7 @@ namespace Validators { the list of chosen validators is critical to the health of the network. All operations are performed asynchronously on an internal thread. */ -class Manager : public PropertyStream::Source +class Manager : public beast::PropertyStream::Source { protected: Manager(); @@ -40,9 +40,9 @@ public: @param journal Where to send log output. */ static Manager* New ( - Stoppable& stoppableParent, - File const& pathToDbFileOrDirectory, - Journal journal); + beast::Stoppable& stoppableParent, + beast::File const& pathToDbFileOrDirectory, + beast::Journal journal); /** Destroy the object. Any pending source fetch operations are aborted. This will block @@ -61,11 +61,11 @@ public: Can be called from any thread. */ /** @{ */ - virtual void addStrings (String name, + virtual void addStrings (beast::String name, std::vector const& strings) = 0; - virtual void addStrings (String name, - StringArray const& stringArray) = 0; - virtual void addFile (File const& file) = 0; + virtual void addStrings (beast::String name, + beast::StringArray const& stringArray) = 0; + virtual void addFile (beast::File const& file) = 0; virtual void addStaticSource (Validators::Source* source) = 0; /** @} */ @@ -75,7 +75,7 @@ public: Thread safety: Can be called from any thread. */ - virtual void addURL (URL const& url) = 0; + virtual void addURL (beast::URL const& url) = 0; /** Add a live source of validators. The caller loses ownership of the object. The fetch is performed diff --git a/src/ripple/validators/api/Source.h b/src/ripple/validators/api/Source.h index 8bb2ef2250..ad6a283cd2 100644 --- a/src/ripple/validators/api/Source.h +++ b/src/ripple/validators/api/Source.h @@ -24,7 +24,7 @@ namespace ripple { namespace Validators { /** A source of validator descriptors. */ -class Source : public SharedObject +class Source : public beast::SharedObject { public: /** A Source's descriptor for a Validator. */ @@ -34,7 +34,7 @@ public: RipplePublicKey publicKey; /** Optional human readable comment describing the validator. */ - String label; + beast::String label; }; /** Destroy the Source. @@ -50,10 +50,10 @@ public: /** An identifier that uniquely describes the source. This is used for identification in the database. */ - virtual String uniqueID () const = 0; + virtual beast::String uniqueID () const = 0; /** A string that is used to recreate the source from the database entry. */ - virtual String createParam () = 0; + virtual beast::String createParam () = 0; /** Cancel any pending fetch. The default implementation does nothing. @@ -69,11 +69,11 @@ public: Results (); bool success; - String message; - Time expirationTime; + beast::String message; + beast::Time expirationTime; std::vector list; }; - virtual void fetch (Results& results, Journal journal) = 0; + virtual void fetch (Results& results, beast::Journal journal) = 0; /** @} */ }; diff --git a/src/ripple/validators/impl/ChosenList.h b/src/ripple/validators/impl/ChosenList.h index d7f338ac69..edd1277ed2 100644 --- a/src/ripple/validators/impl/ChosenList.h +++ b/src/ripple/validators/impl/ChosenList.h @@ -23,10 +23,10 @@ namespace ripple { namespace Validators { -class ChosenList : public SharedObject +class ChosenList : public beast::SharedObject { public: - typedef SharedPtr Ptr; + typedef beast::SharedPtr Ptr; struct Info { diff --git a/src/ripple/validators/impl/Count.h b/src/ripple/validators/impl/Count.h index fcbed76ca1..7ef025ba92 100644 --- a/src/ripple/validators/impl/Count.h +++ b/src/ripple/validators/impl/Count.h @@ -67,7 +67,7 @@ struct Count } /** Output to PropertyStream. */ - void onWrite (PropertyStream::Map& map) + void onWrite (beast::PropertyStream::Map& map) { map["received"] = received; map["expected"] = expected; diff --git a/src/ripple/validators/impl/Logic.h b/src/ripple/validators/impl/Logic.h index ae4cf0650d..d555d3338e 100644 --- a/src/ripple/validators/impl/Logic.h +++ b/src/ripple/validators/impl/Logic.h @@ -41,15 +41,15 @@ public: bool stopping; /** The source we are currently fetching. */ - SharedPtr fetchSource; + beast::SharedPtr fetchSource; }; - typedef SharedData SharedState; + typedef beast::SharedData SharedState; SharedState m_state; Store& m_store; - Journal m_journal; + beast::Journal m_journal; // A small integer assigned to each closed ledger // @@ -88,7 +88,7 @@ public: //-------------------------------------------------------------------------- - explicit Logic (Store& store, Journal journal = Journal ()) + explicit Logic (Store& store, beast::Journal journal = beast::Journal ()) : m_store (store) , m_journal (journal) , m_ledgerID (0) @@ -122,7 +122,7 @@ public: // Returns `true` if a Source with the same unique ID already exists // - bool findSourceByID (String id) + bool findSourceByID (beast::String id) { for (SourceTable::const_iterator iter (m_sources.begin()); iter != m_sources.end(); ++iter) @@ -134,7 +134,7 @@ public: // Add a one-time static source. // Fetch is called right away, this call blocks. // - void addStatic (SharedPtr source) + void addStatic (beast::SharedPtr source) { if (findSourceByID (source->uniqueID())) { @@ -164,7 +164,7 @@ public: // Add a live source to the list of sources. // - void add (SharedPtr source) + void add (beast::SharedPtr source) { if (findSourceByID (source->uniqueID())) { @@ -258,7 +258,7 @@ public: m_journal.debug << "Rebuilt chosen list with " << - String::fromNumber (m_chosenList->size()) << " entries"; + beast::String::fromNumber (m_chosenList->size()) << " entries"; } /** Mark the Chosen List for a rebuild. */ @@ -294,7 +294,7 @@ public: /** Perform a fetch on the source. */ void fetch (SourceDesc& desc) { - SharedPtr const& source (desc.source); + beast::SharedPtr const& source (desc.source); Source::Results results; { @@ -316,8 +316,8 @@ public: } // Reset fetch timer for the source-> - desc.whenToFetch = Time::getCurrentTime () + - RelativeTime (secondsBetweenFetches); + desc.whenToFetch = beast::Time::getCurrentTime () + + beast::RelativeTime (secondsBetweenFetches); if (results.success) { @@ -394,7 +394,7 @@ public: std::size_t fetch_one () { std::size_t n (0); - Time const currentTime (Time::getCurrentTime ()); + beast::Time const currentTime (beast::Time::getCurrentTime ()); for (SourceTable::iterator iter = m_sources.begin (); (n == 0) && iter != m_sources.end (); ++iter) diff --git a/src/ripple/validators/impl/Manager.cpp b/src/ripple/validators/impl/Manager.cpp index 49aabcb517..53e37f9beb 100644 --- a/src/ripple/validators/impl/Manager.cpp +++ b/src/ripple/validators/impl/Manager.cpp @@ -127,21 +127,21 @@ namespace Validators { class ManagerImp : public Manager - , public Stoppable - , public Thread - , public DeadlineTimer::Listener - , public LeakChecked + , public beast::Stoppable + , public beast::Thread + , public beast::DeadlineTimer::Listener + , public beast::LeakChecked { public: - Journal m_journal; - File m_databaseFile; + beast::Journal m_journal; + beast::File m_databaseFile; StoreSqdb m_store; Logic m_logic; - DeadlineTimer m_checkTimer; - ServiceQueue m_queue; + beast::DeadlineTimer m_checkTimer; + beast::ServiceQueue m_queue; - typedef ScopedWrapperContext < - RecursiveMutex, RecursiveMutex::ScopedLockType> Context; + typedef beast::ScopedWrapperContext < + beast::RecursiveMutex, beast::RecursiveMutex::ScopedLockType> Context; Context m_context; @@ -152,8 +152,8 @@ public: ManagerImp ( Stoppable& parent, - File const& pathToDbFileOrDirectory, - Journal journal) + beast::File const& pathToDbFileOrDirectory, + beast::Journal journal) : Stoppable ("Validators::Manager", parent) , Thread ("Validators") , m_journal (journal) @@ -187,16 +187,16 @@ public: // //-------------------------------------------------------------------------- - void addStrings (String name, std::vector const& strings) + void addStrings (beast::String name, std::vector const& strings) { - StringArray stringArray; + beast::StringArray stringArray; stringArray.ensureStorageAllocated (strings.size()); for (std::size_t i = 0; i < strings.size(); ++i) stringArray.add (strings [i]); addStrings (name, stringArray); } - void addStrings (String name, StringArray const& stringArray) + void addStrings (beast::String name, beast::StringArray const& stringArray) { if (stringArray.size() > 0) { @@ -208,25 +208,25 @@ public: } } - void addFile (File const& file) + void addFile (beast::File const& file) { addStaticSource (SourceFile::New (file)); } void addStaticSource (Validators::Source* source) { - m_queue.dispatch (m_context.wrap (bind ( + m_queue.dispatch (m_context.wrap (std::bind ( &Logic::addStatic, &m_logic, source))); } - void addURL (URL const& url) + void addURL (beast::URL const& url) { addSource (SourceURL::New (url)); } void addSource (Validators::Source* source) { - m_queue.dispatch (m_context.wrap (bind ( + m_queue.dispatch (m_context.wrap (std::bind ( &Logic::add, &m_logic, source))); } @@ -235,14 +235,14 @@ public: void receiveValidation (ReceivedValidation const& rv) { if (! isStopping()) - m_queue.dispatch (m_context.wrap (bind ( + m_queue.dispatch (m_context.wrap (std::bind ( &Logic::receiveValidation, &m_logic, rv))); } void ledgerClosed (RippleLedgerHash const& ledgerHash) { if (! isStopping()) - m_queue.dispatch (m_context.wrap (bind ( + m_queue.dispatch (m_context.wrap (std::bind ( &Logic::ledgerClosed, &m_logic, ledgerHash))); } @@ -259,7 +259,7 @@ public: void onStart () { // Do this late so the sources have a chance to be added. - m_queue.dispatch (m_context.wrap (bind ( + m_queue.dispatch (m_context.wrap (std::bind ( &ManagerImp::setCheckSources, this))); startThread(); @@ -269,7 +269,7 @@ public: { m_logic.stop (); - m_queue.dispatch (m_context.wrap (bind ( + m_queue.dispatch (m_context.wrap (std::bind ( &Thread::signalThreadShouldExit, this))); } @@ -279,29 +279,29 @@ public: // //-------------------------------------------------------------------------- - void onWrite (PropertyStream::Map& map) + void onWrite (beast::PropertyStream::Map& map) { Context::Scope scope (m_context); - map ["trusted"] = uint32 ( + map ["trusted"] = beast::uint32 ( m_logic.m_chosenList ? m_logic.m_chosenList->size() : 0); { - PropertyStream::Set items ("sources", map); + beast::PropertyStream::Set items ("sources", map); for (Logic::SourceTable::const_iterator iter (m_logic.m_sources.begin()); iter != m_logic.m_sources.end(); ++iter) items.add (iter->source->to_string()); } { - PropertyStream::Set items ("validators", map); + beast::PropertyStream::Set items ("validators", map); for (Logic::ValidatorTable::iterator iter (m_logic.m_validators.begin()); iter != m_logic.m_validators.end(); ++iter) { RipplePublicKey const& publicKey (iter->first); Validator const& validator (iter->second); - PropertyStream::Map item (items); + beast::PropertyStream::Map item (items); item["public_key"] = publicKey.to_string(); validator.count().onWrite (item); } @@ -316,7 +316,7 @@ public: void init () { - Error error (m_store.open (m_databaseFile)); + beast::Error error (m_store.open (m_databaseFile)); if (! error) { @@ -324,12 +324,12 @@ public: } } - void onDeadlineTimer (DeadlineTimer& timer) + void onDeadlineTimer (beast::DeadlineTimer& timer) { if (timer == m_checkTimer) { m_journal.trace << "Check timer expired"; - m_queue.dispatch (m_context.wrap (bind ( + m_queue.dispatch (m_context.wrap (std::bind ( &ManagerImp::setCheckSources, this))); } } @@ -354,7 +354,7 @@ public: m_checkSources = false; m_journal.trace << "Next check timer expires in " << - RelativeTime::seconds (checkEverySeconds); + beast::RelativeTime::seconds (checkEverySeconds); m_checkTimer.setExpiration (checkEverySeconds); } @@ -378,14 +378,14 @@ public: //------------------------------------------------------------------------------ Manager::Manager () - : PropertyStream::Source ("validators") + : beast::PropertyStream::Source ("validators") { } Validators::Manager* Validators::Manager::New ( - Stoppable& parent, - File const& pathToDbFileOrDirectory, - Journal journal) + beast::Stoppable& parent, + beast::File const& pathToDbFileOrDirectory, + beast::Journal journal) { return new Validators::ManagerImp (parent, pathToDbFileOrDirectory, journal); } diff --git a/src/ripple/validators/impl/SourceDesc.h b/src/ripple/validators/impl/SourceDesc.h index 9ce1fbc779..c13c54ef62 100644 --- a/src/ripple/validators/impl/SourceDesc.h +++ b/src/ripple/validators/impl/SourceDesc.h @@ -33,9 +33,9 @@ struct SourceDesc statusFailed }; - SharedPtr source; + beast::SharedPtr source; Status status; - Time whenToFetch; + beast::Time whenToFetch; int numberOfFailures; // The result of the last fetch @@ -44,16 +44,16 @@ struct SourceDesc //------------------------------------------------------------------ /** The time of the last successful fetch. */ - Time lastFetchTime; + beast::Time lastFetchTime; /** When to expire this source's list of cached results (if any) */ - Time expirationTime; + beast::Time expirationTime; //------------------------------------------------------------------ SourceDesc () noexcept : status (statusNone) - , whenToFetch (Time::getCurrentTime ()) + , whenToFetch (beast::Time::getCurrentTime ()) , numberOfFailures (0) { } diff --git a/src/ripple/validators/impl/SourceFile.cpp b/src/ripple/validators/impl/SourceFile.cpp index 98458a71f3..6b5c700e57 100644 --- a/src/ripple/validators/impl/SourceFile.cpp +++ b/src/ripple/validators/impl/SourceFile.cpp @@ -22,10 +22,10 @@ namespace Validators { class SourceFileImp : public SourceFile - , public LeakChecked + , public beast::LeakChecked { public: - SourceFileImp (File const& file) + SourceFileImp (beast::File const& file) : m_file (file) { } @@ -42,29 +42,29 @@ public: return ss.str(); } - String uniqueID () const + beast::String uniqueID () const { return "File," + m_file.getFullPathName (); } - String createParam () + beast::String createParam () { return m_file.getFullPathName (); } - void fetch (Results& results, Journal journal) + void fetch (Results& results, beast::Journal journal) { - int64 const fileSize (m_file.getSize ()); + beast::int64 const fileSize (m_file.getSize ()); if (fileSize != 0) { - if (fileSize < std::numeric_limits::max()) + if (fileSize < std::numeric_limits::max()) { - MemoryBlock buffer (fileSize); - RandomAccessFile f; - RandomAccessFile::ByteCount amountRead; + beast::MemoryBlock buffer (fileSize); + beast::RandomAccessFile f; + beast::RandomAccessFile::ByteCount amountRead; - f.open (m_file, RandomAccessFile::readOnly); + f.open (m_file, beast::RandomAccessFile::readOnly); f.read (buffer.begin(), fileSize, &amountRead); if (amountRead == fileSize) @@ -85,12 +85,12 @@ public: } private: - File m_file; + beast::File m_file; }; //------------------------------------------------------------------------------ -SourceFile* SourceFile::New (File const& file) +SourceFile* SourceFile::New (beast::File const& file) { return new SourceFileImp (file); } diff --git a/src/ripple/validators/impl/SourceFile.h b/src/ripple/validators/impl/SourceFile.h index 2bf5731432..cf7863cd57 100644 --- a/src/ripple/validators/impl/SourceFile.h +++ b/src/ripple/validators/impl/SourceFile.h @@ -29,7 +29,7 @@ namespace Validators { class SourceFile : public Source { public: - static SourceFile* New (File const& path); + static SourceFile* New (beast::File const& path); }; } diff --git a/src/ripple/validators/impl/SourceStrings.cpp b/src/ripple/validators/impl/SourceStrings.cpp index 938d60a455..84e49a502d 100644 --- a/src/ripple/validators/impl/SourceStrings.cpp +++ b/src/ripple/validators/impl/SourceStrings.cpp @@ -22,11 +22,11 @@ namespace Validators { class SourceStringsImp : public SourceStrings - , public LeakChecked + , public beast::LeakChecked { public: SourceStringsImp ( - String name, StringArray const& strings) + beast::String name, beast::StringArray const& strings) : m_name (name) , m_strings (strings) { @@ -41,18 +41,18 @@ public: return m_name.toStdString(); } - String uniqueID () const + beast::String uniqueID () const { // VFALCO TODO This can't be right...? - return String::empty; + return beast::String::empty; } - String createParam () + beast::String createParam () { - return String::empty; + return beast::String::empty; } - void fetch (Results& results, Journal journal) + void fetch (Results& results, beast::Journal journal) { results.list.reserve (m_strings.size ()); @@ -63,18 +63,19 @@ public: } results.success = results.list.size () > 0; - results.expirationTime = Time::getCurrentTime () + RelativeTime::hours (24); + results.expirationTime = beast::Time::getCurrentTime () + + beast::RelativeTime::hours (24); } private: - String m_name; - StringArray m_strings; + beast::String m_name; + beast::StringArray m_strings; }; //------------------------------------------------------------------------------ SourceStrings* SourceStrings::New ( - String name, StringArray const& strings) + beast::String name, beast::StringArray const& strings) { return new SourceStringsImp (name, strings); } diff --git a/src/ripple/validators/impl/SourceStrings.h b/src/ripple/validators/impl/SourceStrings.h index 585eefc9aa..dbdeca57dc 100644 --- a/src/ripple/validators/impl/SourceStrings.h +++ b/src/ripple/validators/impl/SourceStrings.h @@ -30,7 +30,7 @@ class SourceStrings : public Source { public: static SourceStrings* New ( - String name, StringArray const& strings); + beast::String name, beast::StringArray const& strings); }; } diff --git a/src/ripple/validators/impl/SourceURL.cpp b/src/ripple/validators/impl/SourceURL.cpp index ac23d644cc..f336966a5c 100644 --- a/src/ripple/validators/impl/SourceURL.cpp +++ b/src/ripple/validators/impl/SourceURL.cpp @@ -24,10 +24,10 @@ namespace Validators { class SourceURLImp : public SourceURL - , public LeakChecked + , public beast::LeakChecked { public: - explicit SourceURLImp (URL const& url) + explicit SourceURLImp (beast::URL const& url) : m_url (url) , m_client (beast::asio::HTTPClientBase::New ()) { @@ -45,12 +45,12 @@ public: return ss.str(); } - String uniqueID () const + beast::String uniqueID () const { return "URL," + m_url.toString(); } - String createParam () + beast::String createParam () { return m_url.toString(); } @@ -60,7 +60,7 @@ public: m_client->cancel (); } - void fetch (Results& results, Journal journal) + void fetch (Results& results, beast::Journal journal) { auto httpResult (m_client->get (m_url)); @@ -79,14 +79,14 @@ public: } private: - URL m_url; + beast::URL m_url; std::unique_ptr m_client; }; //------------------------------------------------------------------------------ SourceURL* SourceURL::New ( - URL const& url) + beast::URL const& url) { return new SourceURLImp (url); } diff --git a/src/ripple/validators/impl/SourceURL.h b/src/ripple/validators/impl/SourceURL.h index 726e379f40..fa040716c5 100644 --- a/src/ripple/validators/impl/SourceURL.h +++ b/src/ripple/validators/impl/SourceURL.h @@ -27,7 +27,7 @@ namespace Validators { class SourceURL : public Source { public: - static SourceURL* New (URL const& url); + static SourceURL* New (beast::URL const& url); }; } diff --git a/src/ripple/validators/impl/StoreSqdb.cpp b/src/ripple/validators/impl/StoreSqdb.cpp index 4f636d02f0..2f453f6d2d 100644 --- a/src/ripple/validators/impl/StoreSqdb.cpp +++ b/src/ripple/validators/impl/StoreSqdb.cpp @@ -20,7 +20,7 @@ namespace ripple { namespace Validators { -StoreSqdb::StoreSqdb (Journal journal) +StoreSqdb::StoreSqdb (beast::Journal journal) : m_journal (journal) { } @@ -29,9 +29,9 @@ StoreSqdb::~StoreSqdb () { } -Error StoreSqdb::open (File const& file) +beast::Error StoreSqdb::open (beast::File const& file) { - Error error (m_session.open (file.getFullPathName ())); + beast::Error error (m_session.open (file.getFullPathName ())); m_journal.info << "Opening " << file.getFullPathName(); @@ -53,7 +53,7 @@ Error StoreSqdb::open (File const& file) void StoreSqdb::insert (SourceDesc& desc) { - sqdb::transaction tr (m_session); + beast::sqdb::transaction tr (m_session); bool const found (select (desc)); @@ -63,14 +63,14 @@ void StoreSqdb::insert (SourceDesc& desc) } else { - Error error; + beast::Error error; - String const sourceID (desc.source->uniqueID().toStdString()); - String const createParam (desc.source->createParam().toStdString()); - String const lastFetchTime (Utilities::timeToString (desc.lastFetchTime)); - String const expirationTime (Utilities::timeToString (desc.expirationTime)); + beast::String const sourceID (desc.source->uniqueID().toStdString()); + beast::String const createParam (desc.source->createParam().toStdString()); + beast::String const lastFetchTime (Utilities::timeToString (desc.lastFetchTime)); + beast::String const expirationTime (Utilities::timeToString (desc.expirationTime)); - sqdb::statement st = (m_session.prepare << + beast::sqdb::statement st = (m_session.prepare << "INSERT INTO Validators_Source ( " " sourceID, " " createParam, " @@ -79,10 +79,10 @@ void StoreSqdb::insert (SourceDesc& desc) ") VALUES ( " " ?, ?, ?, ? " "); " - ,sqdb::use (sourceID) - ,sqdb::use (createParam) - ,sqdb::use (lastFetchTime) - ,sqdb::use (expirationTime) + ,beast::sqdb::use (sourceID) + ,beast::sqdb::use (createParam) + ,beast::sqdb::use (lastFetchTime) + ,beast::sqdb::use (expirationTime) ); st.execute_and_fetch (error); @@ -104,13 +104,13 @@ void StoreSqdb::insert (SourceDesc& desc) void StoreSqdb::update (SourceDesc& desc, bool updateFetchResults) { - Error error; + beast::Error error; - String const sourceID (desc.source->uniqueID()); - String const lastFetchTime (Utilities::timeToString (desc.lastFetchTime)); - String const expirationTime (Utilities::timeToString (desc.expirationTime)); + beast::String const sourceID (desc.source->uniqueID()); + beast::String const lastFetchTime (Utilities::timeToString (desc.lastFetchTime)); + beast::String const expirationTime (Utilities::timeToString (desc.expirationTime)); - sqdb::transaction tr (m_session); + beast::sqdb::transaction tr (m_session); m_session.once (error) << "UPDATE Validators_Source SET " @@ -118,9 +118,9 @@ void StoreSqdb::update (SourceDesc& desc, bool updateFetchResults) " expirationTime = ? " "WHERE " " sourceID = ? " - ,sqdb::use (lastFetchTime) - ,sqdb::use (expirationTime) - ,sqdb::use (sourceID) + ,beast::sqdb::use (lastFetchTime) + ,beast::sqdb::use (expirationTime) + ,beast::sqdb::use (sourceID) ; if (! error && updateFetchResults) @@ -129,16 +129,16 @@ void StoreSqdb::update (SourceDesc& desc, bool updateFetchResults) m_session.once (error) << "DELETE FROM Validators_SourceItem WHERE " " sourceID = ?; " - ,sqdb::use (sourceID) + ,beast::sqdb::use (sourceID) ; // Insert the new data set if (! error) { std::string publicKeyString; - String label; + beast::String label; - sqdb::statement st = (m_session.prepare << + beast::sqdb::statement st = (m_session.prepare << "INSERT INTO Validators_SourceItem ( " " sourceID, " " publicKey, " @@ -146,9 +146,9 @@ void StoreSqdb::update (SourceDesc& desc, bool updateFetchResults) ") VALUES ( " " ?, ?, ? " ");" - ,sqdb::use (sourceID) - ,sqdb::use (publicKeyString) - ,sqdb::use (label) + ,beast::sqdb::use (sourceID) + ,beast::sqdb::use (publicKeyString) + ,beast::sqdb::use (label) ); std::vector & list (desc.results.list); @@ -176,13 +176,13 @@ void StoreSqdb::update (SourceDesc& desc, bool updateFetchResults) //-------------------------------------------------------------------------- -void StoreSqdb::report (Error const& error, char const* fileName, int lineNumber) +void StoreSqdb::report (beast::Error const& error, char const* fileName, int lineNumber) { if (error) { m_journal.error << "Failure: '"<< error.getReasonText() << "' " << - " at " << Debug::getSourceLocation (fileName, lineNumber); + " at " << beast::Debug::getSourceLocation (fileName, lineNumber); } } @@ -195,20 +195,20 @@ bool StoreSqdb::select (SourceDesc& desc) { bool found (false); - Error error; + beast::Error error; - String const sourceID (desc.source->uniqueID()); - String lastFetchTime; - String expirationTime; - sqdb::statement st = (m_session.prepare << + beast::String const sourceID (desc.source->uniqueID()); + beast::String lastFetchTime; + beast::String expirationTime; + beast::sqdb::statement st = (m_session.prepare << "SELECT " " lastFetchTime, " " expirationTime " "FROM Validators_Source WHERE " " sourceID = ? " - ,sqdb::into (lastFetchTime) - ,sqdb::into (expirationTime) - ,sqdb::use (sourceID) + ,beast::sqdb::into (lastFetchTime) + ,beast::sqdb::into (expirationTime) + ,beast::sqdb::use (sourceID) ); if (st.execute_and_fetch (error)) @@ -241,9 +241,9 @@ bool StoreSqdb::select (SourceDesc& desc) */ void StoreSqdb::selectList (SourceDesc& desc) { - Error error; + beast::Error error; - String const sourceID (desc.source->uniqueID()); + beast::String const sourceID (desc.source->uniqueID()); // Get the count std::size_t count; @@ -254,8 +254,8 @@ void StoreSqdb::selectList (SourceDesc& desc) " COUNT(*) " "FROM Validators_SourceItem WHERE " " sourceID = ? " - ,sqdb::into (count) - ,sqdb::use (sourceID) + ,beast::sqdb::into (count) + ,beast::sqdb::use (sourceID) ; } @@ -275,15 +275,15 @@ void StoreSqdb::selectList (SourceDesc& desc) { std::string publicKeyString; std::string label; - sqdb::statement st = (m_session.prepare << + beast::sqdb::statement st = (m_session.prepare << "SELECT " " publicKey, " " label " "FROM Validators_SourceItem WHERE " " sourceID = ? " - ,sqdb::into (publicKeyString) - ,sqdb::into (label) - ,sqdb::use (sourceID) + ,beast::sqdb::into (publicKeyString) + ,beast::sqdb::into (label) + ,beast::sqdb::use (sourceID) ); // Add all the records to the list @@ -328,11 +328,11 @@ void StoreSqdb::selectList (SourceDesc& desc) //-------------------------------------------------------------------------- // Update the database for the current schema -Error StoreSqdb::update () +beast::Error StoreSqdb::update () { - Error error; + beast::Error error; - sqdb::transaction tr (m_session); + beast::sqdb::transaction tr (m_session); // Get the version from the database int version (0); @@ -343,7 +343,7 @@ Error StoreSqdb::update () " version " "FROM SchemaVersion WHERE " " name = 'Validators' " - ,sqdb::into (version) + ,beast::sqdb::into (version) ; if (! m_session.got_data ()) @@ -388,7 +388,7 @@ Error StoreSqdb::update () ") VALUES ( " " 'Validators', ? " "); " - ,sqdb::use (version) + ,beast::sqdb::use (version) ; } @@ -408,11 +408,11 @@ Error StoreSqdb::update () //-------------------------------------------------------------------------- -Error StoreSqdb::init () +beast::Error StoreSqdb::init () { - Error error; + beast::Error error; - sqdb::transaction tr (m_session); + beast::sqdb::transaction tr (m_session); if (! error) { diff --git a/src/ripple/validators/impl/StoreSqdb.h b/src/ripple/validators/impl/StoreSqdb.h index ab0671fb50..ff6f1881fb 100644 --- a/src/ripple/validators/impl/StoreSqdb.h +++ b/src/ripple/validators/impl/StoreSqdb.h @@ -26,7 +26,7 @@ namespace Validators { /** Database persistence for Validators using SQLite */ class StoreSqdb : public Store - , public LeakChecked + , public beast::LeakChecked { public: enum @@ -35,11 +35,11 @@ public: currentSchemaVersion = 2 }; - explicit StoreSqdb (Journal journal = Journal()); + explicit StoreSqdb (beast::Journal journal = beast::Journal()); ~StoreSqdb (); - Error open (File const& file); + beast::Error open (beast::File const& file); void insert (SourceDesc& desc); @@ -48,16 +48,16 @@ public: void remove (RipplePublicKey const& publicKey); private: - void report (Error const& error, char const* fileName, int lineNumber); + void report (beast::Error const& error, char const* fileName, int lineNumber); bool select (SourceDesc& desc); void selectList (SourceDesc& desc); - Error update (); - Error init (); + beast::Error update (); + beast::Error init (); - Journal m_journal; - sqdb::session m_session; + beast::Journal m_journal; + beast::sqdb::session m_session; }; } diff --git a/src/ripple/validators/impl/Tests.cpp b/src/ripple/validators/impl/Tests.cpp index fa1b4e32fa..b68ce9e851 100644 --- a/src/ripple/validators/impl/Tests.cpp +++ b/src/ripple/validators/impl/Tests.cpp @@ -20,7 +20,7 @@ namespace ripple { namespace Validators { -class Tests : public UnitTest +class Tests : public beast::UnitTest { public: enum @@ -97,7 +97,7 @@ public: struct TestSource : Source { - TestSource (String const& name, uint32 start, uint32 end) + TestSource (beast::String const& name, beast::uint32 start, beast::uint32 end) : m_name (name) , m_start (start) , m_end (end) @@ -109,34 +109,35 @@ public: return uniqueID().toStdString(); } - String uniqueID () const + beast::String uniqueID () const { + using beast::String; return String ("Test,") + m_name + "," + String::fromNumber (m_start) + "," + String::fromNumber (m_end); } - String createParam () + beast::String createParam () { - return String::empty; + return beast::String::empty; } - void fetch (Results& results, Journal) + void fetch (Results& results, beast::Journal) { results.success = true; - results.message = String::empty; + results.message = beast::String::empty; results.list.reserve (numberOfTestValidators); - for (uint32 i = m_start ; i < m_end; ++i) + for (beast::uint32 i = m_start ; i < m_end; ++i) { Item item;; item.publicKey = RipplePublicKey::createFromInteger (i); - item.label = String::fromNumber (i); + item.label = beast::String::fromNumber (i); results.list.push_back (item); } } - String m_name; + beast::String m_name; std::size_t m_start; std::size_t m_end; }; @@ -173,9 +174,9 @@ public: { for (int i = 1; i <= numberofTestSources; ++i) { - String const name (String::fromNumber (i)); - uint32 const start = random().nextInt (numberOfTestValidators); - uint32 const end = start + random().nextInt (numberOfTestValidators); + beast::String const name (beast::String::fromNumber (i)); + beast::uint32 const start = random().nextInt (numberOfTestValidators); + beast::uint32 const end = start + random().nextInt (numberOfTestValidators); logic.add (new TestSource (name, start, end)); } } @@ -187,17 +188,17 @@ public: //TestStore store; StoreSqdb storage; - File const file ( - File::getSpecialLocation ( - File::userDocumentsDirectory).getChildFile ( + beast::File const file ( + beast::File::getSpecialLocation ( + beast::File::userDocumentsDirectory).getChildFile ( "validators-test.sqlite")); // Can't call this 'error' because of ADL and Journal::error - Error err (storage.open (file)); + beast::Error err (storage.open (file)); unexpected (err, err.what()); - Logic logic (storage, Journal ()); + Logic logic (storage, beast::Journal ()); logic.load (); addSources (logic); @@ -214,7 +215,7 @@ public: // We need to use the same seed so we create the // same IDs for the set of TestSource objects. // - int64 const seedValue = 10; + beast::int64 const seedValue = 10; random().setSeed (seedValue); testLogic (); diff --git a/src/ripple/validators/impl/Utilities.cpp b/src/ripple/validators/impl/Utilities.cpp index 41e3f6e623..e2416dfe52 100644 --- a/src/ripple/validators/impl/Utilities.cpp +++ b/src/ripple/validators/impl/Utilities.cpp @@ -77,7 +77,7 @@ struct Utilities::Helpers bool Utilities::parseInfoLine ( Source::Item& item, std::string const& line, - Journal journal) + beast::Journal journal) { bool success (false); @@ -122,7 +122,7 @@ bool Utilities::parseInfoLine ( void Utilities::parseResultLine ( Source::Results& results, std::string const& line, - Journal journal) + beast::Journal journal) { Source::Item item; @@ -136,12 +136,12 @@ void Utilities::parseResultLine ( //-------------------------------------------------------------------------- -String Utilities::itos (int i, int fieldSize) +beast::String Utilities::itos (int i, int fieldSize) { - return String::fromNumber (i).paddedLeft (beast_wchar('0'), fieldSize); + return beast::String::fromNumber (i).paddedLeft (beast::beast_wchar('0'), fieldSize); } -String Utilities::timeToString (Time const& t) +beast::String Utilities::timeToString (beast::Time const& t) { if (t.isNotNull ()) { @@ -154,13 +154,14 @@ String Utilities::timeToString (Time const& t) itos (t.getSeconds(), 2); } - return String::empty; + return beast::String::empty; } -int Utilities::stoi (String& s, int fieldSize, int minValue, int maxValue, beast_wchar delimiter) +int Utilities::stoi (beast::String& s, int fieldSize, int minValue, int maxValue, + beast::beast_wchar delimiter) { int const needed (fieldSize + ((delimiter != 0) ? 1 : 0)); - String const v (s.substring (0, needed)); + beast::String const v (s.substring (0, needed)); s = s.substring (v.length ()); if (s.length() == needed) { @@ -175,7 +176,7 @@ int Utilities::stoi (String& s, int fieldSize, int minValue, int maxValue, beast return -1; // fail } -Time Utilities::stringToTime (String s) +beast::Time Utilities::stringToTime (beast::String s) { if (s.isNotEmpty ()) { @@ -193,11 +194,11 @@ Time Utilities::stringToTime (String s) sec != -1) { // local time - return Time (year, mon, day, hour, min, sec, 0, true); + return beast::Time (year, mon, day, hour, min, sec, 0, true); } } - return Time (0); + return beast::Time (0); } //------------------------------------------------------------------------------ diff --git a/src/ripple/validators/impl/Utilities.h b/src/ripple/validators/impl/Utilities.h index 5035815960..1a1a8e10e4 100644 --- a/src/ripple/validators/impl/Utilities.h +++ b/src/ripple/validators/impl/Utilities.h @@ -33,7 +33,7 @@ public: class ParseResultLine { public: - ParseResultLine (Source::Results& results, Journal journal) + ParseResultLine (Source::Results& results, beast::Journal journal) : m_result (&results) , m_journal (journal) { } @@ -47,7 +47,7 @@ public: private: Source::Results* m_result; - Journal m_journal; + beast::Journal m_journal; }; /** UnaryPredicate for breaking up lines. @@ -119,15 +119,16 @@ public: static void parseResultLine ( Source::Results& results, std::string const& line, - Journal journal = Journal()); + beast::Journal journal = beast::Journal()); // helpers - static String itos (int i, int fieldSize = 0); - static int stoi (String& s, int fieldSize, int minValue, int maxValue, beast_wchar delimiter); + static beast::String itos (int i, int fieldSize = 0); + static int stoi (beast::String& s, int fieldSize, int minValue, int maxValue, + beast::beast_wchar delimiter); // conversion betwen Time and String - static String timeToString (Time const& t); - static Time stringToTime (String s); + static beast::String timeToString (beast::Time const& t); + static beast::Time stringToTime (beast::String s); struct Helpers; @@ -135,7 +136,7 @@ public: @return `true` on success. */ static bool parseInfoLine ( - Source::Item& item, std::string const& line, Journal journal); + Source::Item& item, std::string const& line, beast::Journal journal); }; } diff --git a/src/ripple/validators/ripple_validators.cpp b/src/ripple/validators/ripple_validators.cpp index c41ccbb89c..f3ef632116 100644 --- a/src/ripple/validators/ripple_validators.cpp +++ b/src/ripple/validators/ripple_validators.cpp @@ -38,10 +38,6 @@ #include "../algorithm/api/CycledSet.h" #include "../testoverlay/ripple_testoverlay.h" // for unit test -namespace ripple { -using namespace beast; -} - # include "impl/Tuning.h" # include "impl/ChosenList.h" # include "impl/Count.h" diff --git a/src/ripple_app/consensus/LedgerConsensus.cpp b/src/ripple_app/consensus/LedgerConsensus.cpp index e715e13603..399b67db31 100644 --- a/src/ripple_app/consensus/LedgerConsensus.cpp +++ b/src/ripple_app/consensus/LedgerConsensus.cpp @@ -32,7 +32,7 @@ public: static char const* getCountedObjectName () { return "LedgerConsensus"; } LedgerConsensusImp (clock_type& clock, LedgerHash const & prevLCLHash, - Ledger::ref previousLedger, uint32 closeTime) + Ledger::ref previousLedger, beast::uint32 closeTime) : m_clock (clock) , mState (lcsPRE_CLOSE) , mCloseTime (closeTime) @@ -207,11 +207,11 @@ public: if (!mCloseTimes.empty ()) { - typedef std::map::value_type ct_t; + typedef std::map::value_type ct_t; Json::Value ctj (Json::objectValue); BOOST_FOREACH (ct_t & ct, mCloseTimes) { - ctj[lexicalCastThrow (ct.first)] = ct.second; + ctj[beast::lexicalCastThrow (ct.first)] = ct.second; } ret["close_times"] = ctj; } @@ -860,7 +860,7 @@ private: // these are now obsolete getApp().getOPs ().peekStoredProposals ().clear (); - uint32 closeTime = roundCloseTime (mOurPosition->getCloseTime ()); + beast::uint32 closeTime = roundCloseTime (mOurPosition->getCloseTime ()); bool closeTimeCorrect = true; if (closeTime == 0) @@ -1019,21 +1019,21 @@ private: // close time reports WriteLog (lsINFO, LedgerConsensus) << "We closed at " - << lexicalCastThrow (mCloseTime); - uint64 closeTotal = mCloseTime; + << beast::lexicalCastThrow (mCloseTime); + beast::uint64 closeTotal = mCloseTime; int closeCount = 1; - for (std::map::iterator it = mCloseTimes.begin () + for (std::map::iterator it = mCloseTimes.begin () , end = mCloseTimes.end (); it != end; ++it) { // FIXME: Use median, not average WriteLog (lsINFO, LedgerConsensus) - << lexicalCastThrow (it->second) + << beast::lexicalCastThrow (it->second) << " time votes for " - << lexicalCastThrow (it->first); + << beast::lexicalCastThrow (it->first); closeCount += it->second; - closeTotal += static_cast - (it->first) * static_cast (it->second); + closeTotal += static_cast + (it->first) * static_cast (it->second); } closeTotal += (closeCount / 2); @@ -1409,7 +1409,7 @@ private: #endif } - uint32 roundCloseTime (uint32 closeTime) + beast::uint32 roundCloseTime (beast::uint32 closeTime) { return Ledger::roundCloseTime (closeTime, mCloseResolution); } @@ -1432,7 +1432,7 @@ private: hash = ledger.getHash (); s.set_ledgerhash (hash.begin (), hash.size ()); - uint32 uMin, uMax; + beast::uint32 uMin, uMax; if (!getApp().getOPs ().getFullValidatedRange (uMin, uMax)) { uMin = 0; @@ -1441,7 +1441,7 @@ private: else { // Don't advertise ledgers we're not willing to serve - uint32 early = getApp().getLedgerMaster().getEarliestFetch (); + beast::uint32 early = getApp().getLedgerMaster().getEarliestFetch (); if (uMin < early) uMin = early; } @@ -1532,7 +1532,7 @@ private: // std::vector addedTx, removedTx; // Verify freshness of peer positions and compute close times - std::map closeTimes; + std::map closeTimes; boost::unordered_map::iterator it = mPeerPositions.begin (); @@ -1596,7 +1596,7 @@ private: else neededWeight = AV_STUCK_CONSENSUS_PCT; - uint32 closeTime = 0; + beast::uint32 closeTime = 0; mHaveCloseTimeConsensus = false; if (mPeerPositions.empty ()) @@ -1634,7 +1634,7 @@ private: << mPeerPositions.size () << " nw:" << neededWeight << " thrV:" << threshVote << " thrC:" << threshConsensus; - for (std::map::iterator it = closeTimes.begin () + for (std::map::iterator it = closeTimes.begin () , end = closeTimes.end (); it != end; ++it) { WriteLog (lsDEBUG, LedgerConsensus) << "CCTime: seq" @@ -1852,10 +1852,10 @@ private: */ void addLoad(SerializedValidation::ref val) { - uint32 fee = std::max( + beast::uint32 fee = std::max( getApp().getFeeTrack().getLocalFee(), getApp().getFeeTrack().getClusterFee()); - uint32 ref = getApp().getFeeTrack().getLoadBase(); + beast::uint32 ref = getApp().getFeeTrack().getLoadBase(); if (fee > ref) val->setFieldU32(sfLoadFee, fee); } @@ -1874,7 +1874,7 @@ private: }; LCState mState; - uint32 mCloseTime; // The wall time this ledger closed + beast::uint32 mCloseTime; // The wall time this ledger closed uint256 mPrevLedgerHash, mNewLedgerHash, mAcquiringLedger; Ledger::pointer mPreviousLedger; LedgerProposal::pointer mOurPosition; @@ -1904,7 +1904,7 @@ private: boost::unordered_set mCompares; // Close time estimates - std::map mCloseTimes; + std::map mCloseTimes; // nodes that have bowed out of this consensus process boost::unordered_set mDeadNodes; @@ -1917,7 +1917,7 @@ LedgerConsensus::~LedgerConsensus () } boost::shared_ptr LedgerConsensus::New (clock_type& clock, - LedgerHash const &prevLCLHash, Ledger::ref previousLedger, uint32 closeTime) + LedgerHash const &prevLCLHash, Ledger::ref previousLedger, beast::uint32 closeTime) { return boost::make_shared ( clock, prevLCLHash, previousLedger,closeTime); diff --git a/src/ripple_app/consensus/LedgerConsensus.h b/src/ripple_app/consensus/LedgerConsensus.h index 0767480d7d..d826d18729 100644 --- a/src/ripple_app/consensus/LedgerConsensus.h +++ b/src/ripple_app/consensus/LedgerConsensus.h @@ -28,11 +28,11 @@ class LedgerConsensus { public: - typedef abstract_clock clock_type; + typedef beast::abstract_clock clock_type; static boost::shared_ptr New (clock_type& clock, LedgerHash const & prevLCLHash, Ledger::ref previousLedger, - uint32 closeTime); + beast::uint32 closeTime); virtual ~LedgerConsensus () = 0; diff --git a/src/ripple_app/contracts/Contract.h b/src/ripple_app/contracts/Contract.h index c3a2292a5e..fba16f5665 100644 --- a/src/ripple_app/contracts/Contract.h +++ b/src/ripple_app/contracts/Contract.h @@ -32,8 +32,8 @@ public: uint160& getIssuer (); uint160& getOwner (); STAmount& getRippleEscrow (); - uint32 getEscrow (); - uint32 getBond (); + beast::uint32 getEscrow (); + beast::uint32 getBond (); Script::Data getData (int index); diff --git a/src/ripple_app/contracts/Interpreter.cpp b/src/ripple_app/contracts/Interpreter.cpp index 26af225587..bbd3db2df3 100644 --- a/src/ripple_app/contracts/Interpreter.cpp +++ b/src/ripple_app/contracts/Interpreter.cpp @@ -27,8 +27,8 @@ namespace Script Interpreter::Interpreter () { - mContract = NULL; - mCode = NULL; + mContract = nullptr; + mCode = nullptr; mInstructionPointer = 0; mTotalFee = 0; diff --git a/src/ripple_app/data/Database.cpp b/src/ripple_app/data/Database.cpp index 31c7f24e24..0512b479b8 100644 --- a/src/ripple_app/data/Database.cpp +++ b/src/ripple_app/data/Database.cpp @@ -48,10 +48,10 @@ char* Database::getStr (const char* colName, std::string& retStr) return getStr (index, retStr); } - return NULL; + return nullptr; } -int32 Database::getInt (const char* colName) +beast::int32 Database::getInt (const char* colName) { int index; @@ -117,7 +117,7 @@ std::string Database::getStrBinary (const std::string& strColName) return strCopy (getBinary (strColName.c_str ())); } -uint64 Database::getBigInt (const char* colName) +beast::uint64 Database::getBigInt (const char* colName) { int index; diff --git a/src/ripple_app/data/Database.h b/src/ripple_app/data/Database.h index 80de4d83a8..158ae1815e 100644 --- a/src/ripple_app/data/Database.h +++ b/src/ripple_app/data/Database.h @@ -67,7 +67,7 @@ public: bool getNull (const char* colName); char* getStr (const char* colName, std::string& retStr); std::string getStrBinary (const std::string& strColName); - int32 getInt (const char* colName); + beast::int32 getInt (const char* colName); float getFloat (const char* colName); bool getBool (const char* colName); @@ -75,15 +75,15 @@ public: int getBinary (const char* colName, unsigned char* buf, int maxSize); Blob getBinary (const std::string& strColName); - uint64 getBigInt (const char* colName); + beast::uint64 getBigInt (const char* colName); virtual bool getNull (int colIndex) = 0; virtual char* getStr (int colIndex, std::string& retStr) = 0; - virtual int32 getInt (int colIndex) = 0; + virtual beast::int32 getInt (int colIndex) = 0; virtual float getFloat (int colIndex) = 0; virtual bool getBool (int colIndex) = 0; virtual int getBinary (int colIndex, unsigned char* buf, int maxSize) = 0; - virtual uint64 getBigInt (int colIndex) = 0; + virtual beast::uint64 getBigInt (int colIndex) = 0; virtual Blob getBinary (int colIndex) = 0; // int getSingleDBValueInt(const char* sql); @@ -97,7 +97,7 @@ public: } virtual SqliteDatabase* getSqliteDB () { - return NULL; + return nullptr; } virtual int getKBUsedAll () { diff --git a/src/ripple_app/data/DatabaseCon.h b/src/ripple_app/data/DatabaseCon.h index d4ca4dbb8c..abd18a9586 100644 --- a/src/ripple_app/data/DatabaseCon.h +++ b/src/ripple_app/data/DatabaseCon.h @@ -22,7 +22,7 @@ // VFALCO NOTE This looks like a pointless class. Figure out // what purpose it is really trying to serve and do it better. -class DatabaseCon : LeakChecked +class DatabaseCon : beast::LeakChecked { public: DatabaseCon (const std::string& name, const char* initString[], int countInit); diff --git a/src/ripple_app/data/SqliteDatabase.cpp b/src/ripple_app/data/SqliteDatabase.cpp index eeb670e739..0565c5a268 100644 --- a/src/ripple_app/data/SqliteDatabase.cpp +++ b/src/ripple_app/data/SqliteDatabase.cpp @@ -24,7 +24,7 @@ SqliteStatement::SqliteStatement (SqliteDatabase* db, const char* sql, bool aux) assert (db); sqlite3* conn = aux ? db->getAuxConnection () : db->peekConnection (); - int j = sqlite3_prepare_v2 (conn, sql, strlen (sql) + 1, &statement, NULL); + int j = sqlite3_prepare_v2 (conn, sql, strlen (sql) + 1, &statement, nullptr); if (j != SQLITE_OK) throw j; @@ -35,7 +35,7 @@ SqliteStatement::SqliteStatement (SqliteDatabase* db, const std::string& sql, bo assert (db); sqlite3* conn = aux ? db->getAuxConnection () : db->peekConnection (); - int j = sqlite3_prepare_v2 (conn, sql.c_str (), sql.size () + 1, &statement, NULL); + int j = sqlite3_prepare_v2 (conn, sql.c_str (), sql.size () + 1, &statement, nullptr); if (j != SQLITE_OK) throw j; @@ -52,14 +52,14 @@ SqliteDatabase::SqliteDatabase (const char* host) : Database (host) , Thread ("sqlitedb") , m_walMutex (this, "SqliteDB", __FILE__, __LINE__) - , mWalQ (NULL) + , mWalQ (nullptr) , walRunning (false) { startThread (); - mConnection = NULL; - mAuxConnection = NULL; - mCurrentStmt = NULL; + mConnection = nullptr; + mAuxConnection = nullptr; + mCurrentStmt = nullptr; } SqliteDatabase::~SqliteDatabase () @@ -71,7 +71,7 @@ SqliteDatabase::~SqliteDatabase () void SqliteDatabase::connect () { int rc = sqlite3_open_v2 (mHost.c_str (), &mConnection, - SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX, NULL); + SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX, nullptr); if (rc) { @@ -85,20 +85,20 @@ sqlite3* SqliteDatabase::getAuxConnection () { ScopedLockType sl (m_walMutex, __FILE__, __LINE__); - if (mAuxConnection == NULL) + if (mAuxConnection == nullptr) { int rc = sqlite3_open_v2 (mHost.c_str (), &mAuxConnection, - SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX, NULL); + SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX, nullptr); if (rc) { WriteLog (lsFATAL, SqliteDatabase) << "Can't aux open " << mHost << " " << rc; assert ((rc != SQLITE_BUSY) && (rc != SQLITE_LOCKED)); - if (mAuxConnection != NULL) + if (mAuxConnection != nullptr) { sqlite3_close (mConnection); - mAuxConnection = NULL; + mAuxConnection = nullptr; } } } @@ -111,7 +111,7 @@ void SqliteDatabase::disconnect () sqlite3_finalize (mCurrentStmt); sqlite3_close (mConnection); - if (mAuxConnection != NULL) + if (mAuxConnection != nullptr) sqlite3_close (mAuxConnection); } @@ -119,12 +119,12 @@ void SqliteDatabase::disconnect () bool SqliteDatabase::executeSQL (const char* sql, bool fail_ok) { #ifdef DEBUG_HANGING_LOCKS - assert (fail_ok || (mCurrentStmt == NULL)); + assert (fail_ok || (mCurrentStmt == nullptr)); #endif sqlite3_finalize (mCurrentStmt); - int rc = sqlite3_prepare_v2 (mConnection, sql, -1, &mCurrentStmt, NULL); + int rc = sqlite3_prepare_v2 (mConnection, sql, -1, &mCurrentStmt, nullptr); if (SQLITE_OK != rc) { @@ -198,7 +198,7 @@ bool SqliteDatabase::startIterRows (bool finalize) void SqliteDatabase::endIterRows () { sqlite3_finalize (mCurrentStmt); - mCurrentStmt = NULL; + mCurrentStmt = nullptr; } // call this after you executeSQL @@ -230,11 +230,11 @@ bool SqliteDatabase::getNull (int colIndex) char* SqliteDatabase::getStr (int colIndex, std::string& retStr) { const char* text = reinterpret_cast (sqlite3_column_text (mCurrentStmt, colIndex)); - retStr = (text == NULL) ? "" : text; + retStr = (text == nullptr) ? "" : text; return const_cast (retStr.c_str ()); } -int32 SqliteDatabase::getInt (int colIndex) +beast::int32 SqliteDatabase::getInt (int colIndex) { return (sqlite3_column_int (mCurrentStmt, colIndex)); } @@ -272,7 +272,7 @@ Blob SqliteDatabase::getBinary (int colIndex) return vucResult; } -uint64 SqliteDatabase::getBigInt (int colIndex) +beast::uint64 SqliteDatabase::getBigInt (int colIndex) { return (sqlite3_column_int64 (mCurrentStmt, colIndex)); } @@ -344,7 +344,7 @@ void SqliteDatabase::run () void SqliteDatabase::runWal () { int log = 0, ckpt = 0; - int ret = sqlite3_wal_checkpoint_v2 (mConnection, NULL, SQLITE_CHECKPOINT_PASSIVE, &log, &ckpt); + int ret = sqlite3_wal_checkpoint_v2 (mConnection, nullptr, SQLITE_CHECKPOINT_PASSIVE, &log, &ckpt); if (ret != SQLITE_OK) { @@ -381,7 +381,7 @@ int SqliteStatement::bindStatic (int position, Blob const& value) return sqlite3_bind_blob (statement, position, &value.front (), value.size (), SQLITE_STATIC); } -int SqliteStatement::bind (int position, uint32 value) +int SqliteStatement::bind (int position, beast::uint32 value) { return sqlite3_bind_int64 (statement, position, static_cast (value)); } @@ -429,12 +429,12 @@ const char* SqliteStatement::peekString (int column) return reinterpret_cast (sqlite3_column_text (statement, column)); } -uint32 SqliteStatement::getUInt32 (int column) +beast::uint32 SqliteStatement::getUInt32 (int column) { - return static_cast (sqlite3_column_int64 (statement, column)); + return static_cast (sqlite3_column_int64 (statement, column)); } -int64 SqliteStatement::getInt64 (int column) +beast::int64 SqliteStatement::getInt64 (int column) { return sqlite3_column_int64 (statement, column); } diff --git a/src/ripple_app/data/SqliteDatabase.h b/src/ripple_app/data/SqliteDatabase.h index 3d80b0c639..cc8ffa023a 100644 --- a/src/ripple_app/data/SqliteDatabase.h +++ b/src/ripple_app/data/SqliteDatabase.h @@ -22,8 +22,8 @@ class SqliteDatabase : public Database - , private Thread - , private LeakChecked + , private beast::Thread + , private beast::LeakChecked { public: explicit SqliteDatabase (char const* host); @@ -48,13 +48,13 @@ public: bool getNull (int colIndex); char* getStr (int colIndex, std::string& retStr); - int32 getInt (int colIndex); + beast::int32 getInt (int colIndex); float getFloat (int colIndex); bool getBool (int colIndex); // returns amount stored in buf int getBinary (int colIndex, unsigned char* buf, int maxSize); Blob getBinary (int colIndex); - uint64 getBigInt (int colIndex); + beast::uint64 getBigInt (int colIndex); sqlite3* peekConnection () { @@ -119,7 +119,7 @@ public: int bind (int position, const std::string& value); int bindStatic (int position, const std::string& value); - int bind (int position, uint32 value); + int bind (int position, beast::uint32 value); int bind (int position); // columns start at 0 @@ -130,8 +130,8 @@ public: std::string getString (int column); const char* peekString (int column); - uint32 getUInt32 (int column); - int64 getInt64 (int column); + beast::uint32 getUInt32 (int column); + beast::int64 getInt64 (int column); int step (); int reset (); diff --git a/src/ripple_app/ledger/AcceptedLedgerTx.cpp b/src/ripple_app/ledger/AcceptedLedgerTx.cpp index bcd9eafe5d..0fdf6ac229 100644 --- a/src/ripple_app/ledger/AcceptedLedgerTx.cpp +++ b/src/ripple_app/ledger/AcceptedLedgerTx.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -AcceptedLedgerTx::AcceptedLedgerTx (uint32 seq, SerializerIterator& sit) +AcceptedLedgerTx::AcceptedLedgerTx (beast::uint32 seq, SerializerIterator& sit) { Serializer txnSer (sit.getVL ()); SerializerIterator txnIt (txnSer); diff --git a/src/ripple_app/ledger/AcceptedLedgerTx.h b/src/ripple_app/ledger/AcceptedLedgerTx.h index 1a24155c27..e16d5e32c9 100644 --- a/src/ripple_app/ledger/AcceptedLedgerTx.h +++ b/src/ripple_app/ledger/AcceptedLedgerTx.h @@ -77,7 +77,7 @@ public: { return mResult; } - uint32 getTxnSeq () const + beast::uint32 getTxnSeq () const { return mMeta->getIndex (); } diff --git a/src/ripple_app/ledger/InboundLedger.cpp b/src/ripple_app/ledger/InboundLedger.cpp index 748c8bae72..de4083e7a9 100644 --- a/src/ripple_app/ledger/InboundLedger.cpp +++ b/src/ripple_app/ledger/InboundLedger.cpp @@ -32,7 +32,7 @@ enum ,ledgerBecomeAggressiveThreshold = 6 }; -InboundLedger::InboundLedger (uint256 const& hash, uint32 seq, fcReason reason, +InboundLedger::InboundLedger (uint256 const& hash, beast::uint32 seq, fcReason reason, clock_type& clock) : PeerSet (hash, ledgerAcquireTimeoutMillis, false, clock, LogPartition::getJournal ()) @@ -1242,7 +1242,7 @@ Json::Value InboundLedger::getJson (int) Json::Value hv (Json::arrayValue); // VFALCO Why 16? std::vector v = mLedger->getNeededAccountStateHashes ( - 16, NULL); + 16, nullptr); BOOST_FOREACH (uint256 const & h, v) { hv.append (h.GetHex ()); @@ -1255,7 +1255,7 @@ Json::Value InboundLedger::getJson (int) Json::Value hv (Json::arrayValue); // VFALCO Why 16? std::vector v = mLedger->getNeededTransactionHashes ( - 16, NULL); + 16, nullptr); BOOST_FOREACH (uint256 const & h, v) { hv.append (h.GetHex ()); diff --git a/src/ripple_app/ledger/InboundLedger.h b/src/ripple_app/ledger/InboundLedger.h index eb04af846d..43d32c064a 100644 --- a/src/ripple_app/ledger/InboundLedger.h +++ b/src/ripple_app/ledger/InboundLedger.h @@ -44,7 +44,7 @@ public: }; public: - InboundLedger (uint256 const& hash, uint32 seq, fcReason reason, clock_type& clock); + InboundLedger (uint256 const& hash, beast::uint32 seq, fcReason reason, clock_type& clock); ~InboundLedger (); @@ -72,7 +72,7 @@ public: { mAborted = true; } - uint32 getSeq () + beast::uint32 getSeq () { return mSeq; } @@ -134,7 +134,7 @@ private: bool mAborted; bool mSignaled; bool mByHash; - uint32 mSeq; + beast::uint32 mSeq; fcReason mReason; std::set mRecentTXNodes; diff --git a/src/ripple_app/ledger/InboundLedgers.cpp b/src/ripple_app/ledger/InboundLedgers.cpp index 0f7b350444..b0f1e7a166 100644 --- a/src/ripple_app/ledger/InboundLedgers.cpp +++ b/src/ripple_app/ledger/InboundLedgers.cpp @@ -20,8 +20,8 @@ class InboundLedgersImp : public InboundLedgers - , public Stoppable - , public LeakChecked + , public beast::Stoppable + , public beast::LeakChecked { public: typedef std::pair u256_acq_pair; @@ -29,7 +29,7 @@ public: static const int kReacquireIntervalSeconds = 300; InboundLedgersImp (clock_type& clock, Stoppable& parent, - insight::Collector::ptr const& collector) + beast::insight::Collector::ptr const& collector) : Stoppable ("InboundLedgers", parent) , m_clock (clock) , mLock (this, "InboundLedger", __FILE__, __LINE__) @@ -41,7 +41,7 @@ public: // VFALCO TODO Should this be called findOrAdd ? // - InboundLedger::pointer findCreate (uint256 const& hash, uint32 seq, InboundLedger::fcReason reason) + InboundLedger::pointer findCreate (uint256 const& hash, beast::uint32 seq, InboundLedger::fcReason reason) { assert (hash.isNonZero ()); InboundLedger::pointer ret; @@ -290,9 +290,9 @@ public: BOOST_FOREACH (const u256_acq_pair& it, acquires) { - uint32 seq = it.second->getSeq(); + beast::uint32 seq = it.second->getSeq(); if (seq > 1) - ret[lexicalCastThrow (seq)] = it.second->getJson(0); + ret[beast::lexicalCastThrow (seq)] = it.second->getJson(0); else ret[it.first.GetHex()] = it.second->getJson(0); } @@ -395,8 +395,8 @@ InboundLedgers::~InboundLedgers() { } -InboundLedgers* InboundLedgers::New (clock_type& clock, Stoppable& parent, - insight::Collector::ptr const& collector) +InboundLedgers* InboundLedgers::New (clock_type& clock, beast::Stoppable& parent, + beast::insight::Collector::ptr const& collector) { return new InboundLedgersImp (clock, parent, collector); } diff --git a/src/ripple_app/ledger/InboundLedgers.h b/src/ripple_app/ledger/InboundLedgers.h index 1352f985db..5a4ff5b345 100644 --- a/src/ripple_app/ledger/InboundLedgers.h +++ b/src/ripple_app/ledger/InboundLedgers.h @@ -27,21 +27,21 @@ class InboundLedgers { public: - typedef abstract_clock clock_type; + typedef beast::abstract_clock clock_type; virtual ~InboundLedgers() = 0; // VFALCO TODO Make this a free function outside the class: // std::unique_ptr make_InboundLedgers (...) // - static InboundLedgers* New (clock_type& clock, Stoppable& parent, - insight::Collector::ptr const& collector); + static InboundLedgers* New (clock_type& clock, beast::Stoppable& parent, + beast::insight::Collector::ptr const& collector); // VFALCO TODO Should this be called findOrAdd ? // virtual InboundLedger::pointer findCreate (uint256 const& hash, - uint32 seq, InboundLedger::fcReason) = 0; + beast::uint32 seq, InboundLedger::fcReason) = 0; virtual InboundLedger::pointer find (LedgerHash const& hash) = 0; diff --git a/src/ripple_app/ledger/Ledger.cpp b/src/ripple_app/ledger/Ledger.cpp index c57104e8a8..24cff81eb2 100644 --- a/src/ripple_app/ledger/Ledger.cpp +++ b/src/ripple_app/ledger/Ledger.cpp @@ -24,7 +24,7 @@ LedgerBase::LedgerBase () { } -Ledger::Ledger (const RippleAddress& masterID, uint64 startAmount) +Ledger::Ledger (const RippleAddress& masterID, beast::uint64 startAmount) : mTotCoins (startAmount) , mLedgerSeq (1) // First Ledger , mCloseTime (0) @@ -62,12 +62,12 @@ Ledger::Ledger (const RippleAddress& masterID, uint64 startAmount) Ledger::Ledger (uint256 const& parentHash, uint256 const& transHash, uint256 const& accountHash, - uint64 totCoins, - uint32 closeTime, - uint32 parentCloseTime, + beast::uint64 totCoins, + beast::uint32 closeTime, + beast::uint32 parentCloseTime, int closeFlags, int closeResolution, - uint32 ledgerSeq, + beast::uint32 ledgerSeq, bool& loaded) : mParentHash (parentHash) , mTransHash (transHash) @@ -91,13 +91,13 @@ Ledger::Ledger (uint256 const& parentHash, updateHash (); loaded = true; - if (mTransHash.isNonZero () && !mTransactionMap->fetchRoot (mTransHash, NULL)) + if (mTransHash.isNonZero () && !mTransactionMap->fetchRoot (mTransHash, nullptr)) { loaded = false; WriteLog (lsWARNING, Ledger) << "Don't have TX root for ledger"; } - if (mAccountHash.isNonZero () && !mAccountStateMap->fetchRoot (mAccountHash, NULL)) + if (mAccountHash.isNonZero () && !mAccountStateMap->fetchRoot (mAccountHash, nullptr)) { loaded = false; WriteLog (lsWARNING, Ledger) << "Don't have AS root for ledger"; @@ -203,15 +203,15 @@ Ledger::~Ledger () if (mTransactionMap) { logTimedDestroy (mTransactionMap, - String ("mTransactionMap with ") + - String::fromNumber (mTransactionMap->size ()) + " items"); + beast::String ("mTransactionMap with ") + + beast::String::fromNumber (mTransactionMap->size ()) + " items"); } if (mAccountStateMap) { logTimedDestroy (mAccountStateMap, - String ("mAccountStateMap with ") + - String::fromNumber (mAccountStateMap->size ()) + " items"); + beast::String ("mAccountStateMap with ") + + beast::String::fromNumber (mAccountStateMap->size ()) + " items"); } } @@ -290,7 +290,7 @@ void Ledger::addRaw (Serializer& s) const s.add8 (mCloseFlags); } -void Ledger::setAccepted (uint32 closeTime, int closeResolution, bool correctCloseTime) +void Ledger::setAccepted (beast::uint32 closeTime, int closeResolution, bool correctCloseTime) { // used when we witnessed the consensus assert (mClosed && !mAccepted); @@ -643,9 +643,9 @@ bool Ledger::saveValidatedLedger (bool current) sql += "','"; sql += it->humanAccountID (); sql += "',"; - sql += lexicalCastThrow (getLedgerSeq ()); + sql += beast::lexicalCastThrow (getLedgerSeq ()); sql += ","; - sql += lexicalCastThrow (vt.second->getTxnSeq ()); + sql += beast::lexicalCastThrow (vt.second->getTxnSeq ()); sql += ")"; } @@ -667,7 +667,7 @@ bool Ledger::saveValidatedLedger (bool current) getApp().getLedgerDB ()->getDB ()->executeSQL (boost::str (addLedger % getHash ().GetHex () % mLedgerSeq % mParentHash.GetHex () % - lexicalCastThrow (mTotCoins) % mCloseTime % mParentCloseTime % + beast::lexicalCastThrow (mTotCoins) % mCloseTime % mParentCloseTime % mCloseResolution % mCloseFlags % mAccountHash.GetHex () % mTransHash.GetHex ())); } @@ -680,7 +680,7 @@ bool Ledger::saveValidatedLedger (bool current) #ifndef NO_SQLITE3_PREPARE -Ledger::pointer Ledger::loadByIndex (uint32 ledgerIndex) +Ledger::pointer Ledger::loadByIndex (beast::uint32 ledgerIndex) { Ledger::pointer ledger; { @@ -733,11 +733,11 @@ Ledger::pointer Ledger::loadByHash (uint256 const& ledgerHash) #else -Ledger::pointer Ledger::loadByIndex (uint32 ledgerIndex) +Ledger::pointer Ledger::loadByIndex (beast::uint32 ledgerIndex) { // This is a low-level function with no caching std::string sql = "SELECT * from Ledgers WHERE LedgerSeq='"; - sql.append (lexicalCastThrow (ledgerIndex)); + sql.append (beast::lexicalCastThrow (ledgerIndex)); sql.append ("';"); return getSQL (sql); } @@ -757,8 +757,8 @@ Ledger::pointer Ledger::getSQL (const std::string& sql) { // only used with sqlite3 prepared statements not used uint256 ledgerHash, prevHash, accountHash, transHash; - uint64 totCoins; - uint32 closingTime, prevClosingTime, ledgerSeq; + beast::uint64 totCoins; + beast::uint32 closingTime, prevClosingTime, ledgerSeq; int closeResolution; unsigned closeFlags; std::string hash; @@ -835,8 +835,8 @@ Ledger::pointer Ledger::getSQL1 (SqliteStatement* stmt) } uint256 ledgerHash, prevHash, accountHash, transHash; - uint64 totCoins; - uint32 closingTime, prevClosingTime, ledgerSeq; + beast::uint64 totCoins; + beast::uint32 closingTime, prevClosingTime, ledgerSeq; int closeResolution; unsigned closeFlags; @@ -873,12 +873,12 @@ void Ledger::getSQL2 (Ledger::ref ret) WriteLog (lsTRACE, Ledger) << "Loaded ledger: " << ret->getHash ().GetHex (); } -uint256 Ledger::getHashByIndex (uint32 ledgerIndex) +uint256 Ledger::getHashByIndex (beast::uint32 ledgerIndex) { uint256 ret; std::string sql = "SELECT LedgerHash FROM Ledgers INDEXED BY SeqLedger WHERE LedgerSeq='"; - sql.append (lexicalCastThrow (ledgerIndex)); + sql.append (beast::lexicalCastThrow (ledgerIndex)); sql.append ("';"); std::string hash; @@ -897,7 +897,7 @@ uint256 Ledger::getHashByIndex (uint32 ledgerIndex) return ret; } -bool Ledger::getHashesByIndex (uint32 ledgerIndex, uint256& ledgerHash, uint256& parentHash) +bool Ledger::getHashesByIndex (beast::uint32 ledgerIndex, uint256& ledgerHash, uint256& parentHash) { #ifndef NO_SQLITE3_PREPARE @@ -932,7 +932,7 @@ bool Ledger::getHashesByIndex (uint32 ledgerIndex, uint256& ledgerHash, uint256& #else std::string sql = "SELECT LedgerHash,PrevHash FROM Ledgers WHERE LedgerSeq='"; - sql.append (lexicalCastThrow (ledgerIndex)); + sql.append (beast::lexicalCastThrow (ledgerIndex)); sql.append ("';"); std::string hash, prevHash; @@ -958,14 +958,15 @@ bool Ledger::getHashesByIndex (uint32 ledgerIndex, uint256& ledgerHash, uint256& #endif } -std::map< uint32, std::pair > Ledger::getHashesByIndex (uint32 minSeq, uint32 maxSeq) +std::map< beast::uint32, std::pair > +Ledger::getHashesByIndex (beast::uint32 minSeq, beast::uint32 maxSeq) { - std::map< uint32, std::pair > ret; + std::map< beast::uint32, std::pair > ret; std::string sql = "SELECT LedgerSeq,LedgerHash,PrevHash FROM Ledgers WHERE LedgerSeq >= "; - sql.append (lexicalCastThrow (minSeq)); + sql.append (beast::lexicalCastThrow (minSeq)); sql.append (" AND LedgerSeq <= "); - sql.append (lexicalCastThrow (maxSeq)); + sql.append (beast::lexicalCastThrow (maxSeq)); sql.append (";"); DatabaseCon* con = getApp().getLedgerDB (); @@ -1019,10 +1020,10 @@ Json::Value Ledger::getJson (int options) ScopedLockType sl (mLock, __FILE__, __LINE__); - ledger["seqNum"] = lexicalCastThrow (mLedgerSeq); // DEPRECATED + ledger["seqNum"] = beast::lexicalCastThrow (mLedgerSeq); // DEPRECATED ledger["parent_hash"] = mParentHash.GetHex (); - ledger["ledger_index"] = lexicalCastThrow (mLedgerSeq); + ledger["ledger_index"] = beast::lexicalCastThrow (mLedgerSeq); if (mClosed || bFull) { @@ -1030,13 +1031,13 @@ Json::Value Ledger::getJson (int options) ledger["closed"] = true; ledger["hash"] = mHash.GetHex (); // DEPRECATED - ledger["totalCoins"] = lexicalCastThrow (mTotCoins); // DEPRECATED + ledger["totalCoins"] = beast::lexicalCastThrow (mTotCoins); // DEPRECATED ledger["ledger_hash"] = mHash.GetHex (); ledger["transaction_hash"] = mTransHash.GetHex (); ledger["account_hash"] = mAccountHash.GetHex (); ledger["accepted"] = mAccepted; - ledger["total_coins"] = lexicalCastThrow (mTotCoins); + ledger["total_coins"] = beast::lexicalCastThrow (mTotCoins); if (mCloseTime != 0) { @@ -1230,7 +1231,7 @@ void Ledger::visitAccountItems (const uint160& accountID, std::functiongetFieldU64 (sfIndexNext); + beast::uint64 uNodeNext = ownerDir->getFieldU64 (sfIndexNext); if (!uNodeNext) return; @@ -1449,7 +1450,7 @@ SLE::pointer Ledger::getRippleState (uint256 const& uNode) } // For an entry put in the 64 bit index or quality. -uint256 Ledger::getQualityIndex (uint256 const& uBase, const uint64 uNodeDir) +uint256 Ledger::getQualityIndex (uint256 const& uBase, const beast::uint64 uNodeDir) { // Indexes are stored in big endian format: they print as hex as stored. // Most significant bytes are first. Least significant bytes represent adjacent entries. @@ -1457,15 +1458,15 @@ uint256 Ledger::getQualityIndex (uint256 const& uBase, const uint64 uNodeDir) // Want uNodeDir in big endian format so ++ goes to the next entry for indexes. uint256 uNode (uBase); - ((uint64*) uNode.end ())[-1] = htobe64 (uNodeDir); + ((beast::uint64*) uNode.end ())[-1] = htobe64 (uNodeDir); return uNode; } // Return the last 64 bits. -uint64 Ledger::getQuality (uint256 const& uBase) +beast::uint64 Ledger::getQuality (uint256 const& uBase) { - return be64toh (((uint64*) uBase.end ())[-1]); + return be64toh (((beast::uint64*) uBase.end ())[-1]); } uint256 Ledger::getQualityNext (uint256 const& uBase) @@ -1513,7 +1514,7 @@ uint256 Ledger::getLedgerHashIndex () return s.getSHA512Half (); } -uint256 Ledger::getLedgerHashIndex (uint32 desiredLedgerIndex) +uint256 Ledger::getLedgerHashIndex (beast::uint32 desiredLedgerIndex) { // get the index of the node that holds the set of 256 ledgers that includes this ledger's hash // (or the first ledger after it if it's not a multiple of 256) @@ -1523,7 +1524,7 @@ uint256 Ledger::getLedgerHashIndex (uint32 desiredLedgerIndex) return s.getSHA512Half (); } -uint256 Ledger::getLedgerHash (uint32 ledgerIndex) +uint256 Ledger::getLedgerHash (beast::uint32 ledgerIndex) { // return the hash of the specified ledger, 0 if not available @@ -1590,9 +1591,9 @@ uint256 Ledger::getLedgerHash (uint32 ledgerIndex) return uint256 (); } -std::vector< std::pair > Ledger::getLedgerHashes () +std::vector< std::pair > Ledger::getLedgerHashes () { - std::vector< std::pair > ret; + std::vector< std::pair > ret; SLE::pointer hashIndex = getSLEi (getLedgerHashIndex ()); if (hashIndex) @@ -1600,7 +1601,7 @@ std::vector< std::pair > Ledger::getLedgerHashes () STVector256 vec = hashIndex->getFieldV256 (sfHashes); int size = vec.size (); ret.reserve (size); - uint32 seq = hashIndex->getFieldU32 (sfLastLedgerSequence) - size; + beast::uint32 seq = hashIndex->getFieldU32 (sfLastLedgerSequence) - size; for (int i = 0; i < size; ++i) ret.push_back (std::make_pair (++seq, vec.at (i))); @@ -1685,7 +1686,7 @@ uint256 Ledger::getBookBase (const uint160& uTakerPaysCurrency, const uint160& u return uBaseIndex; } -uint256 Ledger::getDirNodeIndex (uint256 const& uDirRoot, const uint64 uNodeIndex) +uint256 Ledger::getDirNodeIndex (uint256 const& uDirRoot, const beast::uint64 uNodeIndex) { if (uNodeIndex) { @@ -1726,7 +1727,7 @@ uint256 Ledger::getNicknameIndex (uint256 const& uNickname) return s.getSHA512Half (); } -uint256 Ledger::getOfferIndex (const uint160& uAccountID, uint32 uSequence) +uint256 Ledger::getOfferIndex (const uint160& uAccountID, beast::uint32 uSequence) { Serializer s (26); @@ -1816,7 +1817,7 @@ void Ledger::updateSkipList () if (mLedgerSeq == 0) // genesis ledger has no previous ledger return; - uint32 prevIndex = mLedgerSeq - 1; + beast::uint32 prevIndex = mLedgerSeq - 1; // update record of every 256th ledger if ((prevIndex & 0xff) == 0) @@ -1873,7 +1874,7 @@ void Ledger::updateSkipList () } } -uint32 Ledger::roundCloseTime (uint32 closeTime, uint32 closeResolution) +beast::uint32 Ledger::roundCloseTime (beast::uint32 closeTime, beast::uint32 closeResolution) { if (closeTime == 0) return 0; @@ -1922,7 +1923,7 @@ bool Ledger::pendSaveValidated (bool isSynchronous, bool isCurrent) return true; } -std::set Ledger::getPendingSaves() +std::set Ledger::getPendingSaves() { StaticScopedLockType sl (sPendingSaveLock, __FILE__, __LINE__); return sPendingSaves; @@ -1936,7 +1937,7 @@ void Ledger::ownerDirDescriber (SLE::ref sle, bool, const uint160& owner) void Ledger::qualityDirDescriber (SLE::ref sle, bool isNew, const uint160& uTakerPaysCurrency, const uint160& uTakerPaysIssuer, const uint160& uTakerGetsCurrency, const uint160& uTakerGetsIssuer, - const uint64& uRate) + const beast::uint64& uRate) { sle->setFieldH160 (sfTakerPaysCurrency, uTakerPaysCurrency); sle->setFieldH160 (sfTakerPaysIssuer, uTakerPaysIssuer); @@ -1958,10 +1959,10 @@ void Ledger::initializeFees () void Ledger::updateFees () { - uint64 baseFee = getConfig ().FEE_DEFAULT; - uint32 referenceFeeUnits = 10; - uint32 reserveBase = getConfig ().FEE_ACCOUNT_RESERVE; - int64 reserveIncrement = getConfig ().FEE_OWNER_RESERVE; + beast::uint64 baseFee = getConfig ().FEE_DEFAULT; + beast::uint32 referenceFeeUnits = 10; + beast::uint32 reserveBase = getConfig ().FEE_ACCOUNT_RESERVE; + beast::int64 reserveIncrement = getConfig ().FEE_OWNER_RESERVE; LedgerStateParms p = lepNONE; SLE::pointer sle = getASNode (p, Ledger::getLedgerFeeIndex (), ltFEE_SETTINGS); @@ -1993,7 +1994,7 @@ void Ledger::updateFees () } } -uint64 Ledger::scaleFeeBase (uint64 fee) +beast::uint64 Ledger::scaleFeeBase (beast::uint64 fee) { if (!mBaseFee) updateFees (); @@ -2001,7 +2002,7 @@ uint64 Ledger::scaleFeeBase (uint64 fee) return getApp().getFeeTrack ().scaleFeeBase (fee, mBaseFee, mReferenceFeeUnits); } -uint64 Ledger::scaleFeeLoad (uint64 fee, bool bAdmin) +beast::uint64 Ledger::scaleFeeLoad (beast::uint64 fee, bool bAdmin) { if (!mBaseFee) updateFees (); @@ -2041,7 +2042,7 @@ std::vector Ledger::getNeededAccountStateHashes (int max, SHAMapSyncFil //------------------------------------------------------------------------------ -class LedgerTests : public UnitTest +class LedgerTests : public beast::UnitTest { public: LedgerTests () : UnitTest ("Ledger", "ripple") @@ -2062,4 +2063,4 @@ public: static LedgerTests ledgerTests; Ledger::StaticLockType Ledger::sPendingSaveLock ("LedgerStatic", __FILE__, __LINE__); -std::set Ledger::sPendingSaves; +std::set Ledger::sPendingSaves; diff --git a/src/ripple_app/ledger/Ledger.h b/src/ripple_app/ledger/Ledger.h index c782117392..fdb69a9546 100644 --- a/src/ripple_app/ledger/Ledger.h +++ b/src/ripple_app/ledger/Ledger.h @@ -73,7 +73,7 @@ class Ledger : public boost::enable_shared_from_this , public LedgerBase , public CountedObject - , public Uncopyable + , public beast::Uncopyable { public: static char const* getCountedObjectName () { return "Ledger"; } @@ -97,14 +97,15 @@ public: }; // ledger close flags - static const uint32 sLCF_NoConsensusTime = 1; + static const beast::uint32 sLCF_NoConsensusTime = 1; public: - Ledger (const RippleAddress & masterID, uint64 startAmount); // used for the starting bootstrap ledger + Ledger (const RippleAddress & masterID, beast::uint64 startAmount); // used for the starting bootstrap ledger Ledger (uint256 const & parentHash, uint256 const & transHash, uint256 const & accountHash, - uint64 totCoins, uint32 closeTime, uint32 parentCloseTime, int closeFlags, int closeResolution, - uint32 ledgerSeq, bool & loaded); // used for database ledgers + beast::uint64 totCoins, beast::uint32 closeTime, beast::uint32 parentCloseTime, + int closeFlags, int closeResolution, + beast::uint32 ledgerSeq, bool & loaded); // used for database ledgers Ledger (Blob const & rawLedger, bool hasPrefix); @@ -120,7 +121,7 @@ public: static Ledger::pointer getSQL1 (SqliteStatement*); static void getSQL2 (Ledger::ref); static Ledger::pointer getLastFullLedger (); - static uint32 roundCloseTime (uint32 closeTime, uint32 closeResolution); + static beast::uint32 roundCloseTime (beast::uint32 closeTime, beast::uint32 closeResolution); void updateHash (); void setClosed () @@ -131,7 +132,7 @@ public: { mValidated = true; } - void setAccepted (uint32 closeTime, int closeResolution, bool correctCloseTime); + void setAccepted (beast::uint32 closeTime, int closeResolution, bool correctCloseTime); void setAccepted (); void setImmutable (); bool isClosed () @@ -177,23 +178,23 @@ public: { return mAccountHash; } - uint64 getTotalCoins () const + beast::uint64 getTotalCoins () const { return mTotCoins; } - void destroyCoins (uint64 fee) + void destroyCoins (beast::uint64 fee) { mTotCoins -= fee; } - uint32 getCloseTimeNC () const + beast::uint32 getCloseTimeNC () const { return mCloseTime; } - uint32 getParentCloseTimeNC () const + beast::uint32 getParentCloseTimeNC () const { return mParentCloseTime; } - uint32 getLedgerSeq () const + beast::uint32 getLedgerSeq () const { return mLedgerSeq; } @@ -207,7 +208,7 @@ public: } // close time functions - void setCloseTime (uint32 ct) + void setCloseTime (beast::uint32 ct) { assert (!mImmutable); mCloseTime = ct; @@ -268,11 +269,12 @@ public: void visitStateItems (std::function); // database functions (low-level) - static Ledger::pointer loadByIndex (uint32 ledgerIndex); + static Ledger::pointer loadByIndex (beast::uint32 ledgerIndex); static Ledger::pointer loadByHash (uint256 const & ledgerHash); - static uint256 getHashByIndex (uint32 index); - static bool getHashesByIndex (uint32 index, uint256 & ledgerHash, uint256 & parentHash); - static std::map< uint32, std::pair > getHashesByIndex (uint32 minSeq, uint32 maxSeq); + static uint256 getHashByIndex (beast::uint32 index); + static bool getHashesByIndex (beast::uint32 index, uint256 & ledgerHash, uint256 & parentHash); + static std::map< beast::uint32, std::pair > + getHashesByIndex (beast::uint32 minSeq, beast::uint32 maxSeq); bool pendSaveValidated (bool isSynchronous, bool isCurrent); // next/prev function @@ -290,11 +292,11 @@ public: // Ledger hash table function static uint256 getLedgerHashIndex (); - static uint256 getLedgerHashIndex (uint32 desiredLedgerIndex); - static int getLedgerHashOffset (uint32 desiredLedgerIndex); - static int getLedgerHashOffset (uint32 desiredLedgerIndex, uint32 currentLedgerIndex); - uint256 getLedgerHash (uint32 ledgerIndex); - std::vector< std::pair > getLedgerHashes (); + static uint256 getLedgerHashIndex (beast::uint32 desiredLedgerIndex); + static int getLedgerHashOffset (beast::uint32 desiredLedgerIndex); + static int getLedgerHashOffset (beast::uint32 desiredLedgerIndex, beast::uint32 currentLedgerIndex); + uint256 getLedgerHash (beast::uint32 ledgerIndex); + std::vector< std::pair > getLedgerHashes (); static uint256 getLedgerFeatureIndex (); static uint256 getLedgerFeeIndex (); @@ -360,13 +362,13 @@ public: SLE::pointer getOffer (uint256 const & uIndex); - SLE::pointer getOffer (const uint160 & uAccountID, uint32 uSequence) + SLE::pointer getOffer (const uint160 & uAccountID, beast::uint32 uSequence) { return getOffer (getOfferIndex (uAccountID, uSequence)); } // The index of an offer. - static uint256 getOfferIndex (const uint160 & uAccountID, uint32 uSequence); + static uint256 getOfferIndex (const uint160 & uAccountID, beast::uint32 uSequence); // // Owner functions @@ -383,7 +385,7 @@ public: // Directories are doubly linked lists of nodes. // Given a directory root and and index compute the index of a node. - static uint256 getDirNodeIndex (uint256 const & uDirRoot, const uint64 uNodeIndex = 0); + static uint256 getDirNodeIndex (uint256 const & uDirRoot, const beast::uint64 uNodeIndex = 0); static void ownerDirDescriber (SLE::ref, bool, const uint160 & owner); // Return a node: root or normal @@ -393,13 +395,13 @@ public: // Quality // - static uint256 getQualityIndex (uint256 const & uBase, const uint64 uNodeDir = 0); + static uint256 getQualityIndex (uint256 const & uBase, const beast::uint64 uNodeDir = 0); static uint256 getQualityNext (uint256 const & uBase); - static uint64 getQuality (uint256 const & uBase); + static beast::uint64 getQuality (uint256 const & uBase); static void qualityDirDescriber (SLE::ref, bool, const uint160 & uTakerPaysCurrency, const uint160 & uTakerPaysIssuer, const uint160 & uTakerGetsCurrency, const uint160 & uTakerGetsIssuer, - const uint64 & uRate); + const beast::uint64 & uRate); // // Ripple functions : credit lines @@ -427,38 +429,38 @@ public: return getRippleState (getRippleStateIndex (RippleAddress::createAccountID (uiA), RippleAddress::createAccountID (uiB), uCurrency)); } - uint32 getReferenceFeeUnits () + beast::uint32 getReferenceFeeUnits () { if (!mBaseFee) updateFees (); return mReferenceFeeUnits; } - uint64 getBaseFee () + beast::uint64 getBaseFee () { if (!mBaseFee) updateFees (); return mBaseFee; } - uint64 getReserve (int increments) + beast::uint64 getReserve (int increments) { if (!mBaseFee) updateFees (); - return scaleFeeBase (static_cast (increments) * mReserveIncrement + mReserveBase); + return scaleFeeBase (static_cast (increments) * mReserveIncrement + mReserveBase); } - uint64 getReserveInc () + beast::uint64 getReserveInc () { if (!mBaseFee) updateFees (); return mReserveIncrement; } - uint64 scaleFeeBase (uint64 fee); - uint64 scaleFeeLoad (uint64 fee, bool bAdmin); + beast::uint64 scaleFeeBase (beast::uint64 fee); + beast::uint64 scaleFeeLoad (beast::uint64 fee, bool bAdmin); - static std::set getPendingSaves(); + static std::set getPendingSaves(); Json::Value getJson (int options); void addJson (Json::Value&, int options); @@ -485,21 +487,21 @@ private: private: // The basic Ledger structure, can be opened, closed, or synching - uint256 mHash; - uint256 mParentHash; - uint256 mTransHash; - uint256 mAccountHash; - uint64 mTotCoins; - uint32 mLedgerSeq; - uint32 mCloseTime; // when this ledger closed - uint32 mParentCloseTime; // when the previous ledger closed - int mCloseResolution; // the resolution for this ledger close time (2-120 seconds) - uint32 mCloseFlags; // flags indicating how this ledger close took place - bool mClosed, mValidated, mValidHash, mAccepted, mImmutable; + uint256 mHash; + uint256 mParentHash; + uint256 mTransHash; + uint256 mAccountHash; + beast::uint64 mTotCoins; + beast::uint32 mLedgerSeq; + beast::uint32 mCloseTime; // when this ledger closed + beast::uint32 mParentCloseTime; // when the previous ledger closed + int mCloseResolution; // the resolution for this ledger close time (2-120 seconds) + beast::uint32 mCloseFlags; // flags indicating how this ledger close took place + bool mClosed, mValidated, mValidHash, mAccepted, mImmutable; - uint32 mReferenceFeeUnits; // Fee units for the reference transaction - uint32 mReserveBase, mReserveIncrement; // Reserve basse and increment in fee units - uint64 mBaseFee; // Ripple cost of the reference transaction + beast::uint32 mReferenceFeeUnits; // Fee units for the reference transaction + beast::uint32 mReserveBase, mReserveIncrement; // Reserve basse and increment in fee units + beast::uint64 mBaseFee; // Ripple cost of the reference transaction SHAMap::pointer mTransactionMap; SHAMap::pointer mAccountStateMap; @@ -509,7 +511,7 @@ private: // ledgers not fully saved, validated ledger present but DB may not be correct yet static StaticLockType sPendingSaveLock; - static std::set sPendingSaves; + static std::set sPendingSaves; }; inline LedgerStateParms operator| (const LedgerStateParms& l1, const LedgerStateParms& l2) diff --git a/src/ripple_app/ledger/LedgerCleaner.cpp b/src/ripple_app/ledger/LedgerCleaner.cpp index 983cc2011e..dc9e9a7a5e 100644 --- a/src/ripple_app/ledger/LedgerCleaner.cpp +++ b/src/ripple_app/ledger/LedgerCleaner.cpp @@ -33,8 +33,8 @@ Cleans up the ledger. Specifically, resolves these issues: class LedgerCleanerImp : public LedgerCleaner - , public Thread - , public LeakChecked + , public beast::Thread + , public beast::LeakChecked { public: struct State @@ -55,16 +55,16 @@ public: int failures; // Number of errors encountered since last success }; - typedef SharedData SharedState; + typedef beast::SharedData SharedState; SharedState m_state; - Journal m_journal; + beast::Journal m_journal; //-------------------------------------------------------------------------- LedgerCleanerImp ( Stoppable& stoppable, - Journal journal) + beast::Journal journal) : LedgerCleaner (stoppable) , Thread ("LedgerCleaner") , m_journal (journal) @@ -104,7 +104,7 @@ public: // //-------------------------------------------------------------------------- - void onWrite (PropertyStream::Map& map) + void onWrite (beast::PropertyStream::Map& map) { SharedState::Access state (m_state); @@ -428,7 +428,7 @@ public: LedgerCleaner::LedgerCleaner (Stoppable& parent) : Stoppable ("LedgerCleaner", parent) - , PropertyStream::Source ("ledgercleaner") + , beast::PropertyStream::Source ("ledgercleaner") { } @@ -438,7 +438,7 @@ LedgerCleaner::~LedgerCleaner () LedgerCleaner* LedgerCleaner::New ( Stoppable& parent, - Journal journal) + beast::Journal journal) { return new LedgerCleanerImp (parent, journal); } diff --git a/src/ripple_app/ledger/LedgerCleaner.h b/src/ripple_app/ledger/LedgerCleaner.h index 9a06b34838..14f07f6d51 100644 --- a/src/ripple_app/ledger/LedgerCleaner.h +++ b/src/ripple_app/ledger/LedgerCleaner.h @@ -22,8 +22,8 @@ /** Check the ledger/transaction databases to make sure they have continuity */ class LedgerCleaner - : public Stoppable - , public PropertyStream::Source + : public beast::Stoppable + , public beast::PropertyStream::Source { protected: explicit LedgerCleaner (Stoppable& parent); @@ -34,7 +34,7 @@ public: */ static LedgerCleaner* New ( Stoppable& parent, - Journal journal); + beast::Journal journal); /** Destroy the object. */ virtual ~LedgerCleaner () = 0; diff --git a/src/ripple_app/ledger/LedgerEntrySet.cpp b/src/ripple_app/ledger/LedgerEntrySet.cpp index dc91b71f5e..62d1148a14 100644 --- a/src/ripple_app/ledger/LedgerEntrySet.cpp +++ b/src/ripple_app/ledger/LedgerEntrySet.cpp @@ -27,7 +27,7 @@ SETUP_LOG (LedgerEntrySet) #define DIR_NODE_MAX 32 void LedgerEntrySet::init (Ledger::ref ledger, uint256 const& transactionID, - uint32 ledgerID, TransactionEngineParams params) + beast::uint32 ledgerID, TransactionEngineParams params) { mEntries.clear (); mLedger = ledger; @@ -422,7 +422,7 @@ bool LedgerEntrySet::threadTx (SLE::ref threadTo, Ledger::ref ledger, // node = the node that was modified/deleted/created // threadTo = the node that needs to know uint256 prevTxID; - uint32 prevLgrID; + beast::uint32 prevLgrID; if (!threadTo->thread (mSet.getTxID (), mSet.getLgrSeq (), prevTxID, prevLgrID)) return false; @@ -459,7 +459,7 @@ bool LedgerEntrySet::threadOwners (SLE::ref node, Ledger::ref ledger, return false; } -void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, uint32 index) +void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, beast::uint32 index) { // calculate the raw meta data and return it. This must be called before the set is committed @@ -507,7 +507,8 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, uint32 index) if ((type == &sfModifiedNode) && (*curNode == *origNode)) continue; - uint16 nodeType = curNode ? curNode->getFieldU16 (sfLedgerEntryType) : origNode->getFieldU16 (sfLedgerEntryType); + beast::uint16 nodeType = curNode ? curNode->getFieldU16 (sfLedgerEntryType) + : origNode->getFieldU16 (sfLedgerEntryType); mSet.setAffectedNode (it.first, *type, nodeType); @@ -598,9 +599,9 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, uint32 index) WriteLog (lsTRACE, LedgerEntrySet) << "Metadata:" << mSet.getJson (0); } -TER LedgerEntrySet::dirCount (uint256 const& uRootIndex, uint32& uCount) +TER LedgerEntrySet::dirCount (uint256 const& uRootIndex, beast::uint32& uCount) { - uint64 uNodeDir = 0; + beast::uint64 uNodeDir = 0; uCount = 0; @@ -630,7 +631,7 @@ TER LedgerEntrySet::dirCount (uint256 const& uRootIndex, uint32& uCount) bool LedgerEntrySet::dirIsEmpty (uint256 const& uRootIndex) { - uint64 uNodeDir = 0; + beast::uint64 uNodeDir = 0; SLE::pointer sleNode = entryCache (ltDIR_NODE, Ledger::getDirNodeIndex (uRootIndex, uNodeDir)); @@ -650,7 +651,7 @@ bool LedgerEntrySet::dirIsEmpty (uint256 const& uRootIndex) // Only append. This allow for things that watch append only structure to just monitor from the last node on ward. // Within a node with no deletions order of elements is sequential. Otherwise, order of elements is random. TER LedgerEntrySet::dirAdd ( - uint64& uNodeDir, + beast::uint64& uNodeDir, uint256 const& uRootIndex, uint256 const& uLedgerIndex, std::function fDescriber) @@ -739,13 +740,13 @@ TER LedgerEntrySet::dirAdd ( // Ledger must be in a state for this to work. TER LedgerEntrySet::dirDelete ( const bool bKeepRoot, // --> True, if we never completely clean up, after we overflow the root node. - const uint64& uNodeDir, // --> Node containing entry. + const beast::uint64& uNodeDir, // --> Node containing entry. uint256 const& uRootIndex, // --> The index of the base of the directory. Nodes are based off of this. uint256 const& uLedgerIndex, // --> Value to remove from directory. const bool bStable, // --> True, not to change relative order of entries. const bool bSoft) // --> True, uNodeDir is not hard and fast (pass uNodeDir=0). { - uint64 uNodeCur = uNodeDir; + beast::uint64 uNodeCur = uNodeDir; SLE::pointer sleNode = entryCache (ltDIR_NODE, Ledger::getDirNodeIndex (uRootIndex, uNodeCur)); if (!sleNode) @@ -825,8 +826,8 @@ TER LedgerEntrySet::dirDelete ( if (vuiIndexes.empty ()) { // May be able to delete nodes. - uint64 uNodePrevious = sleNode->getFieldU64 (sfIndexPrevious); - uint64 uNodeNext = sleNode->getFieldU64 (sfIndexNext); + beast::uint64 uNodePrevious = sleNode->getFieldU64 (sfIndexPrevious); + beast::uint64 uNodeNext = sleNode->getFieldU64 (sfIndexNext); if (!uNodeCur) { @@ -975,7 +976,7 @@ bool LedgerEntrySet::dirNext ( if (uDirEntry >= vuiIndexes.size ()) { - uint64 uNodeNext = sleNode->getFieldU64 (sfIndexNext); + beast::uint64 uNodeNext = sleNode->getFieldU64 (sfIndexNext); if (!uNodeNext) { @@ -1051,9 +1052,9 @@ void LedgerEntrySet::ownerCountAdjust (const uint160& uOwnerID, int iAmount, SLE ? sleAccountRoot : sleHold; - const uint32 uOwnerCount = sleRoot->getFieldU32 (sfOwnerCount); + const beast::uint32 uOwnerCount = sleRoot->getFieldU32 (sfOwnerCount); - const uint32 uNew = iAmount + int (uOwnerCount) > 0 + const beast::uint32 uNew = iAmount + int (uOwnerCount) > 0 ? uOwnerCount + iAmount : 0; @@ -1070,9 +1071,9 @@ TER LedgerEntrySet::offerDelete (SLE::pointer sleOffer) uint256 offerIndex = sleOffer->getIndex (); uint160 uOwnerID = sleOffer->getFieldAccount160 (sfAccount); bool bOwnerNode = sleOffer->isFieldPresent (sfOwnerNode); // Detect legacy dirs. - uint64 uOwnerNode = sleOffer->getFieldU64 (sfOwnerNode); + beast::uint64 uOwnerNode = sleOffer->getFieldU64 (sfOwnerNode); uint256 uDirectory = sleOffer->getFieldH256 (sfBookDirectory); - uint64 uBookNode = sleOffer->getFieldU64 (sfBookNode); + beast::uint64 uBookNode = sleOffer->getFieldU64 (sfBookNode); TER terResult = dirDelete (false, uOwnerNode, Ledger::getOwnerDirIndex (uOwnerID), offerIndex, false, !bOwnerNode); TER terResult2 = dirDelete (false, uBookNode, uDirectory, offerIndex, true, false); @@ -1157,11 +1158,11 @@ STAmount LedgerEntrySet::rippleLimit (const uint160& uToAccountID, const uint160 } -uint32 LedgerEntrySet::rippleTransferRate (const uint160& uIssuerID) +beast::uint32 LedgerEntrySet::rippleTransferRate (const uint160& uIssuerID) { SLE::pointer sleAccount = entryCache (ltACCOUNT_ROOT, Ledger::getAccountRootIndex (uIssuerID)); - uint32 uQuality = sleAccount && sleAccount->isFieldPresent (sfTransferRate) + beast::uint32 uQuality = sleAccount && sleAccount->isFieldPresent (sfTransferRate) ? sleAccount->getFieldU32 (sfTransferRate) : QUALITY_ONE; @@ -1173,7 +1174,10 @@ uint32 LedgerEntrySet::rippleTransferRate (const uint160& uIssuerID) return uQuality; } -uint32 LedgerEntrySet::rippleTransferRate (const uint160& uSenderID, const uint160& uReceiverID, const uint160& uIssuerID) +beast::uint32 +LedgerEntrySet::rippleTransferRate (const uint160& uSenderID, + const uint160& uReceiverID, + const uint160& uIssuerID) { return uSenderID == uIssuerID || uReceiverID == uIssuerID ? QUALITY_ONE @@ -1181,9 +1185,13 @@ uint32 LedgerEntrySet::rippleTransferRate (const uint160& uSenderID, const uint1 } // XXX Might not need this, might store in nodes on calc reverse. -uint32 LedgerEntrySet::rippleQualityIn (const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID, SField::ref sfLow, SField::ref sfHigh) +beast::uint32 +LedgerEntrySet::rippleQualityIn (const uint160& uToAccountID, + const uint160& uFromAccountID, + const uint160& uCurrencyID, SField::ref sfLow, + SField::ref sfHigh) { - uint32 uQuality = QUALITY_ONE; + beast::uint32 uQuality = QUALITY_ONE; SLE::pointer sleRippleState; if (uToAccountID == uFromAccountID) @@ -1263,7 +1271,7 @@ STAmount LedgerEntrySet::accountHolds (const uint160& uAccountID, const uint160& if (!uCurrencyID) { SLE::pointer sleAccount = entryCache (ltACCOUNT_ROOT, Ledger::getAccountRootIndex (uAccountID)); - uint64 uReserve = mLedger->getReserve (sleAccount->getFieldU32 (sfOwnerCount)); + beast::uint64 uReserve = mLedger->getReserve (sleAccount->getFieldU32 (sfOwnerCount)); STAmount saBalance = sleAccount->getFieldAmount (sfBalance); @@ -1330,11 +1338,11 @@ STAmount LedgerEntrySet::rippleTransferFee (const uint160& uSenderID, const uint { if (uSenderID != uIssuerID && uReceiverID != uIssuerID) { - uint32 uTransitRate = rippleTransferRate (uIssuerID); + beast::uint32 uTransitRate = rippleTransferRate (uIssuerID); if (QUALITY_ONE != uTransitRate) { - STAmount saTransitRate (CURRENCY_ONE, ACCOUNT_ONE, static_cast (uTransitRate), -9); + STAmount saTransitRate (CURRENCY_ONE, ACCOUNT_ONE, static_cast (uTransitRate), -9); STAmount saTransferTotal = STAmount::multiply (saAmount, saTransitRate, saAmount.getCurrency (), saAmount.getIssuer ()); STAmount saTransferFee = saTransferTotal - saAmount; @@ -1359,16 +1367,16 @@ TER LedgerEntrySet::trustCreate ( const bool bNoRipple, // --> others cannot ripple through const STAmount& saBalance, // --> balance of account being set. Issuer should be ACCOUNT_ONE const STAmount& saLimit, // --> limit for account being set. Issuer should be the account being set. - const uint32 uQualityIn, - const uint32 uQualityOut) + const beast::uint32 uQualityIn, + const beast::uint32 uQualityOut) { const uint160& uLowAccountID = !bSrcHigh ? uSrcAccountID : uDstAccountID; const uint160& uHighAccountID = bSrcHigh ? uSrcAccountID : uDstAccountID; SLE::pointer sleRippleState = entryCreate (ltRIPPLE_STATE, uIndex); - uint64 uLowNode; - uint64 uHighNode; + beast::uint64 uLowNode; + beast::uint64 uHighNode; TER terResult = dirAdd ( uLowNode, @@ -1402,7 +1410,7 @@ TER LedgerEntrySet::trustCreate ( if (uQualityOut) sleRippleState->setFieldU32 (!bSetHigh ? sfLowQualityOut : sfHighQualityOut, uQualityOut); - uint32 uFlags = !bSetHigh ? lsfLowReserve : lsfHighReserve; + beast::uint32 uFlags = !bSetHigh ? lsfLowReserve : lsfHighReserve; if (bAuth) { @@ -1427,8 +1435,8 @@ TER LedgerEntrySet::trustDelete (SLE::ref sleRippleState, const uint160& uLowAcc { bool bLowNode = sleRippleState->isFieldPresent (sfLowNode); // Detect legacy dirs. bool bHighNode = sleRippleState->isFieldPresent (sfHighNode); - uint64 uLowNode = sleRippleState->getFieldU64 (sfLowNode); - uint64 uHighNode = sleRippleState->getFieldU64 (sfHighNode); + beast::uint64 uLowNode = sleRippleState->getFieldU64 (sfLowNode); + beast::uint64 uHighNode = sleRippleState->getFieldU64 (sfHighNode); TER terResult; WriteLog (lsTRACE, LedgerEntrySet) << "trustDelete: Deleting ripple line: low"; @@ -1512,7 +1520,7 @@ TER LedgerEntrySet::rippleCredit (const uint160& uSenderID, const uint160& uRece % saBalance.getFullText ()); bool bDelete = false; - uint32 uFlags; + beast::uint32 uFlags; // YYY Could skip this if rippling in reverse. if (saBefore.isPositive () // Sender balance was positive. diff --git a/src/ripple_app/ledger/LedgerEntrySet.h b/src/ripple_app/ledger/LedgerEntrySet.h index 372c1b1802..cfc6251923 100644 --- a/src/ripple_app/ledger/LedgerEntrySet.h +++ b/src/ripple_app/ledger/LedgerEntrySet.h @@ -128,7 +128,8 @@ public: ++mSeq; } - void init (Ledger::ref ledger, uint256 const & transactionID, uint32 ledgerID, TransactionEngineParams params); + void init (Ledger::ref ledger, uint256 const & transactionID, + beast::uint32 ledgerID, TransactionEngineParams params); void clear (); @@ -157,14 +158,14 @@ public: // Directory functions. TER dirAdd ( - uint64 & uNodeDir, // Node of entry. + beast::uint64 & uNodeDir, // Node of entry. uint256 const & uRootIndex, uint256 const & uLedgerIndex, std::function fDescriber); TER dirDelete ( const bool bKeepRoot, - const uint64 & uNodeDir, // Node item is mentioned in. + const beast::uint64 & uNodeDir, // Node item is mentioned in. uint256 const & uRootIndex, uint256 const & uLedgerIndex, // Item being deleted const bool bStable, @@ -173,7 +174,7 @@ public: bool dirFirst (uint256 const & uRootIndex, SLE::pointer & sleNode, unsigned int & uDirEntry, uint256 & uEntryIndex); bool dirNext (uint256 const & uRootIndex, SLE::pointer & sleNode, unsigned int & uDirEntry, uint256 & uEntryIndex); bool dirIsEmpty (uint256 const & uDirIndex); - TER dirCount (uint256 const & uDirIndex, uint32 & uCount); + TER dirCount (uint256 const & uDirIndex, beast::uint32 & uCount); uint256 getNextLedgerIndex (uint256 const & uHash); uint256 getNextLedgerIndex (uint256 const & uHash, uint256 const & uEnd); @@ -185,13 +186,13 @@ public: TER offerDelete (SLE::pointer sleOffer); // Balance functions. - uint32 rippleTransferRate (const uint160 & uIssuerID); - uint32 rippleTransferRate (const uint160 & uSenderID, const uint160 & uReceiverID, const uint160 & uIssuerID); + beast::uint32 rippleTransferRate (const uint160 & uIssuerID); + beast::uint32 rippleTransferRate (const uint160 & uSenderID, const uint160 & uReceiverID, const uint160 & uIssuerID); STAmount rippleOwed (const uint160 & uToAccountID, const uint160 & uFromAccountID, const uint160 & uCurrencyID); STAmount rippleLimit (const uint160 & uToAccountID, const uint160 & uFromAccountID, const uint160 & uCurrencyID); - uint32 rippleQualityIn (const uint160 & uToAccountID, const uint160 & uFromAccountID, const uint160 & uCurrencyID, + beast::uint32 rippleQualityIn (const uint160 & uToAccountID, const uint160 & uFromAccountID, const uint160 & uCurrencyID, SField::ref sfLow = sfLowQualityIn, SField::ref sfHigh = sfHighQualityIn); - uint32 rippleQualityOut (const uint160 & uToAccountID, const uint160 & uFromAccountID, const uint160 & uCurrencyID) + beast::uint32 rippleQualityOut (const uint160 & uToAccountID, const uint160 & uFromAccountID, const uint160 & uCurrencyID) { return rippleQualityIn (uToAccountID, uFromAccountID, uCurrencyID, sfLowQualityOut, sfHighQualityOut); } @@ -215,12 +216,12 @@ public: const bool bNoRipple, const STAmount & saSrcBalance, const STAmount & saSrcLimit, - const uint32 uSrcQualityIn = 0, - const uint32 uSrcQualityOut = 0); + const beast::uint32 uSrcQualityIn = 0, + const beast::uint32 uSrcQualityOut = 0); TER trustDelete (SLE::ref sleRippleState, const uint160 & uLowAccountID, const uint160 & uHighAccountID); Json::Value getJson (int) const; - void calcRawMeta (Serializer&, TER result, uint32 index); + void calcRawMeta (Serializer&, TER result, beast::uint32 index); // iterator functions typedef std::map::iterator iterator; diff --git a/src/ripple_app/ledger/LedgerHistory.cpp b/src/ripple_app/ledger/LedgerHistory.cpp index ca74fa2819..4cbac2e276 100644 --- a/src/ripple_app/ledger/LedgerHistory.cpp +++ b/src/ripple_app/ledger/LedgerHistory.cpp @@ -49,10 +49,10 @@ void LedgerHistory::addLedger (Ledger::pointer ledger, bool validated) mLedgersByIndex[ledger->getLedgerSeq()] = ledger->getHash(); } -uint256 LedgerHistory::getLedgerHash (uint32 index) +uint256 LedgerHistory::getLedgerHash (beast::uint32 index) { LedgersByHash::ScopedLockType sl (m_ledgers_by_hash.peekMutex ()); - std::map::iterator it (mLedgersByIndex.find (index)); + std::map::iterator it (mLedgersByIndex.find (index)); if (it != mLedgersByIndex.end ()) return it->second; @@ -60,11 +60,11 @@ uint256 LedgerHistory::getLedgerHash (uint32 index) return uint256 (); } -Ledger::pointer LedgerHistory::getLedgerBySeq (uint32 index) +Ledger::pointer LedgerHistory::getLedgerBySeq (beast::uint32 index) { { LedgersByHash::ScopedLockType sl (m_ledgers_by_hash.peekMutex ()); - std::map ::iterator it (mLedgersByIndex.find (index)); + std::map ::iterator it (mLedgersByIndex.find (index)); if (it != mLedgersByIndex.end ()) { @@ -170,7 +170,7 @@ void LedgerHistory::validatedLedger (Ledger::ref ledger) bool LedgerHistory::fixIndex (LedgerIndex ledgerIndex, LedgerHash const& ledgerHash) { LedgersByHash::ScopedLockType sl (m_ledgers_by_hash.peekMutex ()); - std::map::iterator it (mLedgersByIndex.find (ledgerIndex)); + std::map::iterator it (mLedgersByIndex.find (ledgerIndex)); if ((it != mLedgersByIndex.end ()) && (it->second != ledgerHash) ) { diff --git a/src/ripple_app/ledger/LedgerHistory.h b/src/ripple_app/ledger/LedgerHistory.h index 94cbc57d66..c522cd5092 100644 --- a/src/ripple_app/ledger/LedgerHistory.h +++ b/src/ripple_app/ledger/LedgerHistory.h @@ -21,7 +21,7 @@ #define RIPPLE_LEDGERHISTORY_H // VFALCO TODO Rename to OldLedgers ? -class LedgerHistory : LeakChecked +class LedgerHistory : beast::LeakChecked { public: LedgerHistory (); diff --git a/src/ripple_app/ledger/LedgerMaster.cpp b/src/ripple_app/ledger/LedgerMaster.cpp index ffb77fd39b..24cd3d3643 100644 --- a/src/ripple_app/ledger/LedgerMaster.cpp +++ b/src/ripple_app/ledger/LedgerMaster.cpp @@ -27,7 +27,7 @@ template <> char const* LogPartition::getPartitionName () { r class LedgerMasterImp : public LedgerMaster - , public LeakChecked + , public beast::LeakChecked { public: typedef std::function callback; @@ -36,7 +36,7 @@ public: typedef LockType::ScopedLockType ScopedLockType; typedef LockType::ScopedUnlockType ScopedUnlockType; - Journal m_journal; + beast::Journal m_journal; LockType m_mutex; @@ -59,7 +59,7 @@ public: int mMinValidations; // The minimum validations to publish a ledger uint256 mLastValidateHash; - uint32 mLastValidateSeq; + beast::uint32 mLastValidateSeq; std::list mOnValidate; // Called when a ledger has enough validations bool mAdvanceThread; // Publish thread is running @@ -70,14 +70,14 @@ public: bool mPathFindNewLedger; bool mPathFindNewRequest; - std::atomic mPubLedgerClose; - std::atomic mPubLedgerSeq; - std::atomic mValidLedgerClose; - std::atomic mValidLedgerSeq; + std::atomic mPubLedgerClose; + std::atomic mPubLedgerSeq; + std::atomic mValidLedgerClose; + std::atomic mValidLedgerSeq; //-------------------------------------------------------------------------- - explicit LedgerMasterImp (Stoppable& parent, Journal journal) + explicit LedgerMasterImp (Stoppable& parent, beast::Journal journal) : LedgerMaster (parent) , m_journal (journal) , m_mutex (this, "LedgerMaster", __FILE__, __LINE__) @@ -101,22 +101,22 @@ public: { } - uint32 getCurrentLedgerIndex () + beast::uint32 getCurrentLedgerIndex () { return mCurrentLedger.get ()->getLedgerSeq (); } int getPublishedLedgerAge () { - uint32 pubClose = mPubLedgerClose.load(); + beast::uint32 pubClose = mPubLedgerClose.load(); if (!pubClose) { WriteLog (lsDEBUG, LedgerMaster) << "No published ledger"; return 999999; } - int64 ret = getApp().getOPs ().getCloseTimeNC (); - ret -= static_cast (pubClose); + beast::int64 ret = getApp().getOPs ().getCloseTimeNC (); + ret -= static_cast (pubClose); ret = std::max (0LL, ret); WriteLog (lsTRACE, LedgerMaster) << "Published ledger age is " << ret; @@ -125,15 +125,15 @@ public: int getValidatedLedgerAge () { - uint32 valClose = mValidLedgerClose.load(); + beast::uint32 valClose = mValidLedgerClose.load(); if (!valClose) { WriteLog (lsDEBUG, LedgerMaster) << "No validated ledger"; return 999999; } - int64 ret = getApp().getOPs ().getCloseTimeNC (); - ret -= static_cast (valClose); + beast::int64 ret = getApp().getOPs ().getCloseTimeNC (); + ret -= static_cast (valClose); ret = std::max (0LL, ret); WriteLog (lsTRACE, LedgerMaster) << "Validated ledger age is " << ret; @@ -147,8 +147,8 @@ public: reason = "No recently-published ledger"; return false; } - uint32 validClose = mValidLedgerClose.load(); - uint32 pubClose = mPubLedgerClose.load(); + beast::uint32 validClose = mValidLedgerClose.load(); + beast::uint32 pubClose = mPubLedgerClose.load(); if (!validClose || !pubClose) { reason = "No published ledger"; @@ -332,27 +332,27 @@ public: return result; } - bool haveLedgerRange (uint32 from, uint32 to) + bool haveLedgerRange (beast::uint32 from, beast::uint32 to) { ScopedLockType sl (mCompleteLock, __FILE__, __LINE__); - uint32 prevMissing = mCompleteLedgers.prevMissing (to + 1); + beast::uint32 prevMissing = mCompleteLedgers.prevMissing (to + 1); return (prevMissing == RangeSet::absent) || (prevMissing < from); } - bool haveLedger (uint32 seq) + bool haveLedger (beast::uint32 seq) { ScopedLockType sl (mCompleteLock, __FILE__, __LINE__); return mCompleteLedgers.hasValue (seq); } - void clearLedger (uint32 seq) + void clearLedger (beast::uint32 seq) { ScopedLockType sl (mCompleteLock, __FILE__, __LINE__); return mCompleteLedgers.clearValue (seq); } // returns Ledgers we have all the nodes for - bool getFullValidatedRange (uint32& minVal, uint32& maxVal) + bool getFullValidatedRange (beast::uint32& minVal, beast::uint32& maxVal) { maxVal = mPubLedgerSeq.load(); @@ -373,7 +373,7 @@ public: } // Returns Ledgers we have all the nodes for and are indexed - bool getValidatedRange (uint32& minVal, uint32& maxVal) + bool getValidatedRange (beast::uint32& minVal, beast::uint32& maxVal) { maxVal = mPubLedgerSeq.load(); @@ -393,7 +393,7 @@ public: // Remove from the validated range any ledger sequences that may not be // fully updated in the database yet - std::set sPendingSaves = Ledger::getPendingSaves(); + std::set sPendingSaves = Ledger::getPendingSaves(); if (!sPendingSaves.empty() && ((minVal != 0) || (maxVal != 0))) { @@ -406,7 +406,7 @@ public: ++minVal; // Best effort for remaining exclusions - BOOST_FOREACH(uint32 v, sPendingSaves) + BOOST_FOREACH(beast::uint32 v, sPendingSaves) { if ((v >= minVal) && (v <= maxVal)) { @@ -425,11 +425,11 @@ public: } // Get the earliest ledger we will let peers fetch - uint32 getEarliestFetch () + beast::uint32 getEarliestFetch () { // The earliest ledger we will let people fetch is ledger zero, // unless that creates a larger range than allowed - uint32 e = getClosedLedger()->getLedgerSeq(); + beast::uint32 e = getClosedLedger()->getLedgerSeq(); if (e > getConfig().FETCH_DEPTH) e -= getConfig().FETCH_DEPTH; else @@ -439,13 +439,13 @@ public: void tryFill (Job& job, Ledger::pointer ledger) { - uint32 seq = ledger->getLedgerSeq (); + beast::uint32 seq = ledger->getLedgerSeq (); uint256 prevHash = ledger->getParentHash (); - std::map< uint32, std::pair > ledgerHashes; + std::map< beast::uint32, std::pair > ledgerHashes; - uint32 minHas = ledger->getLedgerSeq (); - uint32 maxHas = ledger->getLedgerSeq (); + beast::uint32 minHas = ledger->getLedgerSeq (); + beast::uint32 maxHas = ledger->getLedgerSeq (); while (! job.shouldCancel() && seq > 0) { @@ -458,7 +458,7 @@ public: break; } - std::map< uint32, std::pair >::iterator it = ledgerHashes.find (seq); + std::map< beast::uint32, std::pair >::iterator it = ledgerHashes.find (seq); if (it == ledgerHashes.end ()) { @@ -533,7 +533,7 @@ public: int invalidate = 0; uint256 hash; - for (uint32 lSeq = ledger->getLedgerSeq () - 1; lSeq > 0; --lSeq) + for (beast::uint32 lSeq = ledger->getLedgerSeq () - 1; lSeq > 0; --lSeq) if (haveLedger (lSeq)) { try @@ -621,13 +621,13 @@ public: //-------------------------------------------------------------------------- } - void failedSave(uint32 seq, uint256 const& hash) + void failedSave(beast::uint32 seq, uint256 const& hash) { clearLedger(seq); getApp().getInboundLedgers().findCreate(hash, seq, InboundLedger::fcGENERIC); } - void checkAccept (uint256 const& hash, uint32 seq) + void checkAccept (uint256 const& hash, beast::uint32 seq) { if ((seq == 0) && (seq <= mValidLedgerSeq)) return; @@ -701,7 +701,7 @@ public: getApp().getOrderBookDB().setup(ledger); } - uint64 fee, fee2, ref; + beast::uint64 fee, fee2, ref; ref = getApp().getFeeTrack().getLoadBase(); int count = getApp().getValidations().getFeeAverage(ledger->getHash(), ref, fee); int count2 = getApp().getValidations().getFeeAverage(ledger->getParentHash(), ref, fee2); @@ -749,7 +749,7 @@ public: (getApp().getJobQueue().getJobCount(jtPUBOLDLEDGER) < 10) && (mValidLedgerSeq == mPubLedgerSeq)) { // We are in sync, so can acquire - uint32 missing; + beast::uint32 missing; { ScopedLockType sl (mCompleteLock, __FILE__, __LINE__); missing = mCompleteLedgers.prevMissing(mPubLedger->getLedgerSeq()); @@ -808,7 +808,7 @@ public: { for (int i = 0; i < getConfig().getSize(siLedgerFetch); ++i) { - uint32 seq = missing - i; + beast::uint32 seq = missing - i; uint256 hash = nextLedger->getLedgerHash(seq); if (hash.isNonZero()) getApp().getInboundLedgers().findCreate(hash, @@ -888,14 +888,14 @@ public: { int acqCount = 0; - uint32 pubSeq = mPubLedgerSeq + 1; // Next sequence to publish + beast::uint32 pubSeq = mPubLedgerSeq + 1; // Next sequence to publish Ledger::pointer valLedger = mValidLedger.get (); - uint32 valSeq = valLedger->getLedgerSeq (); + beast::uint32 valSeq = valLedger->getLedgerSeq (); ScopedUnlockType sul(m_mutex, __FILE__, __LINE__); try { - for (uint32 seq = pubSeq; seq <= valSeq; ++seq) + for (beast::uint32 seq = pubSeq; seq <= valSeq; ++seq) { WriteLog (lsTRACE, LedgerMaster) << "Trying to fetch/publish valid ledger " << seq; @@ -979,7 +979,7 @@ public: } // Return the hash of the valid ledger with a particular sequence, given a subsequent ledger known valid - uint256 getLedgerHash(uint32 desiredSeq, Ledger::ref knownGoodLedger) + uint256 getLedgerHash(beast::uint32 desiredSeq, Ledger::ref knownGoodLedger) { assert(desiredSeq < knownGoodLedger->getLedgerSeq()); @@ -988,7 +988,7 @@ public: // Not directly in the given ledger if (hash.isZero ()) { - uint32 seq = (desiredSeq + 255) % 256; + beast::uint32 seq = (desiredSeq + 255) % 256; assert(seq < desiredSeq); uint256 i = knownGoodLedger->getLedgerHash(seq); @@ -1045,8 +1045,8 @@ public: if (!getConfig().RUN_STANDALONE) { // don't pathfind with a ledger that's more than 60 seconds old - int64 age = getApp().getOPs().getCloseTimeNC(); - age -= static_cast (lastLedger->getCloseTimeNC()); + beast::int64 age = getApp().getOPs().getCloseTimeNC(); + age -= static_cast (lastLedger->getCloseTimeNC()); if (age > 60) { WriteLog (lsDEBUG, LedgerMaster) << "Published ledger too old for updating paths"; @@ -1154,7 +1154,7 @@ public: /** Find or acquire the ledger with the specified index and the specified hash Return a pointer to that ledger if it is immediately available */ - Ledger::pointer findAcquireLedger (uint32 index, uint256 const& hash) + Ledger::pointer findAcquireLedger (beast::uint32 index, uint256 const& hash) { Ledger::pointer ledger (getLedgerByHash (hash)); if (!ledger) @@ -1167,7 +1167,7 @@ public: return ledger; } - uint256 getHashBySeq (uint32 index) + uint256 getHashBySeq (beast::uint32 index) { uint256 hash = mLedgerHistory.getLedgerHash (index); @@ -1177,7 +1177,7 @@ public: return Ledger::getHashByIndex (index); } - uint256 walkHashBySeq (uint32 index) + uint256 walkHashBySeq (beast::uint32 index) { uint256 ledgerHash; Ledger::pointer referenceLedger; @@ -1195,7 +1195,7 @@ public: from the reference ledger or any prior ledger are not present in the node store. */ - uint256 walkHashBySeq (uint32 index, Ledger::ref referenceLedger) + uint256 walkHashBySeq (beast::uint32 index, Ledger::ref referenceLedger) { uint256 ledgerHash; if (!referenceLedger || (referenceLedger->getLedgerSeq() < index)) @@ -1224,7 +1224,7 @@ public: return ledgerHash; } - Ledger::pointer getLedgerBySeq (uint32 index) + Ledger::pointer getLedgerBySeq (beast::uint32 index) { Ledger::pointer ret = mLedgerHistory.getLedgerBySeq (index); if (ret) @@ -1267,7 +1267,7 @@ public: mLedgerCleaner->doClean (parameters); } - void setLedgerRangePresent (uint32 minV, uint32 maxV) + void setLedgerRangePresent (beast::uint32 minV, beast::uint32 maxV) { ScopedLockType sl (mCompleteLock, __FILE__, __LINE__); mCompleteLedgers.setRange (minV, maxV); @@ -1292,7 +1292,7 @@ public: mOnValidate.push_back (c); } - PropertyStream::Source& getPropertySource () + beast::PropertyStream::Source& getPropertySource () { return *mLedgerCleaner; } @@ -1310,7 +1310,7 @@ LedgerMaster::~LedgerMaster () } bool LedgerMaster::shouldAcquire ( - uint32 currentLedger, uint32 ledgerHistory, uint32 candidateLedger) + beast::uint32 currentLedger, beast::uint32 ledgerHistory, beast::uint32 candidateLedger) { bool ret; @@ -1324,7 +1324,7 @@ bool LedgerMaster::shouldAcquire ( } -LedgerMaster* LedgerMaster::New (Stoppable& parent, Journal journal) +LedgerMaster* LedgerMaster::New (Stoppable& parent, beast::Journal journal) { return new LedgerMasterImp (parent, journal); } diff --git a/src/ripple_app/ledger/LedgerMaster.h b/src/ripple_app/ledger/LedgerMaster.h index 4698932af4..478a0422fc 100644 --- a/src/ripple_app/ledger/LedgerMaster.h +++ b/src/ripple_app/ledger/LedgerMaster.h @@ -28,7 +28,7 @@ // It sounds like this holds all the ledgers... // class LedgerMaster - : public Stoppable + : public beast::Stoppable { protected: explicit LedgerMaster (Stoppable& parent); @@ -41,11 +41,11 @@ public: typedef LockType::ScopedLockType ScopedLockType; typedef LockType::ScopedUnlockType ScopedUnlockType; - static LedgerMaster* New (Stoppable& parent, Journal journal); + static LedgerMaster* New (Stoppable& parent, beast::Journal journal); virtual ~LedgerMaster () = 0; - virtual uint32 getCurrentLedgerIndex () = 0; + virtual beast::uint32 getCurrentLedgerIndex () = 0; virtual LockType& peekMutex () = 0; @@ -73,7 +73,7 @@ public: virtual void setMinValidations (int v) = 0; - virtual uint32 getEarliestFetch () = 0; + virtual beast::uint32 getEarliestFetch () = 0; virtual void pushLedger (Ledger::pointer newLedger) = 0; virtual void pushLedger (Ledger::pointer newLCL, Ledger::pointer newOL) = 0; @@ -84,7 +84,7 @@ public: virtual void switchLedgers (Ledger::pointer lastClosed, Ledger::pointer newCurrent) = 0; - virtual void failedSave(uint32 seq, uint256 const& hash) = 0; + virtual void failedSave(beast::uint32 seq, uint256 const& hash) = 0; virtual std::string getCompleteLedgers () = 0; @@ -92,31 +92,31 @@ public: /** Get a ledger's hash by sequence number using the cache */ - virtual uint256 getHashBySeq (uint32 index) = 0; + virtual uint256 getHashBySeq (beast::uint32 index) = 0; /** Walk to a ledger's hash using the skip list */ - virtual uint256 walkHashBySeq (uint32 index) = 0; - virtual uint256 walkHashBySeq (uint32 index, Ledger::ref referenceLedger) = 0; + virtual uint256 walkHashBySeq (beast::uint32 index) = 0; + virtual uint256 walkHashBySeq (beast::uint32 index, Ledger::ref referenceLedger) = 0; - virtual Ledger::pointer findAcquireLedger (uint32 index, uint256 const& hash) = 0; + virtual Ledger::pointer findAcquireLedger (beast::uint32 index, uint256 const& hash) = 0; - virtual Ledger::pointer getLedgerBySeq (uint32 index) = 0; + virtual Ledger::pointer getLedgerBySeq (beast::uint32 index) = 0; virtual Ledger::pointer getLedgerByHash (uint256 const& hash) = 0; - virtual void setLedgerRangePresent (uint32 minV, uint32 maxV) = 0; + virtual void setLedgerRangePresent (beast::uint32 minV, beast::uint32 maxV) = 0; - virtual uint256 getLedgerHash(uint32 desiredSeq, Ledger::ref knownGoodLedger) = 0; + virtual uint256 getLedgerHash(beast::uint32 desiredSeq, Ledger::ref knownGoodLedger) = 0; virtual void addHeldTransaction (Transaction::ref trans) = 0; virtual void fixMismatch (Ledger::ref ledger) = 0; - virtual bool haveLedgerRange (uint32 from, uint32 to) = 0; - virtual bool haveLedger (uint32 seq) = 0; - virtual void clearLedger (uint32 seq) = 0; - virtual bool getValidatedRange (uint32& minVal, uint32& maxVal) = 0; - virtual bool getFullValidatedRange (uint32& minVal, uint32& maxVal) = 0; + virtual bool haveLedgerRange (beast::uint32 from, beast::uint32 to) = 0; + virtual bool haveLedger (beast::uint32 seq) = 0; + virtual void clearLedger (beast::uint32 seq) = 0; + virtual bool getValidatedRange (beast::uint32& minVal, beast::uint32& maxVal) = 0; + virtual bool getFullValidatedRange (beast::uint32& minVal, beast::uint32& maxVal) = 0; virtual void tune (int size, int age) = 0; virtual void sweep () = 0; @@ -124,7 +124,7 @@ public: virtual void addValidateCallback (callback& c) = 0; virtual void checkAccept (Ledger::ref ledger) = 0; - virtual void checkAccept (uint256 const& hash, uint32 seq) = 0; + virtual void checkAccept (uint256 const& hash, beast::uint32 seq) = 0; virtual void tryAdvance () = 0; virtual void newPathRequest () = 0; @@ -134,9 +134,10 @@ public: virtual bool fixIndex (LedgerIndex ledgerIndex, LedgerHash const& ledgerHash) = 0; virtual void doLedgerCleaner(const Json::Value& parameters) = 0; - virtual PropertyStream::Source& getPropertySource () = 0; + virtual beast::PropertyStream::Source& getPropertySource () = 0; - static bool shouldAcquire (uint32 currentLedgerID, uint32 ledgerHistory, uint32 targetLedger); + static bool shouldAcquire (beast::uint32 currentLedgerID, + beast::uint32 ledgerHistory, beast::uint32 targetLedger); }; #endif diff --git a/src/ripple_app/ledger/LedgerProposal.cpp b/src/ripple_app/ledger/LedgerProposal.cpp index e80bfc3fbc..c70a87d197 100644 --- a/src/ripple_app/ledger/LedgerProposal.cpp +++ b/src/ripple_app/ledger/LedgerProposal.cpp @@ -17,7 +17,8 @@ */ //============================================================================== -LedgerProposal::LedgerProposal (uint256 const& pLgr, uint32 seq, uint256 const& tx, uint32 closeTime, +LedgerProposal::LedgerProposal (uint256 const& pLgr, beast::uint32 seq, + uint256 const& tx, beast::uint32 closeTime, const RippleAddress& naPeerPublic, uint256 const& suppression) : mPreviousLedger (pLgr), mCurrentHash (tx), mSuppression (suppression), mCloseTime (closeTime), mProposeSeq (seq), mPublicKey (naPeerPublic) @@ -32,7 +33,8 @@ LedgerProposal::LedgerProposal (uint256 const& pLgr, uint32 seq, uint256 const& LedgerProposal::LedgerProposal (const RippleAddress& naPub, const RippleAddress& naPriv, - uint256 const& prevLgr, uint256 const& position, uint32 closeTime) : + uint256 const& prevLgr, uint256 const& position, + beast::uint32 closeTime) : mPreviousLedger (prevLgr), mCurrentHash (position), mCloseTime (closeTime), mProposeSeq (0), mPublicKey (naPub), mPrivateKey (naPriv) { @@ -40,7 +42,8 @@ LedgerProposal::LedgerProposal (const RippleAddress& naPub, const RippleAddress& mTime = boost::posix_time::second_clock::universal_time (); } -LedgerProposal::LedgerProposal (uint256 const& prevLgr, uint256 const& position, uint32 closeTime) : +LedgerProposal::LedgerProposal (uint256 const& prevLgr, uint256 const& position, + beast::uint32 closeTime) : mPreviousLedger (prevLgr), mCurrentHash (position), mCloseTime (closeTime), mProposeSeq (0) { mTime = boost::posix_time::second_clock::universal_time (); @@ -63,8 +66,8 @@ uint256 LedgerProposal::getSigningHash () const uint256 LedgerProposal::computeSuppressionID ( uint256 const& proposeHash, uint256 const& previousLedger, - uint32 proposeSeq, - uint32 closeTime, + beast::uint32 proposeSeq, + beast::uint32 closeTime, Blob const& pubKey, Blob const& signature) { @@ -85,7 +88,7 @@ bool LedgerProposal::checkSign (const std::string& signature, uint256 const& sig return mPublicKey.verifyNodePublic (signingHash, signature, ECDSA::not_strict); } -bool LedgerProposal::changePosition (uint256 const& newPosition, uint32 closeTime) +bool LedgerProposal::changePosition (uint256 const& newPosition, beast::uint32 closeTime) { if (mProposeSeq == seqLeave) return false; diff --git a/src/ripple_app/ledger/LedgerProposal.h b/src/ripple_app/ledger/LedgerProposal.h index 55fff43eec..6897ef9540 100644 --- a/src/ripple_app/ledger/LedgerProposal.h +++ b/src/ripple_app/ledger/LedgerProposal.h @@ -26,21 +26,21 @@ class LedgerProposal public: static char const* getCountedObjectName () { return "LedgerProposal"; } - static const uint32 seqLeave = 0xffffffff; // leaving the consensus process + static const beast::uint32 seqLeave = 0xffffffff; // leaving the consensus process typedef boost::shared_ptr pointer; typedef const pointer& ref; // proposal from peer - LedgerProposal (uint256 const & prevLgr, uint32 proposeSeq, uint256 const & propose, - uint32 closeTime, const RippleAddress & naPeerPublic, uint256 const & suppress); + LedgerProposal (uint256 const & prevLgr, beast::uint32 proposeSeq, uint256 const & propose, + beast::uint32 closeTime, const RippleAddress & naPeerPublic, uint256 const & suppress); // our first proposal LedgerProposal (const RippleAddress & pubKey, const RippleAddress & privKey, - uint256 const & prevLedger, uint256 const & position, uint32 closeTime); + uint256 const & prevLedger, uint256 const & position, beast::uint32 closeTime); // an unsigned "dummy" proposal for nodes not validating - LedgerProposal (uint256 const & prevLedger, uint256 const & position, uint32 closeTime); + LedgerProposal (uint256 const & prevLedger, uint256 const & position, beast::uint32 closeTime); uint256 getSigningHash () const; bool checkSign (const std::string & signature, uint256 const & signingHash); @@ -69,11 +69,11 @@ public: { return mSuppression; } - uint32 getProposeSeq () const + beast::uint32 getProposeSeq () const { return mProposeSeq; } - uint32 getCloseTime () const + beast::uint32 getCloseTime () const { return mCloseTime; } @@ -117,21 +117,21 @@ public: return mTime <= cutoff; } - bool changePosition (uint256 const & newPosition, uint32 newCloseTime); + bool changePosition (uint256 const & newPosition, beast::uint32 newCloseTime); void bowOut (); Json::Value getJson () const; static uint256 computeSuppressionID ( uint256 const& proposeHash, uint256 const& previousLedger, - uint32 proposeSeq, - uint32 closeTime, + beast::uint32 proposeSeq, + beast::uint32 closeTime, Blob const& pubKey, Blob const& signature); private: uint256 mPreviousLedger, mCurrentHash, mSuppression; - uint32 mCloseTime, mProposeSeq; + beast::uint32 mCloseTime, mProposeSeq; uint160 mPeerID; RippleAddress mPublicKey; diff --git a/src/ripple_app/ledger/OrderBookDB.cpp b/src/ripple_app/ledger/OrderBookDB.cpp index f318ef37c3..c99e977265 100644 --- a/src/ripple_app/ledger/OrderBookDB.cpp +++ b/src/ripple_app/ledger/OrderBookDB.cpp @@ -248,7 +248,7 @@ void OrderBookDB::processTxn (Ledger::ref ledger, const AcceptedLedgerTx& alTx, { if (node.getFieldU16 (sfLedgerEntryType) == ltOFFER) { - SField* field = NULL; + SField* field = nullptr; // We need a field that contains the TakerGets and TakerPays parameters if (node.getFName () == sfModifiedNode) @@ -309,7 +309,7 @@ void BookListeners::addSubscriber (InfoSub::ref sub) mListeners[sub->getSeq ()] = sub; } -void BookListeners::removeSubscriber (uint64 seq) +void BookListeners::removeSubscriber (beast::uint64 seq) { ScopedLockType sl (mLock, __FILE__, __LINE__); mListeners.erase (seq); diff --git a/src/ripple_app/ledger/OrderBookDB.h b/src/ripple_app/ledger/OrderBookDB.h index f88b500508..d4f87df10d 100644 --- a/src/ripple_app/ledger/OrderBookDB.h +++ b/src/ripple_app/ledger/OrderBookDB.h @@ -28,7 +28,7 @@ public: BookListeners (); void addSubscriber (InfoSub::ref sub); - void removeSubscriber (uint64 sub); + void removeSubscriber (beast::uint64 sub); void publish (Json::Value const& jvObj); private: @@ -38,15 +38,15 @@ private: // VFALCO TODO Use a typedef for the uint64 // Use a typedef for the container - boost::unordered_map mListeners; + boost::unordered_map mListeners; }; //------------------------------------------------------------------------------ // VFALCO TODO Add Javadoc comment explaining what this class does class OrderBookDB - : public Stoppable - , public LeakChecked + : public beast::Stoppable + , public beast::LeakChecked { public: explicit OrderBookDB (Stoppable& parent); @@ -95,7 +95,7 @@ private: MapType mListeners; - uint32 mSeq; + beast::uint32 mSeq; }; diff --git a/src/ripple_app/ledger/OrderBookIterator.cpp b/src/ripple_app/ledger/OrderBookIterator.cpp index e371f013ea..5d0297ed2b 100644 --- a/src/ripple_app/ledger/OrderBookIterator.cpp +++ b/src/ripple_app/ledger/OrderBookIterator.cpp @@ -85,7 +85,7 @@ DirectoryEntryIterator BookDirIterator::getOfferIterator () const return DirectoryEntryIterator (mOfferDir); } -uint64 BookDirIterator::getRate () const +beast::uint64 BookDirIterator::getRate () const { return Ledger::getQuality(mIndex); } @@ -125,7 +125,7 @@ STAmount OrderBookIterator::getCurrentRate () const return mDirectoryIterator.getCurrentRate(); } -uint64 OrderBookIterator::getCurrentQuality () const +beast::uint64 OrderBookIterator::getCurrentQuality () const { return mDirectoryIterator.getCurrentQuality(); } diff --git a/src/ripple_app/ledger/OrderBookIterator.h b/src/ripple_app/ledger/OrderBookIterator.h index aedd14e0e4..a11aa15384 100644 --- a/src/ripple_app/ledger/OrderBookIterator.h +++ b/src/ripple_app/ledger/OrderBookIterator.h @@ -63,7 +63,7 @@ public: /** Get the current quality */ - uint64 getCurrentQuality () const + beast::uint64 getCurrentQuality () const { return Ledger::getQuality(mIndex); } @@ -85,7 +85,7 @@ public: */ DirectoryEntryIterator getOfferIterator () const; - uint64 getRate () const; + beast::uint64 getRate () const; bool addJson (Json::Value&) const; @@ -128,7 +128,7 @@ public: STAmount getCurrentRate () const; - uint64 getCurrentQuality () const; + beast::uint64 getCurrentQuality () const; uint256 getCurrentIndex () const; diff --git a/src/ripple_app/ledger/SerializedValidation.cpp b/src/ripple_app/ledger/SerializedValidation.cpp index 857c2cd0af..1222920d82 100644 --- a/src/ripple_app/ledger/SerializedValidation.cpp +++ b/src/ripple_app/ledger/SerializedValidation.cpp @@ -32,7 +32,7 @@ SerializedValidation::SerializedValidation (SerializerIterator& sit, bool checkS } SerializedValidation::SerializedValidation ( - uint256 const& ledgerHash, uint32 signTime, + uint256 const& ledgerHash, beast::uint32 signTime, const RippleAddress& raPub, bool isFull) : STObject (getFormat (), sfValidation) , mTrusted (false) @@ -73,12 +73,12 @@ uint256 SerializedValidation::getLedgerHash () const return getFieldH256 (sfLedgerHash); } -uint32 SerializedValidation::getSignTime () const +beast::uint32 SerializedValidation::getSignTime () const { return getFieldU32 (sfSigningTime); } -uint32 SerializedValidation::getFlags () const +beast::uint32 SerializedValidation::getFlags () const { return getFieldU32 (sfFlags); } diff --git a/src/ripple_app/ledger/SerializedValidation.h b/src/ripple_app/ledger/SerializedValidation.h index 6fc577725f..5290cff2f4 100644 --- a/src/ripple_app/ledger/SerializedValidation.h +++ b/src/ripple_app/ledger/SerializedValidation.h @@ -21,7 +21,7 @@ #define RIPPLE_SERIALIZEDVALIDATION_H // Validation flags -const uint32 vfFullyCanonicalSig = 0x80000000; // signature is fully canonical +const beast::uint32 vfFullyCanonicalSig = 0x80000000; // signature is fully canonical class SerializedValidation : public STObject @@ -42,11 +42,12 @@ public: SerializedValidation (SerializerIterator & sit, bool checkSignature = true); // Does not sign the validation - SerializedValidation (uint256 const & ledgerHash, uint32 signTime, const RippleAddress & raPub, bool isFull); + SerializedValidation (uint256 const & ledgerHash, beast::uint32 signTime, + const RippleAddress & raPub, bool isFull); uint256 getLedgerHash () const; - uint32 getSignTime () const; - uint32 getFlags () const; + beast::uint32 getSignTime () const; + beast::uint32 getFlags () const; RippleAddress getSignerPublic () const; uint160 getNodeID () const { diff --git a/src/ripple_app/main/Application.cpp b/src/ripple_app/main/Application.cpp index e450dc2cc1..2302665ff7 100644 --- a/src/ripple_app/main/Application.cpp +++ b/src/ripple_app/main/Application.cpp @@ -97,12 +97,12 @@ Application* ApplicationImpBase::s_instance; // VFALCO TODO Move the function definitions into the class declaration class ApplicationImp : public ApplicationImpBase - , public RootStoppable - , public DeadlineTimer::Listener - , public LeakChecked + , public beast::RootStoppable + , public beast::DeadlineTimer::Listener + , public beast::LeakChecked { public: - Journal m_journal; + beast::Journal m_journal; Application::LockType m_masterMutex; // These are not Stoppable-derived @@ -143,7 +143,7 @@ public: std::unique_ptr mValidations; std::unique_ptr mProofOfWorkFactory; std::unique_ptr m_loadManager; - DeadlineTimer m_sweepTimer; + beast::DeadlineTimer m_sweepTimer; bool volatile mShutdown; std::unique_ptr mRpcDB; @@ -159,22 +159,22 @@ public: std::unique_ptr m_wsPrivateDoor; std::unique_ptr m_wsProxyDoor; - WaitableEvent m_stop; + beast::WaitableEvent m_stop; std::unique_ptr m_resolver; - io_latency_probe m_probe; + beast::io_latency_probe m_probe; //-------------------------------------------------------------------------- class sample_io_service_latency { public: - insight::Event latency; - Journal journal; + beast::insight::Event latency; + beast::Journal journal; - sample_io_service_latency (insight::Event latency_, - Journal journal_) + sample_io_service_latency (beast::insight::Event latency_, + beast::Journal journal_) : latency (latency_) , journal (journal_) { @@ -310,7 +310,7 @@ public: , mShutdown (false) - , m_resolver (ResolverAsio::New (m_mainIoPool.getService (), Journal ())) + , m_resolver (ResolverAsio::New (m_mainIoPool.getService (), beast::Journal ())) , m_probe (std::chrono::milliseconds (100), m_mainIoPool.getService()) { @@ -490,7 +490,7 @@ public: // VFALCO TODO Move these to the .cpp bool running () { - return mTxnDB != NULL; // VFALCO TODO replace with nullptr when beast is available + return mTxnDB != nullptr; } bool getSystemTimeOffset (int& offset) { @@ -573,13 +573,13 @@ public: struct sigaction sa; memset (&sa, 0, sizeof (sa)); sa.sa_handler = &ApplicationImp::sigIntHandler; - sigaction (SIGINT, &sa, NULL); + sigaction (SIGINT, &sa, nullptr); } #endif #endif - assert (mTxnDB == NULL); + assert (mTxnDB == nullptr); if (!getConfig ().DEBUG_LOGFILE.empty ()) { @@ -714,7 +714,7 @@ public: if (m_wsPrivateDoor == nullptr) { - FatalError ("Could not open the WebSocket private interface.", + beast::FatalError ("Could not open the WebSocket private interface.", __FILE__, __LINE__); } } @@ -734,7 +734,7 @@ public: if (m_wsPublicDoor == nullptr) { - FatalError ("Could not open the WebSocket public interface.", + beast::FatalError ("Could not open the WebSocket public interface.", __FILE__, __LINE__); } } @@ -751,7 +751,7 @@ public: if (m_wsProxyDoor == nullptr) { - FatalError ("Could not open the WebSocket public interface.", + beast::FatalError ("Could not open the WebSocket public interface.", __FILE__, __LINE__); } } @@ -825,7 +825,7 @@ public: #endif #if 1 - if (getConfig().getValidatorsFile() != File::nonexistent ()) + if (getConfig().getValidatorsFile() != beast::File::nonexistent ()) { m_validators->addFile (getConfig().getValidatorsFile()); } @@ -893,7 +893,7 @@ public: // PropertyStream // - void onWrite (PropertyStream::Map& stream) + void onWrite (beast::PropertyStream::Map& stream) { } @@ -980,7 +980,7 @@ public: m_stop.signal(); } - void onDeadlineTimer (DeadlineTimer& timer) + void onDeadlineTimer (beast::DeadlineTimer& timer) { if (timer == m_sweepTimer) { @@ -1101,7 +1101,7 @@ bool ApplicationImp::loadOldLedger (const std::string& l, bool bReplay) loadLedger = Ledger::loadByHash (hash); } else // assume by sequence - loadLedger = Ledger::loadByIndex (lexicalCastThrow (l)); + loadLedger = Ledger::loadByIndex (beast::lexicalCastThrow (l)); if (!loadLedger) { @@ -1375,7 +1375,7 @@ void ApplicationImp::onAnnounceAddress () //------------------------------------------------------------------------------ Application::Application () - : PropertyStream::Source ("app") + : beast::PropertyStream::Source ("app") { } diff --git a/src/ripple_app/main/Application.h b/src/ripple_app/main/Application.h index 56dc5b1073..09dffadbad 100644 --- a/src/ripple_app/main/Application.h +++ b/src/ripple_app/main/Application.h @@ -56,7 +56,7 @@ class DatabaseCon; typedef TaggedCache NodeCache; typedef TaggedCache SLECache; -class Application : public PropertyStream::Source +class Application : public beast::PropertyStream::Source { public: /* VFALCO NOTE diff --git a/src/ripple_app/main/CollectorManager.cpp b/src/ripple_app/main/CollectorManager.cpp index 91d946ccd4..1a8a265823 100644 --- a/src/ripple_app/main/CollectorManager.cpp +++ b/src/ripple_app/main/CollectorManager.cpp @@ -23,42 +23,42 @@ class CollectorManagerImp : public CollectorManager { public: - Journal m_journal; - insight::Collector::ptr m_collector; - std::unique_ptr m_groups; + beast::Journal m_journal; + beast::insight::Collector::ptr m_collector; + std::unique_ptr m_groups; - CollectorManagerImp (StringPairArray const& params, - Journal journal) + CollectorManagerImp (beast::StringPairArray const& params, + beast::Journal journal) : m_journal (journal) { std::string const& server (params ["server"].toStdString()); if (server == "statsd") { - IP::Endpoint const address (IP::Endpoint::from_string ( + beast::IP::Endpoint const address (beast::IP::Endpoint::from_string ( params ["address"].toStdString ())); std::string const& prefix (params ["prefix"].toStdString ()); - m_collector = insight::StatsDCollector::New (address, prefix, journal); + m_collector = beast::insight::StatsDCollector::New (address, prefix, journal); } else { - m_collector = insight::NullCollector::New (); + m_collector = beast::insight::NullCollector::New (); } - m_groups = insight::make_Groups (m_collector); + m_groups = beast::insight::make_Groups (m_collector); } ~CollectorManagerImp () { } - insight::Collector::ptr const& collector () + beast::insight::Collector::ptr const& collector () { return m_collector; } - insight::Group::ptr const& group (std::string const& name) + beast::insight::Group::ptr const& group (std::string const& name) { return m_groups->get (name); } @@ -70,8 +70,8 @@ CollectorManager::~CollectorManager () { } -CollectorManager* CollectorManager::New (StringPairArray const& params, - Journal journal) +CollectorManager* CollectorManager::New (beast::StringPairArray const& params, + beast::Journal journal) { return new CollectorManagerImp (params, journal); } diff --git a/src/ripple_app/main/CollectorManager.h b/src/ripple_app/main/CollectorManager.h index ea5f16f10e..fcd6112d69 100644 --- a/src/ripple_app/main/CollectorManager.h +++ b/src/ripple_app/main/CollectorManager.h @@ -28,11 +28,11 @@ namespace ripple { class CollectorManager { public: - static CollectorManager* New (StringPairArray const& params, - Journal journal); + static CollectorManager* New (beast::StringPairArray const& params, + beast::Journal journal); virtual ~CollectorManager () = 0; - virtual insight::Collector::ptr const& collector () = 0; - virtual insight::Group::ptr const& group (std::string const& name) = 0; + virtual beast::insight::Collector::ptr const& collector () = 0; + virtual beast::insight::Group::ptr const& group (std::string const& name) = 0; }; } diff --git a/src/ripple_app/main/FatalErrorReporter.cpp b/src/ripple_app/main/FatalErrorReporter.cpp index 0534c2e980..90abe124b5 100644 --- a/src/ripple_app/main/FatalErrorReporter.cpp +++ b/src/ripple_app/main/FatalErrorReporter.cpp @@ -19,25 +19,25 @@ FatalErrorReporter::FatalErrorReporter () { - m_savedReporter = FatalError::setReporter (this); + m_savedReporter = beast::FatalError::setReporter (this); } FatalErrorReporter::~FatalErrorReporter () { - FatalError::setReporter (m_savedReporter); + beast::FatalError::setReporter (m_savedReporter); } -void FatalErrorReporter::reportMessage (String& formattedMessage) +void FatalErrorReporter::reportMessage (beast::String& formattedMessage) { Log::out() << formattedMessage.toRawUTF8 (); } //------------------------------------------------------------------------------ -class FatalErrorReporterTests : public UnitTest +class FatalErrorReporterTests : public beast::UnitTest { public: - FatalErrorReporterTests () : UnitTest ("FatalErrorReporter", "ripple", runManual) + FatalErrorReporterTests () : beast::UnitTest ("FatalErrorReporter", "ripple", runManual) { } @@ -50,7 +50,7 @@ public: // We don't really expect the program to run after this // but the unit test is here so you can manually test it. - FatalError ("The unit test intentionally failed", __FILE__, __LINE__); + beast::FatalError ("The unit test intentionally failed", __FILE__, __LINE__); } }; diff --git a/src/ripple_app/main/FatalErrorReporter.h b/src/ripple_app/main/FatalErrorReporter.h index 345641c72c..1e8e0ac4f5 100644 --- a/src/ripple_app/main/FatalErrorReporter.h +++ b/src/ripple_app/main/FatalErrorReporter.h @@ -31,16 +31,16 @@ constructors that can report a fatal error. Also, the Log would need to be guaranteed to be set up for this handler to work. */ -class FatalErrorReporter : public FatalError::Reporter +class FatalErrorReporter : public beast::FatalError::Reporter { public: FatalErrorReporter (); ~FatalErrorReporter (); - void reportMessage (String& formattedMessage); + void reportMessage (beast::String& formattedMessage); private: - FatalError::Reporter* m_savedReporter; + beast::FatalError::Reporter* m_savedReporter; }; #endif diff --git a/src/ripple_app/main/IoServicePool.cpp b/src/ripple_app/main/IoServicePool.cpp index 0462ac0095..0fb1601960 100644 --- a/src/ripple_app/main/IoServicePool.cpp +++ b/src/ripple_app/main/IoServicePool.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -class IoServicePool::ServiceThread : private Thread +class IoServicePool::ServiceThread : private beast::Thread { public: explicit ServiceThread ( - String const& name, + beast::String const& name, IoServicePool& owner, boost::asio::io_service& service) : Thread (name) @@ -56,7 +56,8 @@ private: //------------------------------------------------------------------------------ -IoServicePool::IoServicePool (Stoppable& parent, String const& name, int numberOfThreads) +IoServicePool::IoServicePool (Stoppable& parent, beast::String const& name, + int numberOfThreads) : Stoppable (name.toStdString().c_str(), parent) , m_name (name) , m_service (numberOfThreads) diff --git a/src/ripple_app/main/IoServicePool.h b/src/ripple_app/main/IoServicePool.h index d78d3b5d6a..172f909ab8 100644 --- a/src/ripple_app/main/IoServicePool.h +++ b/src/ripple_app/main/IoServicePool.h @@ -21,10 +21,10 @@ #define RIPPLE_APP_IOSERVICEPOOL_H_INCLUDED /** An io_service with an associated group of threads. */ -class IoServicePool : public Stoppable +class IoServicePool : public beast::Stoppable { public: - IoServicePool (Stoppable& parent, String const& name, int numberOfThreads); + IoServicePool (Stoppable& parent, beast::String const& name, int numberOfThreads); ~IoServicePool (); boost::asio::io_service& getService (); @@ -39,12 +39,12 @@ private: void onThreadExit(); - String m_name; + beast::String m_name; boost::asio::io_service m_service; boost::optional m_work; - OwnedArray m_threads; + beast::OwnedArray m_threads; int m_threadsDesired; - Atomic m_threadsRunning; + beast::Atomic m_threadsRunning; }; #endif diff --git a/src/ripple_app/main/LoadManager.cpp b/src/ripple_app/main/LoadManager.cpp index 8ab9c5cc41..570b0bf351 100644 --- a/src/ripple_app/main/LoadManager.cpp +++ b/src/ripple_app/main/LoadManager.cpp @@ -19,7 +19,7 @@ class LoadManagerImp : public LoadManager - , public Thread + , public beast::Thread { public: /* Entry mapping utilization to cost. @@ -69,7 +69,7 @@ public: //-------------------------------------------------------------------------- - Journal m_journal; + beast::Journal m_journal; typedef RippleMutex LockType; typedef LockType::ScopedLockType ScopedLockType; LockType mLock; @@ -82,7 +82,7 @@ public: //-------------------------------------------------------------------------- - LoadManagerImp (Stoppable& parent, Journal journal) + LoadManagerImp (Stoppable& parent, beast::Journal journal) : LoadManager (parent) , Thread ("loadmgr") , m_journal (journal) @@ -255,7 +255,7 @@ LoadManager::LoadManager (Stoppable& parent) //------------------------------------------------------------------------------ -LoadManager* LoadManager::New (Stoppable& parent, Journal journal) +LoadManager* LoadManager::New (Stoppable& parent, beast::Journal journal) { return new LoadManagerImp (parent, journal); } diff --git a/src/ripple_app/main/LoadManager.h b/src/ripple_app/main/LoadManager.h index bf713ffa40..4e75b7d57a 100644 --- a/src/ripple_app/main/LoadManager.h +++ b/src/ripple_app/main/LoadManager.h @@ -33,7 +33,7 @@ @see LoadSource, LoadType */ -class LoadManager : public Stoppable +class LoadManager : public beast::Stoppable { protected: explicit LoadManager (Stoppable& parent); @@ -44,7 +44,7 @@ public: @note The thresholds for warnings and punishments are in the ctor-initializer */ - static LoadManager* New (Stoppable& parent, Journal journal); + static LoadManager* New (Stoppable& parent, beast::Journal journal); /** Destroy the manager. diff --git a/src/ripple_app/main/LocalCredentials.h b/src/ripple_app/main/LocalCredentials.h index 3bee7db010..c7c6b02b8d 100644 --- a/src/ripple_app/main/LocalCredentials.h +++ b/src/ripple_app/main/LocalCredentials.h @@ -22,7 +22,7 @@ /** Holds the cryptographic credentials identifying this instance of the server. */ -class LocalCredentials : public Uncopyable +class LocalCredentials : public beast::Uncopyable { public: LocalCredentials (); diff --git a/src/ripple_app/main/NodeStoreScheduler.h b/src/ripple_app/main/NodeStoreScheduler.h index 8a97015589..5dc6e1a02e 100644 --- a/src/ripple_app/main/NodeStoreScheduler.h +++ b/src/ripple_app/main/NodeStoreScheduler.h @@ -23,7 +23,7 @@ /** A NodeStore::Scheduler which uses the JobQueue and implements the Stoppable API. */ class NodeStoreScheduler : public NodeStore::Scheduler - , public Stoppable + , public beast::Stoppable { public: NodeStoreScheduler (Stoppable& parent); diff --git a/src/ripple_app/main/ParameterTable.cpp b/src/ripple_app/main/ParameterTable.cpp index 4a755daf5c..cde7c0ac31 100644 --- a/src/ripple_app/main/ParameterTable.cpp +++ b/src/ripple_app/main/ParameterTable.cpp @@ -177,7 +177,7 @@ bool ParameterInt::setValue (const Json::Value& value, Json::Value& error) { try { - mValue = lexicalCastThrow (value.asString ()); + mValue = beast::lexicalCastThrow (value.asString ()); } catch (...) { diff --git a/src/ripple_app/main/RPCHTTPServer.cpp b/src/ripple_app/main/RPCHTTPServer.cpp index 826e180793..de33a51fab 100644 --- a/src/ripple_app/main/RPCHTTPServer.cpp +++ b/src/ripple_app/main/RPCHTTPServer.cpp @@ -23,12 +23,12 @@ namespace ripple { class RPCHTTPServerImp : public RPCHTTPServer - , public LeakChecked + , public beast::LeakChecked , public HTTP::Handler { public: Resource::Manager& m_resourceManager; - Journal m_journal; + beast::Journal m_journal; JobQueue& m_jobQueue; NetworkOPs& m_networkOPs; RPCServerHandler m_deprecatedHandler; @@ -36,7 +36,7 @@ public: std::unique_ptr m_context; RPCHTTPServerImp (Stoppable& parent, - Journal journal, + beast::Journal journal, JobQueue& jobQueue, NetworkOPs& networkOPs, Resource::Manager& resourceManager) @@ -66,12 +66,12 @@ public: m_server.stop(); } - void setup (Journal journal) + void setup (beast::Journal journal) { if (! getConfig ().getRpcIP().empty () && getConfig ().getRpcPort() != 0) { - IP::Endpoint ep (IP::Endpoint::from_string (getConfig().getRpcIP())); + beast::IP::Endpoint ep (beast::IP::Endpoint::from_string (getConfig().getRpcIP())); if (! is_unspecified (ep)) { HTTP::Port port; @@ -116,7 +116,7 @@ public: { // Reject non-loopback connections if RPC_ALLOW_REMOTE is not set if (! getConfig().RPC_ALLOW_REMOTE && - ! IP::is_loopback (session.remoteAddress())) + ! beast::IP::is_loopback (session.remoteAddress())) { session.close(); } @@ -176,7 +176,7 @@ public: } // Stolen directly from RPCServerHandler - std::string processRequest (std::string const& request, IP::Endpoint const& remoteIPAddress) + std::string processRequest (std::string const& request, beast::IP::Endpoint const& remoteIPAddress) { Json::Value jvRequest; { @@ -283,7 +283,7 @@ RPCHTTPServer::RPCHTTPServer (Stoppable& parent) //------------------------------------------------------------------------------ RPCHTTPServer* RPCHTTPServer::New (Stoppable& parent, - Journal journal, + beast::Journal journal, JobQueue& jobQueue, NetworkOPs& networkOPs, Resource::Manager& resourceManager) diff --git a/src/ripple_app/main/RPCHTTPServer.h b/src/ripple_app/main/RPCHTTPServer.h index bfebfdbc31..979a8a7076 100644 --- a/src/ripple_app/main/RPCHTTPServer.h +++ b/src/ripple_app/main/RPCHTTPServer.h @@ -22,19 +22,20 @@ namespace ripple { -class RPCHTTPServer : public Stoppable +class RPCHTTPServer : public beast::Stoppable { protected: RPCHTTPServer (Stoppable& parent); public: static RPCHTTPServer* New (Stoppable& parent, - Journal journal, JobQueue& jobQueue, NetworkOPs& networkOPs, Resource::Manager& resourceManager); + beast::Journal journal, JobQueue& jobQueue, NetworkOPs& networkOPs, + Resource::Manager& resourceManager); virtual ~RPCHTTPServer () { } /** Opens listening ports based on the Config settings. */ - virtual void setup (Journal journal) = 0; + virtual void setup (beast::Journal journal) = 0; }; } diff --git a/src/ripple_app/main/RippleMain.cpp b/src/ripple_app/main/RippleMain.cpp index 580c8fb8b9..08183fd13f 100644 --- a/src/ripple_app/main/RippleMain.cpp +++ b/src/ripple_app/main/RippleMain.cpp @@ -142,7 +142,7 @@ void printHelp (const po::options_description& desc) // OUr custom unit test runner // -class RippleUnitTests : public UnitTests +class RippleUnitTests : public beast::UnitTests { public: explicit RippleUnitTests (bool shouldLog) @@ -164,14 +164,14 @@ public: m_app = nullptr; } - void logMessage (String const& message) + void logMessage (beast::String const& message) { if (m_shouldLog) { #if BEAST_MSVC - if (beast_isRunningUnderDebugger ()) + if (beast::beast_isRunningUnderDebugger ()) { - Logger::outputDebugString (message); + beast::Logger::outputDebugString (message); } else { @@ -189,8 +189,8 @@ private: void setupConfigForUnitTests (Config* config) { config->nodeDatabase = parseDelimitedKeyValueString ("type=memory"); - config->ephemeralNodeDatabase = StringPairArray (); - config->importNodeDatabase = StringPairArray (); + config->ephemeralNodeDatabase = beast::StringPairArray (); + config->importNodeDatabase = beast::StringPairArray (); } private: @@ -198,13 +198,13 @@ private: std::unique_ptr m_app; }; -static int runUnitTests (String const& match, String const& format) +static int runUnitTests (beast::String const& match, beast::String const& format) { bool const shouldLog = format != "junit"; if (format != "junit" && format != "text" && format != "") { - String s; + beast::String s; s << "Warning, unknown unittest-format='" << format << "'"; Log::out () << s.toStdString (); } @@ -215,23 +215,23 @@ static int runUnitTests (String const& match, String const& format) if (format == "junit") { - UnitTestUtilities::JUnitXMLFormatter f (tr); + beast::UnitTestUtilities::JUnitXMLFormatter f (tr); - String const s = f.createDocumentString (); + beast::String const s = f.createDocumentString (); std::cout << s.toStdString (); } else { - UnitTests::Results const& r (tr.getResults ()); + beast::UnitTests::Results const& r (tr.getResults ()); - String s; + beast::String s; s << "Summary: " << - String (r.suites.size ()) << " suites, " << - String (r.cases) << " cases, " << - String (r.tests) << " tests, " << - String (r.failures) << " failure" << ((r.failures != 1) ? "s" : "") << "."; + beast::String (r.suites.size ()) << " suites, " << + beast::String (r.cases) << " cases, " << + beast::String (r.tests) << " tests, " << + beast::String (r.failures) << " failure" << ((r.failures != 1) ? "s" : "") << "."; tr.logMessage (s); } @@ -251,7 +251,7 @@ int RippleMain::run (int argc, char const* const* argv) int iResult = 0; po::variables_map vm; // Map of options. - String importDescription; + beast::String importDescription; { importDescription << "Import an existing node database (specified in the " << @@ -330,7 +330,7 @@ int RippleMain::run (int argc, char const* const* argv) if (vm.count ("version")) { - String const& s (BuildInfo::getVersionString ()); + beast::String const& s (BuildInfo::getVersionString ()); std::cout << "rippled version " << s.toStdString() << std::endl; return 0; } @@ -368,7 +368,7 @@ int RippleMain::run (int argc, char const* const* argv) // if (vm.count ("unittest")) { - String format; + beast::String format; if (vm.count ("unittest-format")) format = vm ["unittest-format"].as (); diff --git a/src/ripple_app/main/RippleMain.h b/src/ripple_app/main/RippleMain.h index 3754c7be48..58f4427ccf 100644 --- a/src/ripple_app/main/RippleMain.h +++ b/src/ripple_app/main/RippleMain.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_RIPPLEMAIN_H_INCLUDED #define RIPPLE_RIPPLEMAIN_H_INCLUDED -class RippleMain : public Main +class RippleMain : public beast::Main { public: RippleMain (); diff --git a/src/ripple_app/misc/AccountItems.cpp b/src/ripple_app/misc/AccountItems.cpp index 1666897e7a..8f6c213124 100644 --- a/src/ripple_app/misc/AccountItems.cpp +++ b/src/ripple_app/misc/AccountItems.cpp @@ -65,7 +65,7 @@ void AccountItems::fillItems (const uint160& accountID, Ledger::ref ledger) } } - uint64 uNodeNext = ownerDir->getFieldU64 (sfIndexNext); + beast::uint64 uNodeNext = ownerDir->getFieldU64 (sfIndexNext); // VFALCO TODO Rewrite to not return from the middle of the function if (!uNodeNext) diff --git a/src/ripple_app/misc/AccountItems.h b/src/ripple_app/misc/AccountItems.h index 98c0247382..09b63b1acb 100644 --- a/src/ripple_app/misc/AccountItems.h +++ b/src/ripple_app/misc/AccountItems.h @@ -22,7 +22,7 @@ /** A set of AccountItem objects. */ -class AccountItems : LeakChecked +class AccountItems : beast::LeakChecked { public: typedef boost::shared_ptr pointer; diff --git a/src/ripple_app/misc/AccountState.h b/src/ripple_app/misc/AccountState.h index 6a9270d25b..8f67637aaa 100644 --- a/src/ripple_app/misc/AccountState.h +++ b/src/ripple_app/misc/AccountState.h @@ -24,7 +24,7 @@ // Provide abstract access to an account's state, such that access to the serialized format is hidden. // -class AccountState : LeakChecked +class AccountState : beast::LeakChecked { public: typedef boost::shared_ptr pointer; @@ -51,7 +51,7 @@ public: return mLedgerEntry->getFieldAmount (sfBalance); } - uint32 getSeq () const + beast::uint32 getSeq () const { return mLedgerEntry->getFieldU32 (sfSequence); } diff --git a/src/ripple_app/misc/CanonicalTXSet.h b/src/ripple_app/misc/CanonicalTXSet.h index fbb99ba631..2b17e3f6d2 100644 --- a/src/ripple_app/misc/CanonicalTXSet.h +++ b/src/ripple_app/misc/CanonicalTXSet.h @@ -28,13 +28,13 @@ */ // VFALCO TODO rename to SortedTxSet -class CanonicalTXSet : LeakChecked +class CanonicalTXSet : beast::LeakChecked { public: class Key { public: - Key (uint256 const& account, uint32 seq, uint256 const& id) + Key (uint256 const& account, beast::uint32 seq, uint256 const& id) : mAccount (account) , mTXid (id) , mSeq (seq) @@ -63,7 +63,7 @@ public: private: uint256 mAccount; uint256 mTXid; - uint32 mSeq; + beast::uint32 mSeq; }; typedef std::map ::iterator iterator; diff --git a/src/ripple_app/misc/Features.cpp b/src/ripple_app/misc/Features.cpp index 56a466b6a2..c5dd8df714 100644 --- a/src/ripple_app/misc/Features.cpp +++ b/src/ripple_app/misc/Features.cpp @@ -21,7 +21,7 @@ class Features; SETUP_LOG (Features) -FeatureState* testFeature = NULL; +FeatureState* testFeature = nullptr; // VFALCO TODO Rename this to Features class Features : public IFeatures @@ -39,16 +39,16 @@ protected: featureMap_t mFeatureMap; int mMajorityTime; // Seconds a feature must hold a majority int mMajorityFraction; // 256 = 100% - uint32 mFirstReport; // close time of first majority report - uint32 mLastReport; // close time of most recent majority report + beast::uint32 mFirstReport; // close time of first majority report + beast::uint32 mLastReport; // close time of most recent majority report FeatureState* getCreateFeature (uint256 const& feature, bool create); - bool shouldEnable (uint32 closeTime, const FeatureState& fs); + bool shouldEnable (beast::uint32 closeTime, const FeatureState& fs); void setJson (Json::Value& v, const FeatureState&); public: - Features (uint32 majorityTime, int majorityFraction) + Features (beast::uint32 majorityTime, int majorityFraction) : mLock (this, "Features", __FILE__, __LINE__) , mMajorityTime (majorityTime), mMajorityFraction (majorityFraction), mFirstReport (0), mLastReport (0) { @@ -73,7 +73,7 @@ public: featureList_t getVetoedFeatures (); featureList_t getEnabledFeatures (); - featureList_t getFeaturesToEnable (uint32 closeTime); // gets features we would vote to enable + featureList_t getFeaturesToEnable (beast::uint32 closeTime); // gets features we would vote to enable featureList_t getDesiredFeatures (); // features we support, do not veto, are not enabled void reportValidations (const FeatureSet&); @@ -101,7 +101,7 @@ FeatureState* Features::getCreateFeature (uint256 const& featureHash, bool creat if (it == mFeatureMap.end ()) { if (!create) - return NULL; + return nullptr; FeatureState* feature = & (mFeatureMap[featureHash]); @@ -149,12 +149,12 @@ FeatureState* Features::addKnownFeature (const char* featureID, const char* frie if (hash.isZero ()) { assert (false); - return NULL; + return nullptr; } FeatureState* f = getCreateFeature (hash, true); - if (friendlyName != NULL) + if (friendlyName != nullptr) f->setFriendlyName (friendlyName); f->mVetoed = veto; @@ -249,7 +249,7 @@ Features::featureList_t Features::getEnabledFeatures () return ret; } -bool Features::shouldEnable (uint32 closeTime, const FeatureState& fs) +bool Features::shouldEnable (beast::uint32 closeTime, const FeatureState& fs) { if (fs.mVetoed || fs.mEnabled || !fs.mSupported || (fs.mLastMajority != mLastReport)) return false; @@ -265,7 +265,7 @@ bool Features::shouldEnable (uint32 closeTime, const FeatureState& fs) } -Features::featureList_t Features::getFeaturesToEnable (uint32 closeTime) +Features::featureList_t Features::getFeaturesToEnable (beast::uint32 closeTime) { featureList_t ret; ScopedLockType sl (mLock, __FILE__, __LINE__); @@ -498,7 +498,7 @@ Json::Value Features::getJson (uint256 const& feature) return ret; } -IFeatures* IFeatures::New (uint32 majorityTime, int majorityFraction) +IFeatures* IFeatures::New (beast::uint32 majorityTime, int majorityFraction) { return new Features (majorityTime, majorityFraction); } diff --git a/src/ripple_app/misc/FeeVote.cpp b/src/ripple_app/misc/FeeVote.cpp index aa92b5ae88..d582399ca9 100644 --- a/src/ripple_app/misc/FeeVote.cpp +++ b/src/ripple_app/misc/FeeVote.cpp @@ -81,7 +81,8 @@ private: }; public: - FeeVote (uint64 targetBaseFee, uint32 targetReserveBase, uint32 targetReserveIncrement) + FeeVote (beast::uint64 targetBaseFee, beast::uint32 targetReserveBase, + beast::uint32 targetReserveIncrement) : mTargetBaseFee (targetBaseFee) , mTargetReserveBase (targetReserveBase) , mTargetReserveIncrement (targetReserveIncrement) @@ -118,9 +119,9 @@ public: // LCL must be flag ledger assert ((lastClosedLedger->getLedgerSeq () % 256) == 0); - VotableInteger baseFeeVote (lastClosedLedger->getBaseFee (), mTargetBaseFee); - VotableInteger baseReserveVote (lastClosedLedger->getReserve (0), mTargetReserveBase); - VotableInteger incReserveVote (lastClosedLedger->getReserveInc (), mTargetReserveIncrement); + VotableInteger baseFeeVote (lastClosedLedger->getBaseFee (), mTargetBaseFee); + VotableInteger baseReserveVote (lastClosedLedger->getReserve (0), mTargetReserveBase); + VotableInteger incReserveVote (lastClosedLedger->getReserveInc (), mTargetReserveIncrement); // get validations for ledger before flag ValidationSet set = getApp().getValidations ().getValidations (lastClosedLedger->getParentHash ()); @@ -160,9 +161,9 @@ public: } // choose our positions - uint64 baseFee = baseFeeVote.getVotes (); - uint32 baseReserve = baseReserveVote.getVotes (); - uint32 incReserve = incReserveVote.getVotes (); + beast::uint64 baseFee = baseFeeVote.getVotes (); + beast::uint32 baseReserve = baseReserveVote.getVotes (); + beast::uint32 incReserve = incReserveVote.getVotes (); // add transactions to our position if ((baseFee != lastClosedLedger->getBaseFee ()) || @@ -195,16 +196,16 @@ public: } private: - uint64 mTargetBaseFee; - uint32 mTargetReserveBase; - uint32 mTargetReserveIncrement; + beast::uint64 mTargetBaseFee; + beast::uint32 mTargetReserveBase; + beast::uint32 mTargetReserveIncrement; }; //------------------------------------------------------------------------------ -IFeeVote* IFeeVote::New (uint64 targetBaseFee, - uint32 targetReserveBase, - uint32 targetReserveIncrement) +IFeeVote* IFeeVote::New (beast::uint64 targetBaseFee, + beast::uint32 targetReserveBase, + beast::uint32 targetReserveIncrement) { return new FeeVote (targetBaseFee, targetReserveBase, targetReserveIncrement); } diff --git a/src/ripple_app/misc/IFeatures.h b/src/ripple_app/misc/IFeatures.h index 00683c1aab..376518437f 100644 --- a/src/ripple_app/misc/IFeatures.h +++ b/src/ripple_app/misc/IFeatures.h @@ -24,11 +24,11 @@ class FeatureSet { // the status of all features requested in a given window public: - uint32 mCloseTime; + beast::uint32 mCloseTime; int mTrustedValidations; // number of trusted validations boost::unordered_map mVotes; // yes votes by feature - FeatureSet (uint32 ct, int tv) : mCloseTime (ct), mTrustedValidations (tv) + FeatureSet (beast::uint32 ct, int tv) : mCloseTime (ct), mTrustedValidations (tv) { ; } @@ -46,8 +46,8 @@ public: bool mSupported; bool mDefault; // Include in genesis ledger - uint32 mFirstMajority; // First time we saw a majority (close time) - uint32 mLastMajority; // Most recent time we saw a majority (close time) + beast::uint32 mFirstMajority; // First time we saw a majority (close time) + beast::uint32 mLastMajority; // Most recent time we saw a majority (close time) std::string mFriendlyName; @@ -101,7 +101,7 @@ public: class IFeatures { public: - static IFeatures* New (uint32 majorityTime, int majorityFraction); + static IFeatures* New (beast::uint32 majorityTime, int majorityFraction); virtual ~IFeatures () { } @@ -126,7 +126,7 @@ public: /* featureList_t getVetoedFeatures() = 0; featureList_t getEnabledFeatures() = 0; - featureList_t getFeaturesToEnable(uint32 closeTime) = 0; // gets features we would vote to enable + featureList_t getFeaturesToEnable(beast::uint32 closeTime) = 0; // gets features we would vote to enable featureList_t getDesiredFeatures() = 0; // features we support, do not veto, are not enabled */ diff --git a/src/ripple_app/misc/IFeeVote.h b/src/ripple_app/misc/IFeeVote.h index a7b17ce70e..9f1e85ee7a 100644 --- a/src/ripple_app/misc/IFeeVote.h +++ b/src/ripple_app/misc/IFeeVote.h @@ -31,9 +31,9 @@ public: @param targetReserveBase @param targetReserveIncrement */ - static IFeeVote* New (uint64 targetBaseFee, - uint32 targetReserveBase, - uint32 targetReserveIncrement); + static IFeeVote* New (beast::uint64 targetBaseFee, + beast::uint32 targetReserveBase, + beast::uint32 targetReserveIncrement); virtual ~IFeeVote () { } diff --git a/src/ripple_app/misc/IHashRouter.h b/src/ripple_app/misc/IHashRouter.h index ac43019127..9eb8f7cac9 100644 --- a/src/ripple_app/misc/IHashRouter.h +++ b/src/ripple_app/misc/IHashRouter.h @@ -40,7 +40,7 @@ class IHashRouter { public: // The type here *MUST* match the type of Peer::ShortId - typedef uint32 PeerShortID; + typedef beast::uint32 PeerShortID; // VFALCO NOTE this preferred alternative to default parameters makes // behavior clear. diff --git a/src/ripple_app/misc/NetworkOPs.cpp b/src/ripple_app/misc/NetworkOPs.cpp index f2222a2668..3b2a8252d9 100644 --- a/src/ripple_app/misc/NetworkOPs.cpp +++ b/src/ripple_app/misc/NetworkOPs.cpp @@ -19,8 +19,8 @@ class NetworkOPsImp : public NetworkOPs - , public DeadlineTimer::Listener - , public LeakChecked + , public beast::DeadlineTimer::Listener + , public beast::LeakChecked { public: enum Fault @@ -34,7 +34,7 @@ public: // VFALCO TODO Make LedgerMaster a SharedPtr or a reference. // NetworkOPsImp (clock_type& clock, LedgerMaster& ledgerMaster, - Stoppable& parent, Journal journal) + Stoppable& parent, beast::Journal journal) : NetworkOPs (parent) , m_clock (clock) , m_journal (journal) @@ -65,13 +65,13 @@ public: } // network information - uint32 getNetworkTimeNC (); // Our best estimate of wall time in seconds from 1/1/2000 - uint32 getCloseTimeNC (); // Our best estimate of current ledger close time - uint32 getValidationTimeNC (); // Use *only* to timestamp our own validation + beast::uint32 getNetworkTimeNC (); // Our best estimate of wall time in seconds from 1/1/2000 + beast::uint32 getCloseTimeNC (); // Our best estimate of current ledger close time + beast::uint32 getValidationTimeNC (); // Use *only* to timestamp our own validation void closeTimeOffset (int); boost::posix_time::ptime getNetworkTimePT (); - uint32 getLedgerID (uint256 const& hash); - uint32 getCurrentLedgerID (); + beast::uint32 getLedgerID (uint256 const& hash); + beast::uint32 getCurrentLedgerID (); OperatingMode getOperatingMode () { return mMode; @@ -98,8 +98,8 @@ public: { return m_ledgerMaster.getLedgerByHash (hash); } - Ledger::pointer getLedgerBySeq (const uint32 seq); - void missingNodeInLedger (const uint32 seq); + Ledger::pointer getLedgerBySeq (const beast::uint32 seq); + void missingNodeInLedger (const beast::uint32 seq); uint256 getClosedLedgerHash () { @@ -107,20 +107,20 @@ public: } // Do we have this inclusive range of ledgers in our database - bool haveLedgerRange (uint32 from, uint32 to); - bool haveLedger (uint32 seq); - uint32 getValidatedSeq (); - bool isValidated (uint32 seq); - bool isValidated (uint32 seq, uint256 const& hash); + bool haveLedgerRange (beast::uint32 from, beast::uint32 to); + bool haveLedger (beast::uint32 seq); + beast::uint32 getValidatedSeq (); + bool isValidated (beast::uint32 seq); + bool isValidated (beast::uint32 seq, uint256 const& hash); bool isValidated (Ledger::ref l) { return isValidated (l->getLedgerSeq (), l->getHash ()); } - bool getValidatedRange (uint32& minVal, uint32& maxVal) + bool getValidatedRange (beast::uint32& minVal, beast::uint32& maxVal) { return m_ledgerMaster.getValidatedRange (minVal, maxVal); } - bool getFullValidatedRange (uint32& minVal, uint32& maxVal) + bool getFullValidatedRange (beast::uint32& minVal, beast::uint32& maxVal) { return m_ledgerMaster.getFullValidatedRange (minVal, maxVal); } @@ -167,10 +167,10 @@ public: Transaction::pointer findTransactionByID (uint256 const& transactionID); #if 0 int findTransactionsBySource (uint256 const& uLedger, std::list&, const RippleAddress& sourceAccount, - uint32 minSeq, uint32 maxSeq); + beast::uint32 minSeq, beast::uint32 maxSeq); #endif int findTransactionsByDestination (std::list&, const RippleAddress& destinationAccount, - uint32 startLedgerSeq, uint32 endLedgerSeq, int maxTransactions); + beast::uint32 startLedgerSeq, beast::uint32 endLedgerSeq, int maxTransactions); // // Account functions @@ -184,7 +184,7 @@ public: // STVector256 getDirNodeInfo (Ledger::ref lrLedger, uint256 const& uRootIndex, - uint64& uNodePrevious, uint64& uNodeNext); + beast::uint64& uNodePrevious, beast::uint64& uNodeNext); #if 0 // @@ -227,9 +227,9 @@ public: void mapComplete (uint256 const& hash, SHAMap::ref map); bool stillNeedTXSet (uint256 const& hash); void makeFetchPack (Job&, boost::weak_ptr peer, boost::shared_ptr request, - Ledger::pointer wantLedger, Ledger::pointer haveLedger, uint32 uUptime); - bool shouldFetchPack (uint32 seq); - void gotFetchPack (bool progress, uint32 seq); + Ledger::pointer wantLedger, Ledger::pointer haveLedger, beast::uint32 uUptime); + bool shouldFetchPack (beast::uint32 seq); + void gotFetchPack (bool progress, beast::uint32 seq); void addFetchPack (uint256 const& hash, boost::shared_ptr< Blob >& data); bool getFetchPack (uint256 const& hash, Blob& data); int getFetchSize (); @@ -298,11 +298,11 @@ public: { return mLastCloseConvergeTime; } - uint32 getLastCloseTime () + beast::uint32 getLastCloseTime () { return mLastCloseTime; } - void setLastCloseTime (uint32 t) + void setLastCloseTime (beast::uint32 t) { mLastCloseTime = t; } @@ -310,7 +310,7 @@ public: Json::Value getServerInfo (bool human, bool admin); void clearLedgerFetch (); Json::Value getLedgerFetchInfo (); - uint32 acceptLedger (); + beast::uint32 acceptLedger (); boost::unordered_map < uint160, std::list > & peekStoredProposals () { @@ -322,26 +322,32 @@ public: //Helper function to generate SQL query to get transactions std::string transactionsSQL (std::string selection, const RippleAddress& account, - int32 minLedger, int32 maxLedger, bool descending, uint32 offset, int limit, + beast::int32 minLedger, beast::int32 maxLedger, + bool descending, beast::uint32 offset, int limit, bool binary, bool count, bool bAdmin); // client information retrieval functions std::vector< std::pair > - getAccountTxs (const RippleAddress& account, int32 minLedger, int32 maxLedger, bool descending, uint32 offset, int limit, bool bAdmin); + getAccountTxs (const RippleAddress& account, beast::int32 minLedger, beast::int32 maxLedger, + bool descending, beast::uint32 offset, int limit, bool bAdmin); std::vector< std::pair > - getTxsAccount (const RippleAddress& account, int32 minLedger, int32 maxLedger, bool forward, Json::Value& token, int limit, bool bAdmin); + getTxsAccount (const RippleAddress& account, beast::int32 minLedger, beast::int32 maxLedger, + bool forward, Json::Value& token, int limit, bool bAdmin); - typedef boost::tuple txnMetaLedgerType; + typedef boost::tuple txnMetaLedgerType; std::vector - getAccountTxsB (const RippleAddress& account, int32 minLedger, int32 maxLedger, bool descending, uint32 offset, int limit, bool bAdmin); + getAccountTxsB (const RippleAddress& account, beast::int32 minLedger, + beast::int32 maxLedger, bool descending, beast::uint32 offset, + int limit, bool bAdmin); std::vector - getTxsAccountB (const RippleAddress& account, int32 minLedger, int32 maxLedger, bool forward, Json::Value& token, int limit, bool bAdmin); + getTxsAccountB (const RippleAddress& account, beast::int32 minLedger, + beast::int32 maxLedger, bool forward, Json::Value& token, int limit, bool bAdmin); - std::vector getLedgerAffectedAccounts (uint32 ledgerSeq); + std::vector getLedgerAffectedAccounts (beast::uint32 ledgerSeq); // // Monitoring: publisher side @@ -353,25 +359,30 @@ public: // // InfoSub::Source // - void subAccount (InfoSub::ref ispListener, const boost::unordered_set& vnaAccountIDs, uint32 uLedgerIndex, bool rt); - void unsubAccount (uint64 uListener, const boost::unordered_set& vnaAccountIDs, bool rt); + void subAccount (InfoSub::ref ispListener, + const boost::unordered_set& vnaAccountIDs, + beast::uint32 uLedgerIndex, bool rt); + void unsubAccount (beast::uint64 uListener, + const boost::unordered_set& vnaAccountIDs, + bool rt); bool subLedger (InfoSub::ref ispListener, Json::Value& jvResult); - bool unsubLedger (uint64 uListener); + bool unsubLedger (beast::uint64 uListener); bool subServer (InfoSub::ref ispListener, Json::Value& jvResult); - bool unsubServer (uint64 uListener); + bool unsubServer (beast::uint64 uListener); bool subBook (InfoSub::ref ispListener, RippleCurrency const& currencyPays, RippleCurrency const& currencyGets, RippleIssuer const& issuerPays, RippleIssuer const& issuerGets); - bool unsubBook (uint64 uListener, RippleCurrency const& currencyPays, RippleCurrency const& currencyGets, + bool unsubBook (beast::uint64 uListener, RippleCurrency const& currencyPays, + RippleCurrency const& currencyGets, RippleIssuer const& issuerPays, RippleIssuer const& issuerGets); bool subTransactions (InfoSub::ref ispListener); - bool unsubTransactions (uint64 uListener); + bool unsubTransactions (beast::uint64 uListener); bool subRTTransactions (InfoSub::ref ispListener); - bool unsubRTTransactions (uint64 uListener); + bool unsubRTTransactions (beast::uint64 uListener); InfoSub::pointer findRpcSub (const std::string& strUrl); InfoSub::pointer addRpcSub (const std::string& strUrl, InfoSub::ref rspEntry); @@ -391,7 +402,7 @@ public: private: void setHeartbeatTimer (); void setClusterTimer (); - void onDeadlineTimer (DeadlineTimer& timer); + void onDeadlineTimer (beast::DeadlineTimer& timer); void processHeartbeatTimer (); void processClusterTimer (); @@ -419,7 +430,7 @@ private: typedef RippleRecursiveMutex LockType; typedef LockType::ScopedLockType ScopedLockType; - Journal m_journal; + beast::Journal m_journal; LockType mLock; OperatingMode mMode; @@ -427,8 +438,8 @@ private: bool mProposing, mValidating; bool mFeatureBlocked; boost::posix_time::ptime mConnectTime; - DeadlineTimer m_heartbeatTimer; - DeadlineTimer m_clusterTimer; + beast::DeadlineTimer m_heartbeatTimer; + beast::DeadlineTimer m_clusterTimer; boost::shared_ptr mConsensus; boost::unordered_map < uint160, std::list > mStoredProposals; @@ -441,8 +452,8 @@ private: // last ledger close int mLastCloseProposers, mLastCloseConvergeTime; uint256 mLastCloseHash; - uint32 mLastCloseTime; - uint32 mLastValidationTime; + beast::uint32 mLastCloseTime; + beast::uint32 mLastValidationTime; SerializedValidation::pointer mLastValidation; // Recent positions taken @@ -459,10 +470,10 @@ private: SubMapType mSubRTTransactions; // all proposed and accepted transactions TaggedCache< uint256, Blob> mFetchPack; - uint32 mFetchSeq; + beast::uint32 mFetchSeq; - uint32 mLastLoadBase; - uint32 mLastLoadFactor; + beast::uint32 mLastLoadBase; + beast::uint32 mLastLoadFactor; }; //------------------------------------------------------------------------------ @@ -483,7 +494,7 @@ void NetworkOPsImp::setClusterTimer () m_clusterTimer.setExpiration (10.0); } -void NetworkOPsImp::onDeadlineTimer (DeadlineTimer& timer) +void NetworkOPsImp::onDeadlineTimer (beast::DeadlineTimer& timer) { if (timer == m_heartbeatTimer) { @@ -624,19 +635,19 @@ boost::posix_time::ptime NetworkOPsImp::getNetworkTimePT () return boost::posix_time::microsec_clock::universal_time () + boost::posix_time::seconds (offset); } -uint32 NetworkOPsImp::getNetworkTimeNC () +beast::uint32 NetworkOPsImp::getNetworkTimeNC () { return iToSeconds (getNetworkTimePT ()); } -uint32 NetworkOPsImp::getCloseTimeNC () +beast::uint32 NetworkOPsImp::getCloseTimeNC () { return iToSeconds (getNetworkTimePT () + boost::posix_time::seconds (mCloseTimeOffset)); } -uint32 NetworkOPsImp::getValidationTimeNC () +beast::uint32 NetworkOPsImp::getValidationTimeNC () { - uint32 vt = getNetworkTimeNC (); + beast::uint32 vt = getNetworkTimeNC (); if (vt <= mLastValidationTime) vt = mLastValidationTime + 1; @@ -659,39 +670,39 @@ void NetworkOPsImp::closeTimeOffset (int offset) m_journal.info << "Close time offset now " << mCloseTimeOffset; } -uint32 NetworkOPsImp::getLedgerID (uint256 const& hash) +beast::uint32 NetworkOPsImp::getLedgerID (uint256 const& hash) { Ledger::pointer lrLedger = m_ledgerMaster.getLedgerByHash (hash); return lrLedger ? lrLedger->getLedgerSeq () : 0; } -Ledger::pointer NetworkOPsImp::getLedgerBySeq (const uint32 seq) +Ledger::pointer NetworkOPsImp::getLedgerBySeq (const beast::uint32 seq) { return m_ledgerMaster.getLedgerBySeq (seq); } -uint32 NetworkOPsImp::getCurrentLedgerID () +beast::uint32 NetworkOPsImp::getCurrentLedgerID () { return m_ledgerMaster.getCurrentLedger ()->getLedgerSeq (); } -bool NetworkOPsImp::haveLedgerRange (uint32 from, uint32 to) +bool NetworkOPsImp::haveLedgerRange (beast::uint32 from, beast::uint32 to) { return m_ledgerMaster.haveLedgerRange (from, to); } -bool NetworkOPsImp::haveLedger (uint32 seq) +bool NetworkOPsImp::haveLedger (beast::uint32 seq) { return m_ledgerMaster.haveLedger (seq); } -uint32 NetworkOPsImp::getValidatedSeq () +beast::uint32 NetworkOPsImp::getValidatedSeq () { return m_ledgerMaster.getValidatedLedger ()->getLedgerSeq (); } -bool NetworkOPsImp::isValidated (uint32 seq, uint256 const& hash) +bool NetworkOPsImp::isValidated (beast::uint32 seq, uint256 const& hash) { if (!isValidated (seq)) return false; @@ -699,7 +710,7 @@ bool NetworkOPsImp::isValidated (uint32 seq, uint256 const& hash) return m_ledgerMaster.getHashBySeq (seq) == hash; } -bool NetworkOPsImp::isValidated (uint32 seq) +bool NetworkOPsImp::isValidated (beast::uint32 seq) { // use when ledger was retrieved by seq return haveLedger (seq) && (seq <= m_ledgerMaster.getValidatedLedger ()->getLedgerSeq ()); @@ -996,7 +1007,8 @@ Transaction::pointer NetworkOPsImp::findTransactionByID (uint256 const& transact } int NetworkOPsImp::findTransactionsByDestination (std::list& txns, - const RippleAddress& destinationAccount, uint32 startLedgerSeq, uint32 endLedgerSeq, int maxTransactions) + const RippleAddress& destinationAccount, beast::uint32 startLedgerSeq, + beast::uint32 endLedgerSeq, int maxTransactions) { // WRITEME return 0; @@ -1027,8 +1039,8 @@ SLE::pointer NetworkOPsImp::getGenerator (Ledger::ref lrLedger, const uint160& u STVector256 NetworkOPsImp::getDirNodeInfo ( Ledger::ref lrLedger, uint256 const& uNodeIndex, - uint64& uNodePrevious, - uint64& uNodeNext) + beast::uint64& uNodePrevious, + beast::uint64& uNodeNext) { STVector256 svIndexes; SLE::pointer sleNode = lrLedger->getDirNode (uNodeIndex); @@ -1083,7 +1095,7 @@ Json::Value NetworkOPsImp::getOwnerInfo (Ledger::pointer lpLedger, const RippleA if (sleNode) { - uint64 uNodeDir; + beast::uint64 uNodeDir; do { @@ -1691,20 +1703,22 @@ void NetworkOPsImp::setMode (OperatingMode om) std::string NetworkOPsImp::transactionsSQL (std::string selection, const RippleAddress& account, - int32 minLedger, int32 maxLedger, bool descending, uint32 offset, int limit, + beast::int32 minLedger, beast::int32 maxLedger, bool descending, + beast::uint32 offset, int limit, bool binary, bool count, bool bAdmin) { - uint32 NONBINARY_PAGE_LENGTH = 200; - uint32 BINARY_PAGE_LENGTH = 500; + beast::uint32 NONBINARY_PAGE_LENGTH = 200; + beast::uint32 BINARY_PAGE_LENGTH = 500; - uint32 numberOfResults; + beast::uint32 numberOfResults; if (count) numberOfResults = 1000000000; else if (limit < 0) numberOfResults = binary ? BINARY_PAGE_LENGTH : NONBINARY_PAGE_LENGTH; else if (!bAdmin) - numberOfResults = std::min (binary ? BINARY_PAGE_LENGTH : NONBINARY_PAGE_LENGTH, static_cast (limit)); + numberOfResults = std::min (binary ? BINARY_PAGE_LENGTH + : NONBINARY_PAGE_LENGTH, static_cast (limit)); else numberOfResults = limit; @@ -1726,8 +1740,8 @@ NetworkOPsImp::transactionsSQL (std::string selection, const RippleAddress& acco % account.humanAccountID () % maxClause % minClause - % lexicalCastThrow (offset) - % lexicalCastThrow (numberOfResults) + % beast::lexicalCastThrow (offset) + % beast::lexicalCastThrow (numberOfResults) ); else sql = @@ -1743,15 +1757,17 @@ NetworkOPsImp::transactionsSQL (std::string selection, const RippleAddress& acco % (descending ? "DESC" : "ASC") % (descending ? "DESC" : "ASC") % (descending ? "DESC" : "ASC") - % lexicalCastThrow (offset) - % lexicalCastThrow (numberOfResults) + % beast::lexicalCastThrow (offset) + % beast::lexicalCastThrow (numberOfResults) ); m_journal.trace << "txSQL query: " << sql; return sql; } std::vector< std::pair > -NetworkOPsImp::getAccountTxs (const RippleAddress& account, int32 minLedger, int32 maxLedger, bool descending, uint32 offset, int limit, bool bAdmin) +NetworkOPsImp::getAccountTxs (const RippleAddress& account, beast::int32 minLedger, + beast::int32 maxLedger, bool descending, beast::uint32 offset, + int limit, bool bAdmin) { // can be called with no locks std::vector< std::pair > ret; @@ -1782,7 +1798,7 @@ NetworkOPsImp::getAccountTxs (const RippleAddress& account, int32 minLedger, int if (rawMeta.getLength() == 0) { // Work around a bug that could leave the metadata missing - uint32 seq = static_cast(db->getBigInt("LedgerSeq")); + beast::uint32 seq = static_cast(db->getBigInt("LedgerSeq")); m_journal.warning << "Recovering ledger " << seq << ", txn " << txn->getID(); Ledger::pointer ledger = getLedgerBySeq(seq); if (ledger) @@ -1800,7 +1816,8 @@ NetworkOPsImp::getAccountTxs (const RippleAddress& account, int32 minLedger, int } std::vector NetworkOPsImp::getAccountTxsB ( - const RippleAddress& account, int32 minLedger, int32 maxLedger, bool descending, uint32 offset, int limit, bool bAdmin) + const RippleAddress& account, beast::int32 minLedger, beast::int32 maxLedger, bool descending, + beast::uint32 offset, int limit, bool bAdmin) { // can be called with no locks std::vector< txnMetaLedgerType> ret; @@ -1851,16 +1868,18 @@ std::vector NetworkOPsImp::getAccountTxsB ( std::vector< std::pair > -NetworkOPsImp::getTxsAccount (const RippleAddress& account, int32 minLedger, int32 maxLedger, bool forward, Json::Value& token, int limit, bool bAdmin) +NetworkOPsImp::getTxsAccount (const RippleAddress& account, beast::int32 minLedger, + beast::int32 maxLedger, bool forward, Json::Value& token, + int limit, bool bAdmin) { std::vector< std::pair > ret; - uint32 NONBINARY_PAGE_LENGTH = 200; - uint32 EXTRA_LENGTH = 20; + beast::uint32 NONBINARY_PAGE_LENGTH = 200; + beast::uint32 EXTRA_LENGTH = 20; bool foundResume = token.isNull() || !token.isObject(); - uint32 numberOfResults, queryLimit; + beast::uint32 numberOfResults, queryLimit; if (limit <= 0) numberOfResults = NONBINARY_PAGE_LENGTH; else if (!bAdmin && (limit > NONBINARY_PAGE_LENGTH)) @@ -1869,7 +1888,7 @@ NetworkOPsImp::getTxsAccount (const RippleAddress& account, int32 minLedger, int numberOfResults = limit; queryLimit = numberOfResults + 1 + (foundResume ? 0 : EXTRA_LENGTH); - uint32 findLedger = 0, findSeq = 0; + beast::uint32 findLedger = 0, findSeq = 0; if (!foundResume) { try @@ -1940,7 +1959,7 @@ NetworkOPsImp::getTxsAccount (const RippleAddress& account, int32 minLedger, int if (rawMeta.getLength() == 0) { // Work around a bug that could leave the metadata missing - uint32 seq = static_cast(db->getBigInt("LedgerSeq")); + beast::uint32 seq = static_cast(db->getBigInt("LedgerSeq")); m_journal.warning << "Recovering ledger " << seq << ", txn " << txn->getID(); Ledger::pointer ledger = getLedgerBySeq(seq); if (ledger) @@ -1959,16 +1978,18 @@ NetworkOPsImp::getTxsAccount (const RippleAddress& account, int32 minLedger, int } std::vector -NetworkOPsImp::getTxsAccountB (const RippleAddress& account, int32 minLedger, int32 maxLedger, bool forward, Json::Value& token, int limit, bool bAdmin) +NetworkOPsImp::getTxsAccountB (const RippleAddress& account, beast::int32 minLedger, + beast::int32 maxLedger, bool forward, Json::Value& token, + int limit, bool bAdmin) { std::vector ret; - uint32 BINARY_PAGE_LENGTH = 500; - uint32 EXTRA_LENGTH = 20; + beast::uint32 BINARY_PAGE_LENGTH = 500; + beast::uint32 EXTRA_LENGTH = 20; bool foundResume = token.isNull() || !token.isObject(); - uint32 numberOfResults, queryLimit; + beast::uint32 numberOfResults, queryLimit; if (limit <= 0) numberOfResults = BINARY_PAGE_LENGTH; else if (!bAdmin && (limit > BINARY_PAGE_LENGTH)) @@ -1977,7 +1998,7 @@ NetworkOPsImp::getTxsAccountB (const RippleAddress& account, int32 minLedger, in numberOfResults = limit; queryLimit = numberOfResults + 1 + (foundResume ? 0 : EXTRA_LENGTH); - uint32 findLedger = 0, findSeq = 0; + beast::uint32 findLedger = 0, findSeq = 0; if (!foundResume) { try @@ -2065,7 +2086,7 @@ NetworkOPsImp::getTxsAccountB (const RippleAddress& account, int32 minLedger, in std::vector -NetworkOPsImp::getLedgerAffectedAccounts (uint32 ledgerSeq) +NetworkOPsImp::getLedgerAffectedAccounts (beast::uint32 ledgerSeq) { std::vector accounts; std::string sql = str (boost::format @@ -2117,7 +2138,7 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin) else { // Only admins get the hostname for security reasons - info ["hostid"] = SystemStats::getComputerName(); + info ["hostid"] = beast::SystemStats::getComputerName(); } } @@ -2180,8 +2201,8 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin) static_cast (getApp().getFeeTrack ().getLoadFactor ()) / getApp().getFeeTrack ().getLoadBase (); if (admin) { - uint32 base = getApp().getFeeTrack().getLoadBase(); - uint32 fee = getApp().getFeeTrack().getLocalFee(); + beast::uint32 base = getApp().getFeeTrack().getLoadBase(); + beast::uint32 fee = getApp().getFeeTrack().getLocalFee(); if (fee != base) info["load_factor_local"] = static_cast (fee) / base; @@ -2206,8 +2227,8 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin) if (lpClosed) { - uint64 baseFee = lpClosed->getBaseFee (); - uint64 baseRef = lpClosed->getReferenceFeeUnits (); + beast::uint64 baseFee = lpClosed->getBaseFee (); + beast::uint64 baseRef = lpClosed->getReferenceFeeUnits (); Json::Value l (Json::objectValue); l["seq"] = Json::UInt (lpClosed->getLedgerSeq ()); l["hash"] = lpClosed->getHash ().GetHex (); @@ -2227,12 +2248,12 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin) l["reserve_inc_xrp"] = static_cast (Json::UInt (lpClosed->getReserveInc () * baseFee / baseRef)) / SYSTEM_CURRENCY_PARTS; - uint32 closeTime = getCloseTimeNC (); - uint32 lCloseTime = lpClosed->getCloseTimeNC (); + beast::uint32 closeTime = getCloseTimeNC (); + beast::uint32 lCloseTime = lpClosed->getCloseTimeNC (); if (lCloseTime <= closeTime) { - uint32 age = closeTime - lCloseTime; + beast::uint32 age = closeTime - lCloseTime; if (age < 1000000) l["age"] = Json::UInt (age); @@ -2539,7 +2560,9 @@ void NetworkOPsImp::pubAccountTransaction (Ledger::ref lpCurrent, const Accepted // Monitoring // -void NetworkOPsImp::subAccount (InfoSub::ref isrListener, const boost::unordered_set& vnaAccountIDs, uint32 uLedgerIndex, bool rt) +void NetworkOPsImp::subAccount (InfoSub::ref isrListener, + const boost::unordered_set& vnaAccountIDs, + beast::uint32 uLedgerIndex, bool rt) { SubInfoMapType& subMap = rt ? mSubRTAccount : mSubAccount; @@ -2572,7 +2595,9 @@ void NetworkOPsImp::subAccount (InfoSub::ref isrListener, const boost::unordered } } -void NetworkOPsImp::unsubAccount (uint64 uSeq, const boost::unordered_set& vnaAccountIDs, bool rt) +void NetworkOPsImp::unsubAccount (beast::uint64 uSeq, + const boost::unordered_set& vnaAccountIDs, + bool rt) { SubInfoMapType& subMap = rt ? mSubRTAccount : mSubAccount; @@ -2622,7 +2647,7 @@ bool NetworkOPsImp::subBook (InfoSub::ref isrListener, RippleCurrency const& cur return true; } -bool NetworkOPsImp::unsubBook (uint64 uSeq, +bool NetworkOPsImp::unsubBook (beast::uint64 uSeq, RippleCurrency const& currencyPays, RippleCurrency const& currencyGets, RippleIssuer const& issuerPays, RippleIssuer const& issuerGets) { BookListeners::pointer listeners = @@ -2642,7 +2667,7 @@ void NetworkOPsImp::newLCL (int proposers, int convergeTime, uint256 const& ledg mLastCloseHash = ledgerHash; } -uint32 NetworkOPsImp::acceptLedger () +beast::uint32 NetworkOPsImp::acceptLedger () { // accept the current transaction tree, return the new ledger's sequence beginConsensus (m_ledgerMaster.getClosedLedger ()->getHash (), m_ledgerMaster.getCurrentLedger ()); @@ -2695,7 +2720,7 @@ bool NetworkOPsImp::subLedger (InfoSub::ref isrListener, Json::Value& jvResult) } // <-- bool: true=erased, false=was not there -bool NetworkOPsImp::unsubLedger (uint64 uSeq) +bool NetworkOPsImp::unsubLedger (beast::uint64 uSeq) { ScopedLockType sl (mLock, __FILE__, __LINE__); return !!mSubLedger.erase (uSeq); @@ -2720,7 +2745,7 @@ bool NetworkOPsImp::subServer (InfoSub::ref isrListener, Json::Value& jvResult) } // <-- bool: true=erased, false=was not there -bool NetworkOPsImp::unsubServer (uint64 uSeq) +bool NetworkOPsImp::unsubServer (beast::uint64 uSeq) { ScopedLockType sl (mLock, __FILE__, __LINE__); return !!mSubServer.erase (uSeq); @@ -2734,7 +2759,7 @@ bool NetworkOPsImp::subTransactions (InfoSub::ref isrListener) } // <-- bool: true=erased, false=was not there -bool NetworkOPsImp::unsubTransactions (uint64 uSeq) +bool NetworkOPsImp::unsubTransactions (beast::uint64 uSeq) { ScopedLockType sl (mLock, __FILE__, __LINE__); return !!mSubTransactions.erase (uSeq); @@ -2748,7 +2773,7 @@ bool NetworkOPsImp::subRTTransactions (InfoSub::ref isrListener) } // <-- bool: true=erased, false=was not there -bool NetworkOPsImp::unsubRTTransactions (uint64 uSeq) +bool NetworkOPsImp::unsubRTTransactions (beast::uint64 uSeq) { ScopedLockType sl (mLock, __FILE__, __LINE__); return !!mSubRTTransactions.erase (uSeq); @@ -2808,7 +2833,7 @@ void NetworkOPsImp::getBookPage (Ledger::pointer lpLedger, const uint160& uTaker if ((iLeft == 0) || (iLeft > 300)) iLeft = 300; - uint32 uTransferRate = lesActive.rippleTransferRate (uTakerGetsIssuerID); + beast::uint32 uTransferRate = lesActive.rippleTransferRate (uTakerGetsIssuerID); while (!bDone && (--iLeft > 0)) { @@ -2884,7 +2909,7 @@ void NetworkOPsImp::getBookPage (Ledger::pointer lpLedger, const uint160& uTaker STAmount saTakerGetsFunded; STAmount saOwnerFundsLimit; - uint32 uOfferRate; + beast::uint32 uOfferRate; if (uTransferRate != QUALITY_ONE // Have a tranfer fee. @@ -2977,7 +3002,7 @@ void NetworkOPsImp::getBookPage (Ledger::pointer lpLedger, const uint160& uTaker if ((iLeft == 0) || (iLeft > 300)) iLeft = 300; - uint32 uTransferRate = lesActive.rippleTransferRate (uTakerGetsIssuerID); + beast::uint32 uTransferRate = lesActive.rippleTransferRate (uTakerGetsIssuerID); while ((--iLeft > 0) && obIterator.nextOffer ()) { @@ -3027,7 +3052,7 @@ void NetworkOPsImp::getBookPage (Ledger::pointer lpLedger, const uint160& uTaker STAmount saTakerGetsFunded; STAmount saOwnerFundsLimit; - uint32 uOfferRate; + beast::uint32 uOfferRate; if (uTransferRate != QUALITY_ONE // Have a tranfer fee. @@ -3088,7 +3113,7 @@ void NetworkOPsImp::getBookPage (Ledger::pointer lpLedger, const uint160& uTaker #endif -static void fpAppender (protocol::TMGetObjectByHash* reply, uint32 ledgerSeq, +static void fpAppender (protocol::TMGetObjectByHash* reply, beast::uint32 ledgerSeq, const uint256& hash, const Blob& blob) { protocol::TMIndexedObject& newObj = * (reply->add_objects ()); @@ -3099,7 +3124,8 @@ static void fpAppender (protocol::TMGetObjectByHash* reply, uint32 ledgerSeq, void NetworkOPsImp::makeFetchPack (Job&, boost::weak_ptr wPeer, boost::shared_ptr request, - Ledger::pointer wantLedger, Ledger::pointer haveLedger, uint32 uUptime) + Ledger::pointer wantLedger, Ledger::pointer haveLedger, + beast::uint32 uUptime) { if (UptimeTimer::getInstance ().getElapsedSeconds () > (uUptime + 1)) { @@ -3131,7 +3157,7 @@ void NetworkOPsImp::makeFetchPack (Job&, boost::weak_ptr wPeer, do { - uint32 lSeq = wantLedger->getLedgerSeq (); + beast::uint32 lSeq = wantLedger->getLedgerSeq (); protocol::TMIndexedObject& newObj = *reply.add_objects (); newObj.set_hash (wantLedger->getHash ().begin (), 256 / 8); @@ -3145,7 +3171,7 @@ void NetworkOPsImp::makeFetchPack (Job&, boost::weak_ptr wPeer, BIND_TYPE (fpAppender, &reply, lSeq, P_1, P_2)); if (wantLedger->getTransHash ().isNonZero ()) - wantLedger->peekTransactionMap ()->getFetchPack (NULL, true, 256, + wantLedger->peekTransactionMap ()->getFetchPack (nullptr, true, 256, BIND_TYPE (fpAppender, &reply, lSeq, P_1, P_2)); if (reply.objects ().size () >= 256) @@ -3195,7 +3221,7 @@ bool NetworkOPsImp::getFetchPack (uint256 const& hash, Blob& data) return true; } -bool NetworkOPsImp::shouldFetchPack (uint32 seq) +bool NetworkOPsImp::shouldFetchPack (beast::uint32 seq) { if (mFetchSeq == seq) return false; @@ -3208,7 +3234,7 @@ int NetworkOPsImp::getFetchSize () return mFetchPack.getCacheSize (); } -void NetworkOPsImp::gotFetchPack (bool progress, uint32 seq) +void NetworkOPsImp::gotFetchPack (bool progress, beast::uint32 seq) { // FIXME: Calling this function more than once will result in @@ -3219,7 +3245,7 @@ void NetworkOPsImp::gotFetchPack (bool progress, uint32 seq) BIND_TYPE (&InboundLedgers::gotFetchPack, &getApp().getInboundLedgers (), P_1)); } -void NetworkOPsImp::missingNodeInLedger (uint32 seq) +void NetworkOPsImp::missingNodeInLedger (beast::uint32 seq) { uint256 hash = getApp().getLedgerMaster ().getHashBySeq (seq); if (hash.isZero()) @@ -3247,7 +3273,7 @@ NetworkOPs::~NetworkOPs () //------------------------------------------------------------------------------ NetworkOPs* NetworkOPs::New (clock_type& clock, LedgerMaster& ledgerMaster, - Stoppable& parent, Journal journal) + Stoppable& parent, beast::Journal journal) { return new NetworkOPsImp (clock, ledgerMaster, parent, journal); } diff --git a/src/ripple_app/misc/NetworkOPs.h b/src/ripple_app/misc/NetworkOPs.h index feb982a9dd..3d82ecd87b 100644 --- a/src/ripple_app/misc/NetworkOPs.h +++ b/src/ripple_app/misc/NetworkOPs.h @@ -56,7 +56,7 @@ protected: explicit NetworkOPs (Stoppable& parent); public: - typedef abstract_clock clock_type; + typedef beast::abstract_clock clock_type; enum Fault { @@ -77,13 +77,13 @@ public: // VFALCO TODO Fix OrderBookDB to not need this unrelated type. // - typedef boost::unordered_map SubMapType; + typedef boost::unordered_map SubMapType; public: // VFALCO TODO Make LedgerMaster a SharedPtr or a reference. // static NetworkOPs* New (clock_type& clock, LedgerMaster& ledgerMaster, - Stoppable& parent, Journal journal); + Stoppable& parent, beast::Journal journal); virtual ~NetworkOPs () = 0; @@ -93,15 +93,15 @@ public: // // Our best estimate of wall time in seconds from 1/1/2000 - virtual uint32 getNetworkTimeNC () = 0; + virtual beast::uint32 getNetworkTimeNC () = 0; // Our best estimate of current ledger close time - virtual uint32 getCloseTimeNC () = 0; + virtual beast::uint32 getCloseTimeNC () = 0; // Use *only* to timestamp our own validation - virtual uint32 getValidationTimeNC () = 0; + virtual beast::uint32 getValidationTimeNC () = 0; virtual void closeTimeOffset (int) = 0; virtual boost::posix_time::ptime getNetworkTimePT () = 0; - virtual uint32 getLedgerID (uint256 const& hash) = 0; - virtual uint32 getCurrentLedgerID () = 0; + virtual beast::uint32 getLedgerID (uint256 const& hash) = 0; + virtual beast::uint32 getCurrentLedgerID () = 0; virtual OperatingMode getOperatingMode () = 0; virtual std::string strOperatingMode () = 0; @@ -110,20 +110,20 @@ public: virtual Ledger::pointer getPublishedLedger () = 0; virtual Ledger::pointer getCurrentLedger () = 0; virtual Ledger::pointer getLedgerByHash (uint256 const& hash) = 0; - virtual Ledger::pointer getLedgerBySeq (const uint32 seq) = 0; - virtual void missingNodeInLedger (const uint32 seq) = 0; + virtual Ledger::pointer getLedgerBySeq (const beast::uint32 seq) = 0; + virtual void missingNodeInLedger (const beast::uint32 seq) = 0; virtual uint256 getClosedLedgerHash () = 0; // Do we have this inclusive range of ledgers in our database - virtual bool haveLedgerRange (uint32 from, uint32 to) = 0; - virtual bool haveLedger (uint32 seq) = 0; - virtual uint32 getValidatedSeq () = 0; - virtual bool isValidated (uint32 seq) = 0; - virtual bool isValidated (uint32 seq, uint256 const& hash) = 0; + virtual bool haveLedgerRange (beast::uint32 from, beast::uint32 to) = 0; + virtual bool haveLedger (beast::uint32 seq) = 0; + virtual beast::uint32 getValidatedSeq () = 0; + virtual bool isValidated (beast::uint32 seq) = 0; + virtual bool isValidated (beast::uint32 seq, uint256 const& hash) = 0; virtual bool isValidated (Ledger::ref l) = 0; - virtual bool getValidatedRange (uint32& minVal, uint32& maxVal) = 0; - virtual bool getFullValidatedRange (uint32& minVal, uint32& maxVal) = 0; + virtual bool getValidatedRange (beast::uint32& minVal, beast::uint32& maxVal) = 0; + virtual bool getFullValidatedRange (beast::uint32& minVal, beast::uint32& maxVal) = 0; virtual SerializedValidation::ref getLastValidation () = 0; virtual void setLastValidation (SerializedValidation::ref v) = 0; @@ -149,8 +149,8 @@ public: bool bAdmin, bool bLocal, bool bFailHard) = 0; virtual Transaction::pointer findTransactionByID (uint256 const& transactionID) = 0; virtual int findTransactionsByDestination (std::list&, - const RippleAddress& destinationAccount, uint32 startLedgerSeq, - uint32 endLedgerSeq, int maxTransactions) = 0; + const RippleAddress& destinationAccount, beast::uint32 startLedgerSeq, + beast::uint32 endLedgerSeq, int maxTransactions) = 0; //-------------------------------------------------------------------------- // @@ -168,7 +168,8 @@ public: // virtual STVector256 getDirNodeInfo (Ledger::ref lrLedger, - uint256 const& uRootIndex, uint64& uNodePrevious, uint64& uNodeNext) = 0; + uint256 const& uRootIndex, beast::uint64& uNodePrevious, + beast::uint64& uNodeNext) = 0; //-------------------------------------------------------------------------- // @@ -223,10 +224,10 @@ public: // Fetch packs virtual void makeFetchPack (Job&, boost::weak_ptr peer, boost::shared_ptr request, - Ledger::pointer wantLedger, Ledger::pointer haveLedger, uint32 uUptime) = 0; + Ledger::pointer wantLedger, Ledger::pointer haveLedger, beast::uint32 uUptime) = 0; - virtual bool shouldFetchPack (uint32 seq) = 0; - virtual void gotFetchPack (bool progress, uint32 seq) = 0; + virtual bool shouldFetchPack (beast::uint32 seq) = 0; + virtual void gotFetchPack (bool progress, beast::uint32 seq) = 0; virtual void addFetchPack (uint256 const& hash, boost::shared_ptr< Blob >& data) = 0; virtual bool getFetchPack (uint256 const& hash, Blob& data) = 0; virtual int getFetchSize () = 0; @@ -251,14 +252,14 @@ public: virtual void consensusViewChange () = 0; virtual int getPreviousProposers () = 0; virtual int getPreviousConvergeTime () = 0; - virtual uint32 getLastCloseTime () = 0; - virtual void setLastCloseTime (uint32 t) = 0; + virtual beast::uint32 getLastCloseTime () = 0; + virtual void setLastCloseTime (beast::uint32 t) = 0; virtual Json::Value getConsensusInfo () = 0; virtual Json::Value getServerInfo (bool human, bool admin) = 0; virtual void clearLedgerFetch () = 0; virtual Json::Value getLedgerFetchInfo () = 0; - virtual uint32 acceptLedger () = 0; + virtual beast::uint32 acceptLedger () = 0; typedef boost::unordered_map > Proposals; virtual Proposals& peekStoredProposals () = 0; @@ -272,32 +273,32 @@ public: //Helper function to generate SQL query to get transactions virtual std::string transactionsSQL (std::string selection, - const RippleAddress& account, int32 minLedger, int32 maxLedger, - bool descending, uint32 offset, int limit, bool binary, + const RippleAddress& account, beast::int32 minLedger, beast::int32 maxLedger, + bool descending, beast::uint32 offset, int limit, bool binary, bool count, bool bAdmin) = 0; // client information retrieval functions typedef std::vector< std::pair > AccountTxs; virtual AccountTxs getAccountTxs (const RippleAddress& account, - int32 minLedger, int32 maxLedger, bool descending, uint32 offset, + beast::int32 minLedger, beast::int32 maxLedger, bool descending, beast::uint32 offset, int limit, bool bAdmin) = 0; typedef std::vector< std::pair > TxsAccount; virtual TxsAccount getTxsAccount (const RippleAddress& account, - int32 minLedger, int32 maxLedger, bool forward, Json::Value& token, + beast::int32 minLedger, beast::int32 maxLedger, bool forward, Json::Value& token, int limit, bool bAdmin) = 0; - typedef boost::tuple txnMetaLedgerType; + typedef boost::tuple txnMetaLedgerType; typedef std::vector MetaTxsList; virtual MetaTxsList getAccountTxsB (const RippleAddress& account, - int32 minLedger, int32 maxLedger, bool descending, - uint32 offset, int limit, bool bAdmin) = 0; + beast::int32 minLedger, beast::int32 maxLedger, bool descending, + beast::uint32 offset, int limit, bool bAdmin) = 0; virtual MetaTxsList getTxsAccountB (const RippleAddress& account, - int32 minLedger, int32 maxLedger, bool forward, + beast::int32 minLedger, beast::int32 maxLedger, bool forward, Json::Value& token, int limit, bool bAdmin) = 0; - virtual std::vector getLedgerAffectedAccounts (uint32 ledgerSeq) = 0; + virtual std::vector getLedgerAffectedAccounts (beast::uint32 ledgerSeq) = 0; //-------------------------------------------------------------------------- // diff --git a/src/ripple_app/misc/OrderBook.h b/src/ripple_app/misc/OrderBook.h index b4608a8630..efabf03ae3 100644 --- a/src/ripple_app/misc/OrderBook.h +++ b/src/ripple_app/misc/OrderBook.h @@ -23,7 +23,7 @@ /** Describes a serialized ledger entry for an order book. */ -class OrderBook : LeakChecked +class OrderBook : beast::LeakChecked { public: typedef boost::shared_ptr pointer; diff --git a/src/ripple_app/misc/ProofOfWork.cpp b/src/ripple_app/misc/ProofOfWork.cpp index d4568aa990..1cbd473fe5 100644 --- a/src/ripple_app/misc/ProofOfWork.cpp +++ b/src/ripple_app/misc/ProofOfWork.cpp @@ -44,7 +44,7 @@ ProofOfWork::ProofOfWork (const std::string& token) mToken = token; mChallenge.SetHex (fields[0]); mTarget.SetHex (fields[1]); - mIterations = lexicalCast (fields[2]); + mIterations = beast::lexicalCast (fields[2]); } bool ProofOfWork::isValid () const @@ -56,7 +56,7 @@ bool ProofOfWork::isValid () const return false; } -uint64 ProofOfWork::getDifficulty (uint256 const& target, int iterations) +beast::uint64 ProofOfWork::getDifficulty (uint256 const& target, int iterations) { // calculate the approximate number of hashes required to solve this proof of work if ((iterations > kMaxIterations) || (target < sMinTarget)) @@ -69,7 +69,7 @@ uint64 ProofOfWork::getDifficulty (uint256 const& target, int iterations) } // more iterations means more hashes per iteration but also a larger final hash - uint64 difficulty = iterations + (iterations / 8); + beast::uint64 difficulty = iterations + (iterations / 8); // Multiply the number of hashes needed by 256 for each leading zero byte in the difficulty const unsigned char* ptr = target.begin (); diff --git a/src/ripple_app/misc/ProofOfWork.h b/src/ripple_app/misc/ProofOfWork.h index ce10ce377e..2b2b63b036 100644 --- a/src/ripple_app/misc/ProofOfWork.h +++ b/src/ripple_app/misc/ProofOfWork.h @@ -24,7 +24,7 @@ namespace ripple { -class ProofOfWork : LeakChecked +class ProofOfWork : beast::LeakChecked { public: enum @@ -55,13 +55,13 @@ public: return mChallenge; } - uint64 getDifficulty () const + beast::uint64 getDifficulty () const { return getDifficulty (mTarget, mIterations); } // approximate number of hashes needed to solve - static uint64 getDifficulty (uint256 const& target, int iterations); + static beast::uint64 getDifficulty (uint256 const& target, int iterations); static bool validateToken (const std::string& strToken); diff --git a/src/ripple_app/misc/ProofOfWorkFactory.cpp b/src/ripple_app/misc/ProofOfWorkFactory.cpp index 97d94881e5..5cea975463 100644 --- a/src/ripple_app/misc/ProofOfWorkFactory.cpp +++ b/src/ripple_app/misc/ProofOfWorkFactory.cpp @@ -19,7 +19,7 @@ class ProofOfWorkFactoryImp : public ProofOfWorkFactory - , public LeakChecked + , public beast::LeakChecked { public: typedef boost::bimap< boost::bimaps::multiset_of, @@ -145,7 +145,7 @@ public: // challenge - target - iterations - time - validator static boost::format f ("%s-%s-%d-%d"); - int now = static_cast (time (NULL) / 4); + int now = static_cast (time (nullptr) / 4); uint256 challenge; RandomNumbers::getInstance ().fillBytes (challenge.begin (), challenge.size ()); @@ -192,14 +192,14 @@ public: time_t t; #if 0 // Broken with lexicalCast<> changes - t = lexicalCast (fields[3]); + t = beast::lexicalCast (fields[3]); #else - t = static_cast (lexicalCast (fields [3])); + t = static_cast (beast::lexicalCast (fields [3])); #endif - time_t now = time (NULL); + time_t now = time (nullptr); - int iterations = lexicalCast (fields[2]); + int iterations = beast::lexicalCast (fields[2]); { ScopedLockType sl (mLock, __FILE__, __LINE__); @@ -243,7 +243,7 @@ public: void sweep () { - time_t expire = time (NULL) - mValidTime; + time_t expire = time (nullptr) - mValidTime; ScopedLockType sl (mLock, __FILE__, __LINE__); @@ -266,7 +266,7 @@ public: void loadHigh () { - time_t now = time (NULL); + time_t now = time (nullptr); ScopedLockType sl (mLock, __FILE__, __LINE__); @@ -284,7 +284,7 @@ public: void loadLow () { - time_t now = time (NULL); + time_t now = time (nullptr); ScopedLockType sl (mLock, __FILE__, __LINE__); @@ -303,7 +303,7 @@ public: void setDifficulty (int i) { assert ((i >= 0) && (i <= kMaxDifficulty)); - time_t now = time (NULL); + time_t now = time (nullptr); ScopedLockType sl (mLock, __FILE__, __LINE__); mPowEntry = i; @@ -315,7 +315,7 @@ public: //-------------------------------------------------------------------------- - uint64 getDifficulty () + beast::uint64 getDifficulty () { return ProofOfWork::getDifficulty (mTarget, mIterations); } @@ -354,10 +354,10 @@ ProofOfWorkFactory* ProofOfWorkFactory::New () //------------------------------------------------------------------------------ -class ProofOfWorkTests : public UnitTest +class ProofOfWorkTests : public beast::UnitTest { public: - ProofOfWorkTests () : UnitTest ("ProofOfWork", "ripple", runManual) + ProofOfWorkTests () : beast::UnitTest ("ProofOfWork", "ripple", runManual) { } @@ -368,9 +368,9 @@ public: ProofOfWorkFactoryImp gen; ProofOfWork pow = gen.getProof (); - String s; + beast::String s; - s << "solve difficulty " << String (pow.getDifficulty ()); + s << "solve difficulty " << beast::String (pow.getDifficulty ()); beginTestCase ("solve"); uint256 solution = pow.solve (16777216); diff --git a/src/ripple_app/misc/ProofOfWorkFactory.h b/src/ripple_app/misc/ProofOfWorkFactory.h index 7eb9810c69..9b739ef38a 100644 --- a/src/ripple_app/misc/ProofOfWorkFactory.h +++ b/src/ripple_app/misc/ProofOfWorkFactory.h @@ -41,7 +41,7 @@ public: virtual PowResult checkProof (const std::string& token, uint256 const& solution) = 0; - virtual uint64 getDifficulty () = 0; + virtual beast::uint64 getDifficulty () = 0; virtual void setDifficulty (int i) = 0; diff --git a/src/ripple_app/misc/SerializedLedger.cpp b/src/ripple_app/misc/SerializedLedger.cpp index d29205b287..45659e3094 100644 --- a/src/ripple_app/misc/SerializedLedger.cpp +++ b/src/ripple_app/misc/SerializedLedger.cpp @@ -25,7 +25,7 @@ SerializedLedgerEntry::SerializedLedgerEntry (SerializerIterator& sit, uint256 c : STObject (sfLedgerEntry), mIndex (index), mMutable (true) { set (sit); - uint16 type = getFieldU16 (sfLedgerEntryType); + beast::uint16 type = getFieldU16 (sfLedgerEntryType); LedgerFormats::Item const* const item = LedgerFormats::getInstance()->findByType (static_cast (type)); @@ -45,7 +45,7 @@ SerializedLedgerEntry::SerializedLedgerEntry (const Serializer& s, uint256 const SerializerIterator sit (const_cast (s)); // we know 's' isn't going away set (sit); - uint16 type = getFieldU16 (sfLedgerEntryType); + beast::uint16 type = getFieldU16 (sfLedgerEntryType); LedgerFormats::Item const* const item = LedgerFormats::getInstance()->findByType (static_cast (type)); @@ -73,7 +73,7 @@ SerializedLedgerEntry::SerializedLedgerEntry (LedgerEntryType type, uint256 cons { set (item->elements); - setFieldU16 (sfLedgerEntryType, static_cast (item->getType ())); + setFieldU16 (sfLedgerEntryType, static_cast (item->getType ())); } else { @@ -131,12 +131,13 @@ uint256 SerializedLedgerEntry::getThreadedTransaction () return getFieldH256 (sfPreviousTxnID); } -uint32 SerializedLedgerEntry::getThreadedLedger () +beast::uint32 SerializedLedgerEntry::getThreadedLedger () { return getFieldU32 (sfPreviousTxnLgrSeq); } -bool SerializedLedgerEntry::thread (uint256 const& txID, uint32 ledgerSeq, uint256& prevTxID, uint32& prevLedgerID) +bool SerializedLedgerEntry::thread (uint256 const& txID, beast::uint32 ledgerSeq, + uint256& prevTxID, beast::uint32& prevLedgerID) { uint256 oldPrevTxID = getFieldH256 (sfPreviousTxnID); WriteLog (lsTRACE, SerializedLedgerLog) << "Thread Tx:" << txID << " prev:" << oldPrevTxID; @@ -193,7 +194,7 @@ std::vector SerializedLedgerEntry::getOwners () { const STAccount* entry = dynamic_cast (peekAtPIndex (i)); - if ((entry != NULL) && entry->getValueH160 (account)) + if ((entry != nullptr) && entry->getValueH160 (account)) owners.push_back (Ledger::getAccountRootIndex (account)); } @@ -201,7 +202,7 @@ std::vector SerializedLedgerEntry::getOwners () { const STAmount* entry = dynamic_cast (peekAtPIndex (i)); - if ((entry != NULL)) + if ((entry != nullptr)) { uint160 issuer = entry->getIssuer (); diff --git a/src/ripple_app/misc/SerializedLedger.h b/src/ripple_app/misc/SerializedLedger.h index 4209387271..9da2729918 100644 --- a/src/ripple_app/misc/SerializedLedger.h +++ b/src/ripple_app/misc/SerializedLedger.h @@ -81,7 +81,7 @@ public: { return mType; } - uint16 getVersion () const + beast::uint16 getVersion () const { return getFieldU16 (sfLedgerEntryType); } @@ -98,8 +98,9 @@ public: RippleAddress getFirstOwner (); RippleAddress getSecondOwner (); uint256 getThreadedTransaction (); - uint32 getThreadedLedger (); - bool thread (uint256 const & txID, uint32 ledgerSeq, uint256 & prevTxID, uint32 & prevLedgerID); + beast::uint32 getThreadedLedger (); + bool thread (uint256 const & txID, beast::uint32 ledgerSeq, uint256 & prevTxID, + beast::uint32 & prevLedgerID); std::vector getOwners (); // nodes notified if this node is deleted private: diff --git a/src/ripple_app/misc/SerializedTransaction.cpp b/src/ripple_app/misc/SerializedTransaction.cpp index ab873fbfbf..922b47d745 100644 --- a/src/ripple_app/misc/SerializedTransaction.cpp +++ b/src/ripple_app/misc/SerializedTransaction.cpp @@ -110,7 +110,7 @@ std::vector SerializedTransaction::getMentionedAccounts () const { const STAccount* sa = dynamic_cast (&it); - if (sa != NULL) + if (sa != nullptr) { bool found = false; RippleAddress na = sa->getValueNCA (); @@ -272,21 +272,22 @@ std::string SerializedTransaction::getMetaSQLInsertReplaceHeader () return "INSERT OR REPLACE INTO Transactions " + getMetaSQLValueHeader () + " VALUES "; } -std::string SerializedTransaction::getSQL (uint32 inLedger, char status) const +std::string SerializedTransaction::getSQL (beast::uint32 inLedger, char status) const { Serializer s; add (s); return getSQL (s, inLedger, status); } -std::string SerializedTransaction::getMetaSQL (uint32 inLedger, const std::string& escapedMetaData) const +std::string SerializedTransaction::getMetaSQL (beast::uint32 inLedger, + const std::string& escapedMetaData) const { Serializer s; add (s); return getMetaSQL (s, inLedger, TXN_SQL_VALIDATED, escapedMetaData); } -std::string SerializedTransaction::getSQL (Serializer rawTxn, uint32 inLedger, char status) const +std::string SerializedTransaction::getSQL (Serializer rawTxn, beast::uint32 inLedger, char status) const { static boost::format bfTrans ("('%s', '%s', '%s', '%d', '%d', '%c', %s)"); std::string rTxn = sqlEscape (rawTxn.peekData ()); @@ -296,7 +297,7 @@ std::string SerializedTransaction::getSQL (Serializer rawTxn, uint32 inLedger, c % getSequence () % inLedger % status % rTxn); } -std::string SerializedTransaction::getMetaSQL (Serializer rawTxn, uint32 inLedger, char status, +std::string SerializedTransaction::getMetaSQL (Serializer rawTxn, beast::uint32 inLedger, char status, const std::string& escapedMetaData) const { static boost::format bfTrans ("('%s', '%s', '%s', '%d', '%d', '%c', %s, %s)"); @@ -324,10 +325,10 @@ bool isMemoOkay (STObject const& st) //------------------------------------------------------------------------------ -class SerializedTransactionTests : public UnitTest +class SerializedTransactionTests : public beast::UnitTest { public: - SerializedTransactionTests () : UnitTest ("SerializedTransaction", "ripple") + SerializedTransactionTests () : beast::UnitTest ("SerializedTransaction", "ripple") { } diff --git a/src/ripple_app/misc/SerializedTransaction.h b/src/ripple_app/misc/SerializedTransaction.h index b1cf24c4c6..373108a455 100644 --- a/src/ripple_app/misc/SerializedTransaction.h +++ b/src/ripple_app/misc/SerializedTransaction.h @@ -88,11 +88,11 @@ public: return mFormat->getName (); } - uint32 getSequence () const + beast::uint32 getSequence () const { return getFieldU32 (sfSequence); } - void setSequence (uint32 seq) + void setSequence (beast::uint32 seq) { return setFieldU32 (sfSequence, seq); } @@ -128,15 +128,15 @@ public: static std::string getSQLValueHeader (); static std::string getSQLInsertHeader (); static std::string getSQLInsertIgnoreHeader (); - std::string getSQL (std::string & sql, uint32 inLedger, char status) const; - std::string getSQL (uint32 inLedger, char status) const; - std::string getSQL (Serializer rawTxn, uint32 inLedger, char status) const; + std::string getSQL (std::string & sql, beast::uint32 inLedger, char status) const; + std::string getSQL (beast::uint32 inLedger, char status) const; + std::string getSQL (Serializer rawTxn, beast::uint32 inLedger, char status) const; // SQL Functions with metadata static std::string getMetaSQLValueHeader (); static std::string getMetaSQLInsertReplaceHeader (); - std::string getMetaSQL (uint32 inLedger, const std::string & escapedMetaData) const; - std::string getMetaSQL (Serializer rawTxn, uint32 inLedger, char status, const std::string & escapedMetaData) const; + std::string getMetaSQL (beast::uint32 inLedger, const std::string & escapedMetaData) const; + std::string getMetaSQL (Serializer rawTxn, beast::uint32 inLedger, char status, const std::string & escapedMetaData) const; private: TxType mType; diff --git a/src/ripple_app/misc/Validations.cpp b/src/ripple_app/misc/Validations.cpp index bdca1e6a4a..dee7403c65 100644 --- a/src/ripple_app/misc/Validations.cpp +++ b/src/ripple_app/misc/Validations.cpp @@ -76,8 +76,8 @@ private: if (val->isTrusted () || getApp().getUNL ().nodeInUNL (signer)) { val->setTrusted (); - uint32 now = getApp().getOPs ().getCloseTimeNC (); - uint32 valClose = val->getSignTime (); + beast::uint32 now = getApp().getOPs ().getCloseTimeNC (); + beast::uint32 valClose = val->getSignTime (); if ((now > (valClose - LEDGER_EARLY_INTERVAL)) && (now < (valClose + LEDGER_VAL_INTERVAL))) isCurrent = true; @@ -157,14 +157,14 @@ private: if (set) { - uint32 now = getApp().getOPs ().getNetworkTimeNC (); + beast::uint32 now = getApp().getOPs ().getNetworkTimeNC (); BOOST_FOREACH (u160_val_pair & it, *set) { bool isTrusted = it.second->isTrusted (); if (isTrusted && currentOnly) { - uint32 closeTime = it.second->getSignTime (); + beast::uint32 closeTime = it.second->getSignTime (); if ((now < (closeTime - LEDGER_EARLY_INTERVAL)) || (now > (closeTime + LEDGER_VAL_INTERVAL))) isTrusted = false; @@ -226,7 +226,7 @@ private: return trusted; } - int getFeeAverage (uint256 const& ledger, uint64 ref, uint64& fee) + int getFeeAverage (uint256 const& ledger, beast::uint64 ref, beast::uint64& fee) { int trusted = 0; fee = 0; @@ -292,7 +292,7 @@ private: std::list getCurrentTrustedValidations () { - uint32 cutoff = getApp().getOPs ().getNetworkTimeNC () - LEDGER_VAL_INTERVAL; + beast::uint32 cutoff = getApp().getOPs ().getNetworkTimeNC () - LEDGER_VAL_INTERVAL; std::list ret; @@ -327,7 +327,7 @@ private: boost::unordered_map getCurrentValidations (uint256 currentLedger, uint256 priorLedger) { - uint32 cutoff = getApp().getOPs ().getNetworkTimeNC () - LEDGER_VAL_INTERVAL; + beast::uint32 cutoff = getApp().getOPs ().getNetworkTimeNC () - LEDGER_VAL_INTERVAL; bool valCurrentLedger = currentLedger.isNonZero (); bool valPriorLedger = priorLedger.isNonZero (); diff --git a/src/ripple_app/misc/Validations.h b/src/ripple_app/misc/Validations.h index bea072d891..ea49e57fe1 100644 --- a/src/ripple_app/misc/Validations.h +++ b/src/ripple_app/misc/Validations.h @@ -24,7 +24,7 @@ typedef boost::unordered_map ValidationSet; typedef std::pair currentValidationCount; // nodes validating and highest node ID validating -class Validations : LeakChecked +class Validations : beast::LeakChecked { public: static Validations* New (); @@ -40,7 +40,7 @@ public: virtual int getTrustedValidationCount (uint256 const& ledger) = 0; - virtual int getFeeAverage(uint256 const& ledger, uint64 ref, uint64& fee) = 0; + virtual int getFeeAverage(uint256 const& ledger, beast::uint64 ref, beast::uint64& fee) = 0; virtual int getNodesAfter (uint256 const& ledger) = 0; virtual int getLoadRatio (bool overLoaded) = 0; diff --git a/src/ripple_app/node/SqliteFactory.cpp b/src/ripple_app/node/SqliteFactory.cpp index 23e453ebd0..6a3c702f79 100644 --- a/src/ripple_app/node/SqliteFactory.cpp +++ b/src/ripple_app/node/SqliteFactory.cpp @@ -52,11 +52,11 @@ public: : m_name (path) , m_db (new DatabaseCon(path, s_nodeStoreDBInit, s_nodeStoreDBCount)) { - String s; + beast::String s; // VFALCO TODO Remove this dependency on theConfig // - s << "PRAGMA cache_size=-" << String (getConfig ().getSize(siHashNodeDBCache) * 1024); + s << "PRAGMA cache_size=-" << beast::String (getConfig ().getSize(siHashNodeDBCache) * 1024); m_db->getDB()->executeSQL (s.toStdString ().c_str ()); } @@ -225,14 +225,14 @@ private: class SqliteFactory : public NodeStore::Factory { public: - String getName () const + beast::String getName () const { return "Sqlite"; } std::unique_ptr createInstance ( size_t, NodeStore::Parameters const& keyValues, - NodeStore::Scheduler&, Journal) + NodeStore::Scheduler&, beast::Journal) { return std::make_unique (keyValues ["path"].toStdString ()); } diff --git a/src/ripple_app/paths/PathRequest.cpp b/src/ripple_app/paths/PathRequest.cpp index ebaef768af..064d87d77d 100644 --- a/src/ripple_app/paths/PathRequest.cpp +++ b/src/ripple_app/paths/PathRequest.cpp @@ -21,7 +21,7 @@ SETUP_LOG (PathRequest) PathRequest::PathRequest ( const boost::shared_ptr& subscriber, int id, PathRequests& owner, - Journal journal) + beast::Journal journal) : m_journal (journal) , mLock (this, "PathRequest", __FILE__, __LINE__) , mOwner (owner) @@ -40,7 +40,7 @@ const boost::shared_ptr& subscriber, int id, PathRequests& owner, static std::string const get_milli_diff (boost::posix_time::ptime const& after, boost::posix_time::ptime const& before) { - return lexicalCastThrow (static_cast ((after - before).total_milliseconds())); + return beast::lexicalCastThrow (static_cast ((after - before).total_milliseconds())); } static std::string const get_milli_diff (boost::posix_time::ptime const& before) diff --git a/src/ripple_app/paths/PathRequest.h b/src/ripple_app/paths/PathRequest.h index 0ec5224736..929bbe2eb8 100644 --- a/src/ripple_app/paths/PathRequest.h +++ b/src/ripple_app/paths/PathRequest.h @@ -47,7 +47,7 @@ public: public: // VFALCO TODO Break the cyclic dependency on InfoSub PathRequest (boost::shared_ptr const& subscriber, - int id, PathRequests&, Journal journal); + int id, PathRequests&, beast::Journal journal); ~PathRequest (); @@ -69,7 +69,7 @@ private: void resetLevel (int level); int parseJson (const Json::Value&, bool complete); - Journal m_journal; + beast::Journal m_journal; typedef RippleRecursiveMutex LockType; typedef LockType::ScopedLockType ScopedLockType; diff --git a/src/ripple_app/paths/PathRequests.cpp b/src/ripple_app/paths/PathRequests.cpp index 38273e4754..7ef7b366bc 100644 --- a/src/ripple_app/paths/PathRequests.cpp +++ b/src/ripple_app/paths/PathRequests.cpp @@ -24,8 +24,8 @@ RippleLineCache::pointer PathRequests::getLineCache (Ledger::pointer& ledger, bo { ScopedLockType sl (mLock, __FILE__, __LINE__); - uint32 lineSeq = mLineCache ? mLineCache->getLedger()->getLedgerSeq() : 0; - uint32 lgrSeq = ledger->getLedgerSeq(); + beast::uint32 lineSeq = mLineCache ? mLineCache->getLedger()->getLedgerSeq() : 0; + beast::uint32 lgrSeq = ledger->getLedgerSeq(); if ( (lineSeq == 0) || // no ledger (authoritative && (lgrSeq > lineSeq)) || // newer authoritative ledger diff --git a/src/ripple_app/paths/PathRequests.h b/src/ripple_app/paths/PathRequests.h index 473ae54bb8..8497d1eaee 100644 --- a/src/ripple_app/paths/PathRequests.h +++ b/src/ripple_app/paths/PathRequests.h @@ -23,7 +23,7 @@ class PathRequests { public: - PathRequests (Journal journal, insight::Collector::ptr const& collector) + PathRequests (beast::Journal journal, beast::insight::Collector::ptr const& collector) : mJournal (journal) , mLastIdentifier (0) , mLock ("PathRequests", __FILE__, __LINE__) @@ -43,19 +43,19 @@ public: void reportFast (int milliseconds) { - mFast.notify (static_cast < insight::Event::value_type> (milliseconds)); + mFast.notify (static_cast < beast::insight::Event::value_type> (milliseconds)); } void reportFull (int milliseconds) { - mFull.notify (static_cast < insight::Event::value_type> (milliseconds)); + mFull.notify (static_cast < beast::insight::Event::value_type> (milliseconds)); } private: - Journal mJournal; + beast::Journal mJournal; - insight::Event mFast; - insight::Event mFull; + beast::insight::Event mFast; + beast::insight::Event mFull; // Track all requests std::vector mRequests; @@ -63,7 +63,7 @@ private: // Use a RippleLineCache RippleLineCache::pointer mLineCache; - Atomic mLastIdentifier; + beast::Atomic mLastIdentifier; typedef RippleRecursiveMutex LockType; typedef LockType::ScopedLockType ScopedLockType; diff --git a/src/ripple_app/paths/PathState.h b/src/ripple_app/paths/PathState.h index 1eae7afff3..5a93e65e19 100644 --- a/src/ripple_app/paths/PathState.h +++ b/src/ripple_app/paths/PathState.h @@ -42,7 +42,7 @@ public: Json::Value getJson () const; public: - uint16 uFlags; // --> From path. + beast::uint16 uFlags; // --> From path. uint160 uAccountID; // --> Accounts: Recieving/sending account. uint160 uCurrencyID; // --> Accounts: Receive and send, Offers: send. @@ -167,7 +167,7 @@ public: LedgerEntrySet lesEntries; int mIndex; // Index/rank amoung siblings. - uint64 uQuality; // 0 = no quality/liquity left. + beast::uint64 uQuality; // 0 = no quality/liquity left. const STAmount& saInReq; // --> Max amount to spend by sender. STAmount saInAct; // --> Amount spent by sender so far. STAmount saInPass; // <-- Amount spent by sender. diff --git a/src/ripple_app/paths/Pathfinder.cpp b/src/ripple_app/paths/Pathfinder.cpp index cbb68bc30b..f808e2e8bf 100644 --- a/src/ripple_app/paths/Pathfinder.cpp +++ b/src/ripple_app/paths/Pathfinder.cpp @@ -57,7 +57,7 @@ Test USD to EUR // correct currency at the end // quality, length, liquidity, index -typedef boost::tuple path_LQ_t; +typedef boost::tuple path_LQ_t; // Lower numbers have better quality. Sort higher quality first. static bool bQualityCmp (const path_LQ_t& a, const path_LQ_t& b) @@ -79,7 +79,7 @@ static bool bQualityCmp (const path_LQ_t& a, const path_LQ_t& b) } typedef std::pair candidate_t; -static bool candCmp (uint32 seq, const candidate_t& first, const candidate_t& second) +static bool candCmp (beast::uint32 seq, const candidate_t& first, const candidate_t& second) { if (first.first < second.first) return false; @@ -331,7 +331,7 @@ STPathSet Pathfinder::filterPaths(int iMaxPaths, STPath& extraPath) } else { - uint64 uQuality = STAmount::getRate (saDstAmountAct, saMaxAmountAct); + beast::uint64 uQuality = STAmount::getRate (saDstAmountAct, saMaxAmountAct); WriteLog (lsDEBUG, Pathfinder) << boost::str (boost::format ("findPaths: quality: %d: %s") diff --git a/src/ripple_app/paths/Pathfinder.h b/src/ripple_app/paths/Pathfinder.h index ae893411df..8a9404771f 100644 --- a/src/ripple_app/paths/Pathfinder.h +++ b/src/ripple_app/paths/Pathfinder.h @@ -129,11 +129,11 @@ private: boost::unordered_map mRLMap; boost::unordered_map, int> mPOMap; - static const uint32 afADD_ACCOUNTS = 0x001; // Add ripple paths - static const uint32 afADD_BOOKS = 0x002; // Add order books - static const uint32 afOB_XRP = 0x010; // Add order book to XRP only - static const uint32 afOB_LAST = 0x040; // Must link to destination currency - static const uint32 afAC_LAST = 0x080; // Destination account only + static const beast::uint32 afADD_ACCOUNTS = 0x001; // Add ripple paths + static const beast::uint32 afADD_BOOKS = 0x002; // Add order books + static const beast::uint32 afOB_XRP = 0x010; // Add order book to XRP only + static const beast::uint32 afOB_LAST = 0x040; // Must link to destination currency + static const beast::uint32 afAC_LAST = 0x080; // Destination account only }; boost::unordered_set usAccountDestCurrencies diff --git a/src/ripple_app/paths/RippleCalc.cpp b/src/ripple_app/paths/RippleCalc.cpp index d60943df1a..a6192cc3b8 100644 --- a/src/ripple_app/paths/RippleCalc.cpp +++ b/src/ripple_app/paths/RippleCalc.cpp @@ -1028,13 +1028,13 @@ TER RippleCalc::calcNodeOfferFwd ( // This routine is called one or two times for a node in a pass. If called once, it will work and set a rate. If called again, // the new work must not worsen the previous rate. void RippleCalc::calcNodeRipple ( - const uint32 uQualityIn, - const uint32 uQualityOut, + const beast::uint32 uQualityIn, + const beast::uint32 uQualityOut, const STAmount& saPrvReq, // --> in limit including fees, <0 = unlimited const STAmount& saCurReq, // --> out limit (driver) STAmount& saPrvAct, // <-> in limit including achieved so far: <-- <= --> STAmount& saCurAct, // <-> out limit including achieved : <-- <= --> - uint64& uRateMax) + beast::uint64& uRateMax) { WriteLog (lsTRACE, RippleCalc) << boost::str (boost::format ("calcNodeRipple> uQualityIn=%d uQualityOut=%d saPrvReq=%s saCurReq=%s saPrvAct=%s saCurAct=%s") % uQualityIn @@ -1084,7 +1084,7 @@ void RippleCalc::calcNodeRipple ( // Fee. WriteLog (lsTRACE, RippleCalc) << boost::str (boost::format ("calcNodeRipple: Fee")); - uint64 uRate = STAmount::getRate (STAmount (uQualityOut), STAmount (uQualityIn)); + beast::uint64 uRate = STAmount::getRate (STAmount (uQualityOut), STAmount (uQualityIn)); if (!uRateMax || uRate <= uRateMax) { @@ -1139,7 +1139,7 @@ TER RippleCalc::calcNodeAccountRev (const unsigned int uNode, PathState& psCur, TER terResult = tesSUCCESS; const unsigned int uLast = psCur.vpnNodes.size () - 1; - uint64 uRateMax = 0; + beast::uint64 uRateMax = 0; PathState::Node& pnPrv = psCur.vpnNodes[uNode ? uNode - 1 : 0]; PathState::Node& pnCur = psCur.vpnNodes[uNode]; @@ -1156,8 +1156,8 @@ TER RippleCalc::calcNodeAccountRev (const unsigned int uNode, PathState& psCur, const uint160& uCurrencyID = pnCur.uCurrencyID; // XXX Don't look up quality for XRP - const uint32 uQualityIn = uNode ? lesActive.rippleQualityIn (uCurAccountID, uPrvAccountID, uCurrencyID) : QUALITY_ONE; - const uint32 uQualityOut = uNode != uLast ? lesActive.rippleQualityOut (uCurAccountID, uNxtAccountID, uCurrencyID) : QUALITY_ONE; + const beast::uint32 uQualityIn = uNode ? lesActive.rippleQualityIn (uCurAccountID, uPrvAccountID, uCurrencyID) : QUALITY_ONE; + const beast::uint32 uQualityOut = uNode != uLast ? lesActive.rippleQualityOut (uCurAccountID, uNxtAccountID, uCurrencyID) : QUALITY_ONE; // For bPrvAccount const STAmount saPrvOwed = bPrvAccount && uNode // Previous account is owed. @@ -1502,7 +1502,7 @@ TER RippleCalc::calcNodeAccountFwd ( TER terResult = tesSUCCESS; const unsigned int uLast = psCur.vpnNodes.size () - 1; - uint64 uRateMax = 0; + beast::uint64 uRateMax = 0; PathState::Node& pnPrv = psCur.vpnNodes[uNode ? uNode - 1 : 0]; PathState::Node& pnCur = psCur.vpnNodes[uNode]; @@ -1519,8 +1519,8 @@ TER RippleCalc::calcNodeAccountFwd ( const uint160& uCurrencyID = pnCur.uCurrencyID; - uint32 uQualityIn = uNode ? lesActive.rippleQualityIn (uCurAccountID, uPrvAccountID, uCurrencyID) : QUALITY_ONE; - uint32 uQualityOut = uNode == uLast ? lesActive.rippleQualityOut (uCurAccountID, uNxtAccountID, uCurrencyID) : QUALITY_ONE; + beast::uint32 uQualityIn = uNode ? lesActive.rippleQualityIn (uCurAccountID, uPrvAccountID, uCurrencyID) : QUALITY_ONE; + beast::uint32 uQualityOut = uNode == uLast ? lesActive.rippleQualityOut (uCurAccountID, uNxtAccountID, uCurrencyID) : QUALITY_ONE; // When looking backward (prv) for req we care about what we just calculated: use fwd // When looking forward (cur) for req we care about what was desired: use rev @@ -2114,7 +2114,7 @@ TER RippleCalc::rippleCalc ( saDstAmountAct = STAmount (saDstAmountReq.getCurrency (), saDstAmountReq.getIssuer ()); const LedgerEntrySet lesBase = lesActive; // Checkpoint with just fees paid. - const uint64 uQualityLimit = bLimitQuality ? STAmount::getRate (saDstAmountReq, saMaxAmountReq) : 0; + const beast::uint64 uQualityLimit = bLimitQuality ? STAmount::getRate (saDstAmountReq, saMaxAmountReq) : 0; // When processing, don't want to complicate directory walking with deletion. std::vector vuUnfundedBecame; // Offers that became unfunded. @@ -2396,7 +2396,7 @@ void TransactionEngine::calcOfferBridgeNext ( uint256 const& uBookRoot, // --> Which order book to look in. uint256 const& uBookEnd, // --> Limit of how far to look. uint256& uBookDirIndex, // <-> Current directory. <-- 0 = no offer available. - uint64& uBookDirNode, // <-> Which node. 0 = first. + beast::uint64& uBookDirNode, // <-> Which node. 0 = first. unsigned int& uBookDirEntry, // <-> Entry in node. 0 = first. STAmount& saOfferIn, // <-- How much to pay in, fee inclusive, to get saOfferOut out. STAmount& saOfferOut // <-- How much offer pays out. diff --git a/src/ripple_app/paths/RippleCalc.h b/src/ripple_app/paths/RippleCalc.h index 71f032737a..1c9d90cbf6 100644 --- a/src/ripple_app/paths/RippleCalc.h +++ b/src/ripple_app/paths/RippleCalc.h @@ -62,10 +62,10 @@ public: STAmount& saInAct, STAmount& saInFees); - void calcNodeRipple (const uint32 uQualityIn, const uint32 uQualityOut, + void calcNodeRipple (const beast::uint32 uQualityIn, const beast::uint32 uQualityOut, const STAmount& saPrvReq, const STAmount& saCurReq, STAmount& saPrvAct, STAmount& saCurAct, - uint64& uRateMax); + beast::uint64& uRateMax); RippleCalc (LedgerEntrySet& lesNodes, const bool bOpenLedger) : lesActive (lesNodes), mOpenLedger (bOpenLedger) diff --git a/src/ripple_app/paths/RippleState.h b/src/ripple_app/paths/RippleState.h index 838b3945af..78f75cfcec 100644 --- a/src/ripple_app/paths/RippleState.h +++ b/src/ripple_app/paths/RippleState.h @@ -90,14 +90,14 @@ public: return !mViewLowest ? mLowLimit : mHighLimit; } - uint32 getQualityIn () const + beast::uint32 getQualityIn () const { - return ((uint32) (mViewLowest ? mLowQualityIn : mHighQualityIn)); + return ((beast::uint32) (mViewLowest ? mLowQualityIn : mHighQualityIn)); } - uint32 getQualityOut () const + beast::uint32 getQualityOut () const { - return ((uint32) (mViewLowest ? mLowQualityOut : mHighQualityOut)); + return ((beast::uint32) (mViewLowest ? mLowQualityOut : mHighQualityOut)); } SerializedLedgerEntry::pointer getSLE () @@ -126,7 +126,7 @@ private: bool mValid; bool mViewLowest; - uint32 mFlags; + beast::uint32 mFlags; STAmount mLowLimit; STAmount mHighLimit; @@ -134,10 +134,10 @@ private: uint160 mLowID; uint160 mHighID; - uint64 mLowQualityIn; - uint64 mLowQualityOut; - uint64 mHighQualityIn; - uint64 mHighQualityOut; + beast::uint64 mLowQualityIn; + beast::uint64 mLowQualityOut; + beast::uint64 mHighQualityIn; + beast::uint64 mHighQualityOut; STAmount mBalance; }; diff --git a/src/ripple_app/peers/ClusterNodeStatus.h b/src/ripple_app/peers/ClusterNodeStatus.h index 73313ca5db..1e22e6611f 100644 --- a/src/ripple_app/peers/ClusterNodeStatus.h +++ b/src/ripple_app/peers/ClusterNodeStatus.h @@ -30,7 +30,7 @@ public: explicit ClusterNodeStatus(std::string const& name) : mNodeName(name), mLoadFee(0), mReportTime(0) { ; } - ClusterNodeStatus(const std::string& name, uint32 fee, uint32 rtime) : + ClusterNodeStatus(const std::string& name, beast::uint32 fee, beast::uint32 rtime) : mNodeName(name), mLoadFee(fee), mReportTime(rtime) @@ -41,12 +41,12 @@ public: return mNodeName; } - uint32 getLoadFee() + beast::uint32 getLoadFee() { return mLoadFee; } - uint32 getReportTime() + beast::uint32 getReportTime() { return mReportTime; } @@ -64,8 +64,8 @@ public: private: std::string mNodeName; - uint32 mLoadFee; - uint32 mReportTime; + beast::uint32 mLoadFee; + beast::uint32 mReportTime; }; #endif diff --git a/src/ripple_app/peers/PeerSet.cpp b/src/ripple_app/peers/PeerSet.cpp index 52a54bf111..7b3ddaab28 100644 --- a/src/ripple_app/peers/PeerSet.cpp +++ b/src/ripple_app/peers/PeerSet.cpp @@ -27,7 +27,7 @@ class InboundLedger; // function pure virtual? // PeerSet::PeerSet (uint256 const& hash, int interval, bool txnData, - clock_type& clock, Journal journal) + clock_type& clock, beast::Journal journal) : m_journal (journal) , m_clock (clock) , mLock (this, "PeerSet", __FILE__, __LINE__) diff --git a/src/ripple_app/peers/PeerSet.h b/src/ripple_app/peers/PeerSet.h index f43706e1ee..715acf0b70 100644 --- a/src/ripple_app/peers/PeerSet.h +++ b/src/ripple_app/peers/PeerSet.h @@ -24,10 +24,10 @@ A peer set is used to acquire a ledger or a transaction set. */ -class PeerSet : LeakChecked +class PeerSet : beast::LeakChecked { public: - typedef abstract_clock clock_type; + typedef beast::abstract_clock clock_type; uint256 const& getHash () const { @@ -108,7 +108,7 @@ protected: typedef LockType::ScopedLockType ScopedLockType; PeerSet (uint256 const& hash, int interval, bool txnData, - clock_type& clock, Journal journal); + clock_type& clock, beast::Journal journal); virtual ~PeerSet () = 0; virtual void newPeer (Peer::ref) = 0; @@ -129,7 +129,7 @@ protected: void sendRequest (const protocol::TMGetLedger& message, Peer::ref peer); protected: - Journal m_journal; + beast::Journal m_journal; clock_type& m_clock; LockType mLock; diff --git a/src/ripple_app/peers/UniqueNodeList.cpp b/src/ripple_app/peers/UniqueNodeList.cpp index f7379f4f17..cedae04929 100644 --- a/src/ripple_app/peers/UniqueNodeList.cpp +++ b/src/ripple_app/peers/UniqueNodeList.cpp @@ -57,7 +57,7 @@ SETUP_LOG (UniqueNodeList) // VFALCO TODO move all function definitions inlined into the class. class UniqueNodeListImp : public UniqueNodeList - , public DeadlineTimer::Listener + , public beast::DeadlineTimer::Listener { private: // VFALCO TODO Rename these structs? Are they objects with static storage? @@ -152,7 +152,7 @@ public: fetchNext (); } - void onDeadlineTimer (DeadlineTimer& timer) + void onDeadlineTimer (beast::DeadlineTimer& timer) { if (timer == m_scoreTimer) { @@ -377,11 +377,11 @@ public: //-------------------------------------------------------------------------- - uint32 getClusterFee () + beast::uint32 getClusterFee () { int thresh = getApp().getOPs().getNetworkTimeNC() - 90; - std::vector fees; + std::vector fees; { ScopedUNLLockType sl (mUNLLock, __FILE__, __LINE__); { @@ -408,7 +408,7 @@ public: if (m_clusterNodes.size() > 1) // nodes other than us { int now = getApp().getOPs().getNetworkTimeNC(); - uint32 ref = getApp().getFeeTrack().getLoadBase(); + beast::uint32 ref = getApp().getFeeTrack().getLoadBase(); Json::Value& nodes = (obj["cluster"] = Json::objectValue); for (std::map::iterator it = m_clusterNodes.begin(), @@ -2019,12 +2019,12 @@ private: boost::posix_time::ptime mtpScoreNext; // When to start scoring. boost::posix_time::ptime mtpScoreStart; // Time currently started scoring. - DeadlineTimer m_scoreTimer; // Timer to start scoring. + beast::DeadlineTimer m_scoreTimer; // Timer to start scoring. int mFetchActive; // Count of active fetches. boost::posix_time::ptime mtpFetchNext; // Time of to start next fetch. - DeadlineTimer m_fetchTimer; // Timer to start fetching. + beast::DeadlineTimer m_fetchTimer; // Timer to start fetching. std::map m_clusterNodes; }; diff --git a/src/ripple_app/peers/UniqueNodeList.h b/src/ripple_app/peers/UniqueNodeList.h index 9f23ce982d..4097126472 100644 --- a/src/ripple_app/peers/UniqueNodeList.h +++ b/src/ripple_app/peers/UniqueNodeList.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_UNIQUENODELIST_H_INCLUDED #define RIPPLE_UNIQUENODELIST_H_INCLUDED -class UniqueNodeList : public Stoppable +class UniqueNodeList : public beast::Stoppable { protected: explicit UniqueNodeList (Stoppable& parent); @@ -63,7 +63,7 @@ public: virtual bool nodeInCluster (const RippleAddress& naNodePublic, std::string& name) = 0; virtual bool nodeUpdate (const RippleAddress& naNodePublic, ClusterNodeStatus const& cnsStatus) = 0; virtual std::map getClusterStatus () = 0; - virtual uint32 getClusterFee () = 0; + virtual beast::uint32 getClusterFee () = 0; virtual void addClusterStatus (Json::Value&) = 0; virtual void nodeBootstrap () = 0; diff --git a/src/ripple_app/rpc/RPCHandler.cpp b/src/ripple_app/rpc/RPCHandler.cpp index f2c156fd5a..a4534d6d75 100644 --- a/src/ripple_app/rpc/RPCHandler.cpp +++ b/src/ripple_app/rpc/RPCHandler.cpp @@ -139,10 +139,10 @@ static void autofill_fee (Json::Value& request, } // Administrative endpoints are exempt from local fees - uint64 fee = ledger->scaleFeeLoad ( + beast::uint64 fee = ledger->scaleFeeLoad ( getConfig().FEE_DEFAULT, admin); - uint64 const limit (mult * getConfig().FEE_DEFAULT); + beast::uint64 const limit (mult * getConfig().FEE_DEFAULT); if (fee > limit) { std::stringstream ss; @@ -855,7 +855,7 @@ Json::Value RPCHandler::doConnect (Json::Value params, else iPort = SYSTEM_PEER_PORT; - IP::Endpoint ip (IP::Endpoint::from_string(params["ip"].asString ())); + beast::IP::Endpoint ip (beast::IP::Endpoint::from_string(params["ip"].asString ())); if (! is_unspecified (ip)) getApp().getPeers ().connect (ip.at_port(iPort)); @@ -2327,7 +2327,7 @@ Json::Value RPCHandler::doLedgerData (Json::Value params, Resource::Charge& load Json::Value jvReply = Json::objectValue; jvReply["ledger_hash"] = lpLedger->getHash().GetHex (); - jvReply["ledger_index"] = lexicalCastThrow (lpLedger->getLedgerSeq ()); + jvReply["ledger_index"] = beast::lexicalCastThrow (lpLedger->getLedgerSeq ()); Json::Value& nodes = (jvReply["state"] = Json::arrayValue); SHAMap& map = *(lpLedger->peekAccountStateMap ()); @@ -2448,15 +2448,15 @@ Json::Value RPCHandler::doAccountTxOld (Json::Value params, Resource::Charge& lo masterLockHolder.unlock (); RippleAddress raAccount; - uint32 offset = params.isMember ("offset") ? params["offset"].asUInt () : 0; + beast::uint32 offset = params.isMember ("offset") ? params["offset"].asUInt () : 0; int limit = params.isMember ("limit") ? params["limit"].asUInt () : -1; bool bBinary = params.isMember ("binary") && params["binary"].asBool (); bool bDescending = params.isMember ("descending") && params["descending"].asBool (); bool bCount = params.isMember ("count") && params["count"].asBool (); - uint32 uLedgerMin; - uint32 uLedgerMax; - uint32 uValidatedMin; - uint32 uValidatedMax; + beast::uint32 uLedgerMin; + beast::uint32 uLedgerMax; + beast::uint32 uValidatedMin; + beast::uint32 uValidatedMax; bool bValidated = mNetOps->getValidatedRange (uValidatedMin, uValidatedMax); if (!params.isMember ("account")) @@ -2486,8 +2486,8 @@ Json::Value RPCHandler::doAccountTxOld (Json::Value params, Resource::Charge& lo if (params.isMember ("ledger_index_min") || params.isMember ("ledger_index_max")) { - int64 iLedgerMin = params.isMember ("ledger_index_min") ? params["ledger_index_min"].asInt () : -1; - int64 iLedgerMax = params.isMember ("ledger_index_max") ? params["ledger_index_max"].asInt () : -1; + beast::int64 iLedgerMin = params.isMember ("ledger_index_min") ? params["ledger_index_min"].asInt () : -1; + beast::int64 iLedgerMax = params.isMember ("ledger_index_max") ? params["ledger_index_max"].asInt () : -1; if (!bValidated && (iLedgerMin == -1 || iLedgerMax == -1)) { @@ -2538,7 +2538,7 @@ Json::Value RPCHandler::doAccountTxOld (Json::Value params, Resource::Charge& lo ++count; Json::Value& jvObj = jvTxns.append (Json::objectValue); - uint32 uLedgerIndex = it->get<2> (); + beast::uint32 uLedgerIndex = it->get<2> (); jvObj["tx_blob"] = it->get<0> (); jvObj["meta"] = it->get<1> (); jvObj["ledger_index"] = uLedgerIndex; @@ -2560,7 +2560,7 @@ Json::Value RPCHandler::doAccountTxOld (Json::Value params, Resource::Charge& lo if (it->second) { - uint32 uLedgerIndex = it->second->getLgrSeq (); + beast::uint32 uLedgerIndex = it->second->getLgrSeq (); jvObj["meta"] = it->second->getJson (0); jvObj["validated"] = bValidated && uValidatedMin <= uLedgerIndex && uValidatedMax >= uLedgerIndex; @@ -2612,10 +2612,10 @@ Json::Value RPCHandler::doAccountTx (Json::Value params, Resource::Charge& loadT int limit = params.isMember ("limit") ? params["limit"].asUInt () : -1; bool bBinary = params.isMember ("binary") && params["binary"].asBool (); bool bForward = params.isMember ("forward") && params["forward"].asBool (); - uint32 uLedgerMin; - uint32 uLedgerMax; - uint32 uValidatedMin; - uint32 uValidatedMax; + beast::uint32 uLedgerMin; + beast::uint32 uLedgerMax; + beast::uint32 uValidatedMin; + beast::uint32 uValidatedMax; bool bValidated = mNetOps->getValidatedRange (uValidatedMin, uValidatedMax); if (!bValidated) @@ -2634,8 +2634,8 @@ Json::Value RPCHandler::doAccountTx (Json::Value params, Resource::Charge& loadT if (params.isMember ("ledger_index_min") || params.isMember ("ledger_index_max")) { - int64 iLedgerMin = params.isMember ("ledger_index_min") ? params["ledger_index_min"].asInt () : -1; - int64 iLedgerMax = params.isMember ("ledger_index_max") ? params["ledger_index_max"].asInt () : -1; + beast::int64 iLedgerMin = params.isMember ("ledger_index_min") ? params["ledger_index_min"].asInt () : -1; + beast::int64 iLedgerMax = params.isMember ("ledger_index_max") ? params["ledger_index_max"].asInt () : -1; uLedgerMin = iLedgerMin == -1 ? uValidatedMin : iLedgerMin; @@ -2684,7 +2684,7 @@ Json::Value RPCHandler::doAccountTx (Json::Value params, Resource::Charge& loadT { Json::Value& jvObj = jvTxns.append (Json::objectValue); - uint32 uLedgerIndex = it->get<2> (); + beast::uint32 uLedgerIndex = it->get<2> (); jvObj["tx_blob"] = it->get<0> (); jvObj["meta"] = it->get<1> (); jvObj["ledger_index"] = uLedgerIndex; @@ -2706,7 +2706,7 @@ Json::Value RPCHandler::doAccountTx (Json::Value params, Resource::Charge& loadT if (it->second) { - uint32 uLedgerIndex = it->second->getLgrSeq (); + beast::uint32 uLedgerIndex = it->second->getLgrSeq (); jvObj["meta"] = it->second->getJson (0); jvObj["validated"] = bValidated && uValidatedMin <= uLedgerIndex && uValidatedMax >= uLedgerIndex; @@ -2989,7 +2989,7 @@ static void textTime (std::string& text, int& seconds, const char* unitName, int if (!text.empty ()) text += ", "; - text += lexicalCastThrow (i); + text += beast::lexicalCastThrow (i); text += " "; text += unitName; @@ -3374,7 +3374,7 @@ Json::Value RPCHandler::lookupLedger (Json::Value const& params, Ledger::pointer return jvResult; } - int32 iLedgerIndex = LEDGER_CURRENT; + beast::int32 iLedgerIndex = LEDGER_CURRENT; // We only try to parse a ledger index if we have not already // determined that we have a ledger hash. @@ -3525,7 +3525,7 @@ Json::Value RPCHandler::doLedgerEntry (Json::Value params, Resource::Charge& loa } else { - uint64 uSubIndex = params["directory"].isMember ("sub_index") + beast::uint64 uSubIndex = params["directory"].isMember ("sub_index") ? params["directory"]["sub_index"].asUInt () : 0; @@ -3604,7 +3604,7 @@ Json::Value RPCHandler::doLedgerEntry (Json::Value params, Resource::Charge& loa } else { - uint32 uSequence = params["offer"]["seq"].asUInt (); + beast::uint32 uSequence = params["offer"]["seq"].asUInt (); uNodeIndex = Ledger::getOfferIndex (naAccountID.getAccountID (), uSequence); } @@ -3735,7 +3735,7 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT InfoSub::pointer ispSub; Json::Value jvResult (Json::objectValue); - uint32 uLedgerIndex = params.isMember ("ledger_index") && params["ledger_index"].isNumeric () + beast::uint32 uLedgerIndex = params.isMember ("ledger_index") && params["ledger_index"].isNumeric () ? params["ledger_index"].asUInt () : 0; @@ -4437,7 +4437,7 @@ Json::Value RPCHandler::doCommand (const Json::Value& params, int iRole, Resourc } } -RPCInternalHandler* RPCInternalHandler::sHeadHandler = NULL; +RPCInternalHandler* RPCInternalHandler::sHeadHandler = nullptr; RPCInternalHandler::RPCInternalHandler (const std::string& name, handler_t Handler) : mName (name), mHandler (Handler) { @@ -4449,7 +4449,7 @@ Json::Value RPCInternalHandler::runHandler (const std::string& name, const Json: { RPCInternalHandler* h = sHeadHandler; - while (h != NULL) + while (h != nullptr) { if (name == h->mName) { @@ -4467,7 +4467,7 @@ Json::Value RPCInternalHandler::runHandler (const std::string& name, const Json: //------------------------------------------------------------------------------ -class JSONRPCTests : public UnitTest +class JSONRPCTests : public beast::UnitTest { public: void testAutoFillFees () @@ -4477,7 +4477,7 @@ public: RippleAddress rootSeedMaster = RippleAddress::createSeedGeneric ("masterpassphrase"); RippleAddress rootGeneratorMaster = RippleAddress::createGeneratorPublic (rootSeedMaster); RippleAddress rootAddress = RippleAddress::createAccountPublic (rootGeneratorMaster, 0); - uint64 startAmount (100000); + beast::uint64 startAmount (100000); Ledger::pointer ledger (boost::make_shared ( rootAddress, startAmount)); diff --git a/src/ripple_app/rpc/RPCServerHandler.cpp b/src/ripple_app/rpc/RPCServerHandler.cpp index 0991f16fed..75510b25e7 100644 --- a/src/ripple_app/rpc/RPCServerHandler.cpp +++ b/src/ripple_app/rpc/RPCServerHandler.cpp @@ -38,7 +38,8 @@ bool RPCServerHandler::isAuthorized ( return HTTPAuthorized (headers); } -std::string RPCServerHandler::processRequest (std::string const& request, IP::Endpoint const& remoteIPAddress) +std::string RPCServerHandler::processRequest (std::string const& request, + beast::IP::Endpoint const& remoteIPAddress) { Json::Value jsonRequest; { diff --git a/src/ripple_app/rpc/RPCServerHandler.h b/src/ripple_app/rpc/RPCServerHandler.h index 688226a86e..8d4f1f6721 100644 --- a/src/ripple_app/rpc/RPCServerHandler.h +++ b/src/ripple_app/rpc/RPCServerHandler.h @@ -35,7 +35,8 @@ public: bool isAuthorized (std::map const& headers); - std::string processRequest (std::string const& request, IP::Endpoint const& remoteIPAddress); + std::string processRequest (std::string const& request, + beast::IP::Endpoint const& remoteIPAddress); private: NetworkOPs& m_networkOPs; diff --git a/src/ripple_app/shamap/FetchPackTests.cpp b/src/ripple_app/shamap/FetchPackTests.cpp index b243c69006..7e4159e77e 100644 --- a/src/ripple_app/shamap/FetchPackTests.cpp +++ b/src/ripple_app/shamap/FetchPackTests.cpp @@ -19,7 +19,7 @@ namespace ripple { -class FetchPackTests : public UnitTest +class FetchPackTests : public beast::UnitTest { public: enum @@ -32,7 +32,7 @@ public: struct TestFilter : SHAMapSyncFilter { - TestFilter (Map& map, Journal journal) : mMap (map), mJournal (journal) + TestFilter (Map& map, beast::Journal journal) : mMap (map), mJournal (journal) { } @@ -56,7 +56,7 @@ public: } Map& mMap; - Journal mJournal; + beast::Journal mJournal; }; @@ -87,9 +87,9 @@ public: // turn t1 into t2 Map map; t2->getFetchPack (t1.get(), true, 1000000, boost::bind ( - &FetchPackTests::on_fetch, this, boost::ref (map), _1, _2)); + &FetchPackTests::on_fetch, this, boost::ref (map), beast::_1, beast::_2)); t1->getFetchPack (nullptr, true, 1000000, boost::bind ( - &FetchPackTests::on_fetch, this, boost::ref (map), _1, _2)); + &FetchPackTests::on_fetch, this, boost::ref (map), beast::_1, beast::_2)); // try to rebuild t2 from the fetch pack boost::shared_ptr t3; diff --git a/src/ripple_app/shamap/RadixMapTest.cpp b/src/ripple_app/shamap/RadixMapTest.cpp index 13ada695c5..c28b20a0b0 100644 --- a/src/ripple_app/shamap/RadixMapTest.cpp +++ b/src/ripple_app/shamap/RadixMapTest.cpp @@ -20,7 +20,7 @@ namespace ripple { namespace RadixMap { -boost::shared_ptr make_random_item (Random& r) +boost::shared_ptr make_random_item (beast::Random& r) { Serializer s; for (int d = 0; d < 3; ++d) @@ -31,7 +31,7 @@ boost::shared_ptr make_random_item (Random& r) //------------------------------------------------------------------------------ -void add_random_items (std::size_t n, Table& t, Random& r) +void add_random_items (std::size_t n, Table& t, beast::Random& r) { while (n--) { diff --git a/src/ripple_app/shamap/RadixMapTest.h b/src/ripple_app/shamap/RadixMapTest.h index 9f7d228697..a8c891c00c 100644 --- a/src/ripple_app/shamap/RadixMapTest.h +++ b/src/ripple_app/shamap/RadixMapTest.h @@ -26,14 +26,14 @@ typedef SHAMapItem Item; // Utility functions for RadixMap::Table (a.k.a. SHAMap) unit tests /** Returns a pseudo random Table item. */ -boost::shared_ptr make_random_item (Random& r); +boost::shared_ptr make_random_item (beast::Random& r); /** Adds a set of random items to the Table. @param n The number of items to add. @param t The table to add the items to. @param r A pseudo random number generator. */ -void add_random_items (std::size_t n, Table& t, Random& r); +void add_random_items (std::size_t n, Table& t, beast::Random& r); } } diff --git a/src/ripple_app/shamap/SHAMap.cpp b/src/ripple_app/shamap/SHAMap.cpp index 0dfa66cdd8..7b0541a7e3 100644 --- a/src/ripple_app/shamap/SHAMap.cpp +++ b/src/ripple_app/shamap/SHAMap.cpp @@ -19,14 +19,14 @@ SETUP_LOG (SHAMap) -void SHAMap::DefaultMissingNodeHandler::operator() (uint32 refNUm) +void SHAMap::DefaultMissingNodeHandler::operator() (beast::uint32 refNUm) { getApp().getOPs ().missingNodeInLedger (refNUm); }; //------------------------------------------------------------------------------ -SHAMap::SHAMap (SHAMapType t, FullBelowCache& fullBelowCache, uint32 seq, +SHAMap::SHAMap (SHAMapType t, FullBelowCache& fullBelowCache, beast::uint32 seq, MissingNodeHandler missing_node_handler) : m_fullBelowCache (fullBelowCache) , mSeq (seq) @@ -73,20 +73,20 @@ SHAMap::~SHAMap () mState = smsInvalid; logTimedDestroy (mTNByID, - String ("mTNByID with ") + - String::fromNumber (mTNByID.size ()) + " items"); + beast::String ("mTNByID with ") + + beast::String::fromNumber (mTNByID.size ()) + " items"); if (mDirtyNodes) { logTimedDestroy (mDirtyNodes, - String ("mDirtyNodes with ") + - String::fromNumber (mDirtyNodes->size ()) + " items"); + beast::String ("mDirtyNodes with ") + + beast::String::fromNumber (mDirtyNodes->size ()) + " items"); } if (root) { logTimedDestroy (root, - String ("root node")); + beast::String ("root node")); } } @@ -265,13 +265,13 @@ SHAMapTreeNode* SHAMap::walkToPointer (uint256 const& id) int branch = inNode->selectBranch (id); if (inNode->isEmptyBranch (branch)) - return NULL; + return nullptr; inNode = getNodePointer (inNode->getChildNodeID (branch), inNode->getChildHash (branch)); assert (inNode); } - return (inNode->getTag () == id) ? inNode : NULL; + return (inNode->getTag () == id) ? inNode : nullptr; } SHAMapTreeNode::pointer SHAMap::getNode (const SHAMapNode& id, uint256 const& hash, bool modify) @@ -289,7 +289,7 @@ SHAMapTreeNode::pointer SHAMap::getNode (const SHAMapNode& id, uint256 const& ha WriteLog (lsFATAL, SHAMap) << "ID: " << id; WriteLog (lsFATAL, SHAMap) << "TgtHash " << hash; WriteLog (lsFATAL, SHAMap) << "NodHash " << node->getNodeHash (); - Throw (std::runtime_error ("invalid node")); + beast::Throw (std::runtime_error ("invalid node")); } #endif @@ -408,7 +408,7 @@ SHAMapTreeNode* SHAMap::firstBelow (SHAMapTreeNode* node) } if (!foundNode) - return NULL; + return nullptr; } while (true); } @@ -432,7 +432,7 @@ SHAMapTreeNode* SHAMap::lastBelow (SHAMapTreeNode* node) } if (!foundNode) - return NULL; + return nullptr; } while (true); } @@ -442,7 +442,7 @@ SHAMapItem::pointer SHAMap::onlyBelow (SHAMapTreeNode* node) // If there is only one item below this node, return it while (!node->isLeaf ()) { - SHAMapTreeNode* nextNode = NULL; + SHAMapTreeNode* nextNode = nullptr; for (int i = 0; i < 16; ++i) if (!node->isEmptyBranch (i)) @@ -671,7 +671,7 @@ bool SHAMap::hasItem (uint256 const& id) ScopedReadLockType sl (mLock); SHAMapTreeNode* leaf = walkToPointer (id); - return (leaf != NULL); + return (leaf != nullptr); } bool SHAMap::delItem (uint256 const& id) @@ -1096,7 +1096,7 @@ int SHAMap::armDirty () return ++mSeq; } -int SHAMap::flushDirty (NodeMap& map, int maxNodes, NodeObjectType t, uint32 seq) +int SHAMap::flushDirty (NodeMap& map, int maxNodes, NodeObjectType t, beast::uint32 seq) { int flushed = 0; Serializer s; @@ -1113,7 +1113,7 @@ int SHAMap::flushDirty (NodeMap& map, int maxNodes, NodeObjectType t, uint32 seq if (s.getSHA512Half () != it->second->getNodeHash ()) { WriteLog (lsFATAL, SHAMap) << * (it->second); - WriteLog (lsFATAL, SHAMap) << lexicalCast (s.getDataLength ()); + WriteLog (lsFATAL, SHAMap) << beast::lexicalCast (s.getDataLength ()); WriteLog (lsFATAL, SHAMap) << s.getSHA512Half () << " != " << it->second->getNodeHash (); assert (false); } @@ -1181,13 +1181,13 @@ SHAMapTreeNode* SHAMap::getNodePointer (const SHAMapNode& nodeID) while (nodeID != *node) { if (node->isLeaf ()) - return NULL; + return nullptr; int branch = node->selectBranch (nodeID.getNodeID ()); assert (branch >= 0); if ((branch < 0) || node->isEmptyBranch (branch)) - return NULL; + return nullptr; node = getNodePointer (node->getChildNodeID (branch), node->getChildHash (branch)); assert (node); @@ -1292,7 +1292,7 @@ void SHAMap::canonicalize (uint256 const& hash, SHAMapTreeNode::pointer& node) //------------------------------------------------------------------------------ -class SHAMapTests : public UnitTest +class SHAMapTests : public beast::UnitTest { public: SHAMapTests () : UnitTest ("SHAMap", "ripple") diff --git a/src/ripple_app/shamap/SHAMap.h b/src/ripple_app/shamap/SHAMap.h index 13865b82a0..11126e6410 100644 --- a/src/ripple_app/shamap/SHAMap.h +++ b/src/ripple_app/shamap/SHAMap.h @@ -67,12 +67,12 @@ class SHAMap { private: /** Function object which handles missing nodes. */ - typedef std::function MissingNodeHandler; + typedef std::function MissingNodeHandler; /** Default handler which calls NetworkOPs. */ struct DefaultMissingNodeHandler { - void operator() (uint32 refNUm); + void operator() (beast::uint32 refNUm); }; public: @@ -98,7 +98,7 @@ public: public: // build new map explicit SHAMap (SHAMapType t, FullBelowCache& fullBelowCache, - uint32 seq = 1, MissingNodeHandler missing_node_handler = DefaultMissingNodeHandler()); + beast::uint32 seq = 1, MissingNodeHandler missing_node_handler = DefaultMissingNodeHandler()); SHAMap (SHAMapType t, uint256 const& hash, FullBelowCache& fullBelowCache, MissingNodeHandler missing_node_handler = DefaultMissingNodeHandler()); @@ -116,7 +116,7 @@ public: // Remove nodes from memory void dropCache (); - void setLedgerSeq (uint32 lseq) + void setLedgerSeq (beast::uint32 lseq) { mLedgerSeq = lseq; } @@ -207,15 +207,16 @@ public: bool compare (SHAMap::ref otherMap, Delta & differences, int maxCount); int armDirty (); - static int flushDirty (NodeMap & dirtyMap, int maxNodes, NodeObjectType t, uint32 seq); + static int flushDirty (NodeMap & dirtyMap, int maxNodes, NodeObjectType t, + beast::uint32 seq); boost::shared_ptr disarmDirty (); - void setSeq (uint32 seq) + void setSeq (beast::uint32 seq) { mSeq = seq; assert (seq != 0); } - uint32 getSeq () + beast::uint32 getSeq () { return mSeq; } @@ -321,8 +322,8 @@ private: mutable LockType mLock; FullBelowCache& m_fullBelowCache; - uint32 mSeq; - uint32 mLedgerSeq; // sequence number of ledger this is part of + beast::uint32 mSeq; + beast::uint32 mLedgerSeq; // sequence number of ledger this is part of SyncUnorderedMapType< SHAMapNode, SHAMapTreeNode::pointer > mTNByID; boost::shared_ptr mDirtyNodes; SHAMapTreeNode::pointer root; diff --git a/src/ripple_app/shamap/SHAMapAddNode.h b/src/ripple_app/shamap/SHAMapAddNode.h index eee0cb90ce..725fec4f85 100644 --- a/src/ripple_app/shamap/SHAMapAddNode.h +++ b/src/ripple_app/shamap/SHAMapAddNode.h @@ -105,21 +105,21 @@ public: if (mGood > 0) { ret.append("good:"); - ret.append(lexicalCastThrow(mGood)); + ret.append(beast::lexicalCastThrow(mGood)); } if (mBad > 0) { if (!ret.empty()) ret.append(" "); ret.append("bad:"); - ret.append(lexicalCastThrow(mBad)); + ret.append(beast::lexicalCastThrow(mBad)); } if (mDuplicate > 0) { if (!ret.empty()) ret.append(" "); ret.append("dupe:"); - ret.append(lexicalCastThrow(mDuplicate)); + ret.append(beast::lexicalCastThrow(mDuplicate)); } if (ret.empty ()) ret = "no nodes processed"; diff --git a/src/ripple_app/shamap/SHAMapNode.cpp b/src/ripple_app/shamap/SHAMapNode.cpp index dcb32f5879..8a81513e2f 100644 --- a/src/ripple_app/shamap/SHAMapNode.cpp +++ b/src/ripple_app/shamap/SHAMapNode.cpp @@ -44,7 +44,7 @@ std::string SHAMapNode::getString () const return "NodeID(root)"; return str (boost::format (NodeID) - % lexicalCastThrow (mDepth) + % beast::lexicalCastThrow (mDepth) % mNodeID.GetHex ()); } diff --git a/src/ripple_app/shamap/SHAMapSync.cpp b/src/ripple_app/shamap/SHAMapSync.cpp index 84880902a2..91defa4f88 100644 --- a/src/ripple_app/shamap/SHAMapSync.cpp +++ b/src/ripple_app/shamap/SHAMapSync.cpp @@ -212,7 +212,7 @@ void SHAMap::getMissingNodes (std::vector& nodeIDs, std::vector& nodeIDs, std::vector& node if ((!fatRoot && node->isRoot ()) || node->isLeaf ()) // don't get a fat root, can't get a fat leaf return true; - SHAMapTreeNode* nextNode = NULL; + SHAMapTreeNode* nextNode = nullptr; count = 0; for (int i = 0; i < 16; ++i) @@ -731,10 +731,10 @@ std::list SHAMap::getTrustedPath (uint256 const& index) //#define SMS_DEBUG #endif -class SHAMapSyncTests : public UnitTest +class SHAMapSyncTests : public beast::UnitTest { public: - SHAMapSyncTests () : UnitTest ("SHAMapSync", "ripple") + SHAMapSyncTests () : beast::UnitTest ("SHAMapSync", "ripple") { } @@ -829,7 +829,7 @@ public: unexpected (gotNodes.size () < 1, "NodeSize"); - unexpected (!destination.addRootNode (*gotNodes.begin (), snfWIRE, NULL).isGood(), "AddRootNode"); + unexpected (!destination.addRootNode (*gotNodes.begin (), snfWIRE, nullptr).isGood(), "AddRootNode"); nodeIDs.clear (); gotNodes.clear (); @@ -844,7 +844,7 @@ public: hashes.clear (); // get the list of nodes we know we need - destination.getMissingNodes (nodeIDs, hashes, 2048, NULL); + destination.getMissingNodes (nodeIDs, hashes, 2048, nullptr); if (nodeIDs.empty ()) break; @@ -883,7 +883,7 @@ public: bytes += rawNodeIterator->size (); #endif - if (!destination.addKnownNode (*nodeIDIterator, *rawNodeIterator, NULL).isGood ()) + if (!destination.addKnownNode (*nodeIDIterator, *rawNodeIterator, nullptr).isGood ()) { WriteLog (lsTRACE, SHAMap) << "AddKnownNode fails"; fail ("AddKnownNode"); diff --git a/src/ripple_app/shamap/SHAMapSyncFilters.cpp b/src/ripple_app/shamap/SHAMapSyncFilters.cpp index 7711d04010..e9796651bd 100644 --- a/src/ripple_app/shamap/SHAMapSyncFilters.cpp +++ b/src/ripple_app/shamap/SHAMapSyncFilters.cpp @@ -77,7 +77,7 @@ bool ConsensusTransSetSF::haveNode (const SHAMapNode& id, uint256 const& nodeHas //------------------------------------------------------------------------------ -AccountStateSF::AccountStateSF (uint32 ledgerSeq) +AccountStateSF::AccountStateSF (beast::uint32 ledgerSeq) : mLedgerSeq (ledgerSeq) { } @@ -100,7 +100,7 @@ bool AccountStateSF::haveNode (SHAMapNode const& id, //------------------------------------------------------------------------------ -TransactionStateSF::TransactionStateSF (uint32 ledgerSeq) +TransactionStateSF::TransactionStateSF (beast::uint32 ledgerSeq) : mLedgerSeq (ledgerSeq) { } diff --git a/src/ripple_app/shamap/SHAMapSyncFilters.h b/src/ripple_app/shamap/SHAMapSyncFilters.h index 5ccd8975fc..9fcc021590 100644 --- a/src/ripple_app/shamap/SHAMapSyncFilters.h +++ b/src/ripple_app/shamap/SHAMapSyncFilters.h @@ -53,7 +53,7 @@ private: class AccountStateSF : public SHAMapSyncFilter { public: - explicit AccountStateSF (uint32 ledgerSeq); + explicit AccountStateSF (beast::uint32 ledgerSeq); // Note that the nodeData is overwritten by this call void gotNode (bool fromFilter, @@ -67,7 +67,7 @@ public: Blob& nodeData); private: - uint32 mLedgerSeq; + beast::uint32 mLedgerSeq; }; // This class is only needed on add functions @@ -75,7 +75,7 @@ private: class TransactionStateSF : public SHAMapSyncFilter { public: - explicit TransactionStateSF (uint32 ledgerSeq); + explicit TransactionStateSF (beast::uint32 ledgerSeq); // Note that the nodeData is overwritten by this call void gotNode (bool fromFilter, @@ -89,7 +89,7 @@ public: Blob& nodeData); private: - uint32 mLedgerSeq; + beast::uint32 mLedgerSeq; }; #endif diff --git a/src/ripple_app/shamap/SHAMapTreeNode.cpp b/src/ripple_app/shamap/SHAMapTreeNode.cpp index 219edf9616..8b36c5c1fe 100644 --- a/src/ripple_app/shamap/SHAMapTreeNode.cpp +++ b/src/ripple_app/shamap/SHAMapTreeNode.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -SHAMapTreeNode::SHAMapTreeNode (uint32 seq, const SHAMapNode& nodeID) +SHAMapTreeNode::SHAMapTreeNode (beast::uint32 seq, const SHAMapNode& nodeID) : SHAMapNode (nodeID) - , mHash (uint64(0)) + , mHash (beast::uint64(0)) , mSeq (seq) , mAccessSeq (seq) , mType (tnERROR) @@ -28,7 +28,7 @@ SHAMapTreeNode::SHAMapTreeNode (uint32 seq, const SHAMapNode& nodeID) { } -SHAMapTreeNode::SHAMapTreeNode (const SHAMapTreeNode& node, uint32 seq) : SHAMapNode (node), +SHAMapTreeNode::SHAMapTreeNode (const SHAMapTreeNode& node, beast::uint32 seq) : SHAMapNode (node), mHash (node.mHash), mSeq (seq), mType (node.mType), mIsBranch (node.mIsBranch), mFullBelow (false) { if (node.mItem) @@ -37,14 +37,15 @@ SHAMapTreeNode::SHAMapTreeNode (const SHAMapTreeNode& node, uint32 seq) : SHAMap memcpy (mHashes, node.mHashes, sizeof (mHashes)); } -SHAMapTreeNode::SHAMapTreeNode (const SHAMapNode& node, SHAMapItem::ref item, TNType type, uint32 seq) : +SHAMapTreeNode::SHAMapTreeNode (const SHAMapNode& node, SHAMapItem::ref item, + TNType type, beast::uint32 seq) : SHAMapNode (node), mItem (item), mSeq (seq), mType (type), mIsBranch (0), mFullBelow (false) { assert (item->peekData ().size () >= 12); updateHash (); } -SHAMapTreeNode::SHAMapTreeNode (const SHAMapNode& id, Blob const& rawNode, uint32 seq, +SHAMapTreeNode::SHAMapTreeNode (const SHAMapNode& id, Blob const& rawNode, beast::uint32 seq, SHANodeFormat format, uint256 const& hash, bool hashValid) : SHAMapNode (id), mSeq (seq), mType (tnERROR), mIsBranch (0), mFullBelow (false) { @@ -145,7 +146,7 @@ SHAMapTreeNode::SHAMapTreeNode (const SHAMapNode& id, Blob const& rawNode, uint3 throw std::runtime_error ("invalid P node"); } - uint32 prefix = rawNode[0]; + beast::uint32 prefix = rawNode[0]; prefix <<= 8; prefix |= rawNode[1]; prefix <<= 8; @@ -416,7 +417,7 @@ void SHAMapTreeNode::dump () std::string SHAMapTreeNode::getString () const { std::string ret = "NodeID("; - ret += lexicalCastThrow (getDepth ()); + ret += beast::lexicalCastThrow (getDepth ()); ret += ","; ret += getNodeID ().GetHex (); ret += ")"; @@ -427,7 +428,7 @@ std::string SHAMapTreeNode::getString () const if (!isEmptyBranch (i)) { ret += "\nb"; - ret += lexicalCastThrow (i); + ret += beast::lexicalCastThrow (i); ret += " = "; ret += mHashes[i].GetHex (); } @@ -449,7 +450,7 @@ std::string SHAMapTreeNode::getString () const ret += "\n Hash="; ret += mHash.GetHex (); ret += "/"; - ret += lexicalCast (mItem->peekSerializer ().getDataLength ()); + ret += beast::lexicalCast (mItem->peekSerializer ().getDataLength ()); } return ret; diff --git a/src/ripple_app/shamap/SHAMapTreeNode.h b/src/ripple_app/shamap/SHAMapTreeNode.h index 54e97f6e6c..c9c598a108 100644 --- a/src/ripple_app/shamap/SHAMapTreeNode.h +++ b/src/ripple_app/shamap/SHAMapTreeNode.h @@ -51,12 +51,13 @@ public: }; public: - SHAMapTreeNode (uint32 seq, const SHAMapNode & nodeID); // empty node - SHAMapTreeNode (const SHAMapTreeNode & node, uint32 seq); // copy node from older tree - SHAMapTreeNode (const SHAMapNode & nodeID, SHAMapItem::ref item, TNType type, uint32 seq); + SHAMapTreeNode (beast::uint32 seq, const SHAMapNode & nodeID); // empty node + SHAMapTreeNode (const SHAMapTreeNode & node, beast::uint32 seq); // copy node from older tree + SHAMapTreeNode (const SHAMapNode & nodeID, SHAMapItem::ref item, TNType type, + beast::uint32 seq); // raw node functions - SHAMapTreeNode (const SHAMapNode & id, Blob const & data, uint32 seq, + SHAMapTreeNode (const SHAMapNode & id, Blob const & data, beast::uint32 seq, SHANodeFormat format, uint256 const & hash, bool hashValid); void addRaw (Serializer&, SHANodeFormat format); @@ -66,15 +67,15 @@ public: } // node functions - uint32 getSeq () const + beast::uint32 getSeq () const { return mSeq; } - void setSeq (uint32 s) + void setSeq (beast::uint32 s) { mAccessSeq = mSeq = s; } - void touch (uint32 s) + void touch (beast::uint32 s) { if (mSeq != 0) mAccessSeq = s; @@ -177,7 +178,7 @@ private: uint256 mHash; uint256 mHashes[16]; SHAMapItem::pointer mItem; - uint32 mSeq, mAccessSeq; + beast::uint32 mSeq, mAccessSeq; TNType mType; int mIsBranch; bool mFullBelow; diff --git a/src/ripple_app/transactors/AccountSetTransactor.cpp b/src/ripple_app/transactors/AccountSetTransactor.cpp index f3e797c138..fb48d6c22f 100644 --- a/src/ripple_app/transactors/AccountSetTransactor.cpp +++ b/src/ripple_app/transactors/AccountSetTransactor.cpp @@ -25,13 +25,13 @@ TER AccountSetTransactor::doApply () { WriteLog (lsINFO, AccountSetTransactor) << "AccountSet>"; - const uint32 uTxFlags = mTxn.getFlags (); + const beast::uint32 uTxFlags = mTxn.getFlags (); - const uint32 uFlagsIn = mTxnAccount->getFieldU32 (sfFlags); - uint32 uFlagsOut = uFlagsIn; + const beast::uint32 uFlagsIn = mTxnAccount->getFieldU32 (sfFlags); + beast::uint32 uFlagsOut = uFlagsIn; - const uint32 uSetFlag = mTxn.getFieldU32 (sfSetFlag); - const uint32 uClearFlag = mTxn.getFieldU32 (sfClearFlag); + const beast::uint32 uSetFlag = mTxn.getFieldU32 (sfSetFlag); + const beast::uint32 uClearFlag = mTxn.getFieldU32 (sfClearFlag); // legacy AccountSet flags bool bSetRequireDest = (uTxFlags & TxFlag::requireDestTag) || (uSetFlag == asfRequireDest); @@ -282,7 +282,7 @@ TER AccountSetTransactor::doApply () if (mTxn.isFieldPresent (sfTransferRate)) { - uint32 uRate = mTxn.getFieldU32 (sfTransferRate); + beast::uint32 uRate = mTxn.getFieldU32 (sfTransferRate); if (!uRate || uRate == QUALITY_ONE) { diff --git a/src/ripple_app/transactors/OfferCancelTransactor.cpp b/src/ripple_app/transactors/OfferCancelTransactor.cpp index b3e56961ce..43ba409966 100644 --- a/src/ripple_app/transactors/OfferCancelTransactor.cpp +++ b/src/ripple_app/transactors/OfferCancelTransactor.cpp @@ -24,12 +24,12 @@ SETUP_LOG (OfferCancelTransactor) TER OfferCancelTransactor::doApply () { TER terResult; - const uint32 uOfferSequence = mTxn.getFieldU32 (sfOfferSequence); - const uint32 uAccountSequenceNext = mTxnAccount->getFieldU32 (sfSequence); + const beast::uint32 uOfferSequence = mTxn.getFieldU32 (sfOfferSequence); + const beast::uint32 uAccountSequenceNext = mTxnAccount->getFieldU32 (sfSequence); WriteLog (lsDEBUG, OfferCancelTransactor) << "OfferCancel: uAccountSequenceNext=" << uAccountSequenceNext << " uOfferSequence=" << uOfferSequence; - const uint32 uTxFlags = mTxn.getFlags (); + const beast::uint32 uTxFlags = mTxn.getFlags (); if (uTxFlags & tfUniversalMask) { diff --git a/src/ripple_app/transactors/OfferCreateTransactor.cpp b/src/ripple_app/transactors/OfferCreateTransactor.cpp index 0aeebca4e7..3202274529 100644 --- a/src/ripple_app/transactors/OfferCreateTransactor.cpp +++ b/src/ripple_app/transactors/OfferCreateTransactor.cpp @@ -131,7 +131,7 @@ TER OfferCreateTransactor::takeOffers ( WriteLog (lsDEBUG, OfferCreateTransactor) << "takeOffers: bSell: " << bSell << ": against book: " << uBookBase.ToString (); LedgerEntrySet& lesActive = mEngine->getNodes (); - const uint64 uTakeQuality = STAmount::getRate (saTakerGets, saTakerPays); + const beast::uint64 uTakeQuality = STAmount::getRate (saTakerGets, saTakerPays); STAmount saTakerRate = STAmount::setRate (uTakeQuality); const uint160 uTakerPaysAccountID = saTakerPays.getIssuer (); const uint160 uTakerGetsAccountID = saTakerGets.getIssuer (); @@ -153,7 +153,7 @@ TER OfferCreateTransactor::takeOffers ( STAmount saTakerFunds = lesActive.accountFunds (uTakerAccountID, saTakerPays); STAmount saSubTakerPays = saTakerPays - saTakerPaid; // How much more to spend. STAmount saSubTakerGets = saTakerGets - saTakerGot; // How much more is wanted. - uint64 uTipQuality = bookIterator.getCurrentQuality(); + beast::uint64 uTipQuality = bookIterator.getCurrentQuality(); if (!saTakerFunds.isPositive ()) { @@ -374,7 +374,7 @@ TER OfferCreateTransactor::takeOffers ( TER OfferCreateTransactor::doApply () { WriteLog (lsTRACE, OfferCreateTransactor) << "OfferCreate> " << mTxn.getJson (0); - const uint32 uTxFlags = mTxn.getFlags (); + const beast::uint32 uTxFlags = mTxn.getFlags (); const bool bPassive = isSetBit (uTxFlags, tfPassive); const bool bImmediateOrCancel = isSetBit (uTxFlags, tfImmediateOrCancel); const bool bFillOrKill = isSetBit (uTxFlags, tfFillOrKill); @@ -391,12 +391,12 @@ TER OfferCreateTransactor::doApply () const uint160 uPaysIssuerID = saTakerPays.getIssuer (); const uint160 uGetsIssuerID = saTakerGets.getIssuer (); - const uint32 uExpiration = mTxn.getFieldU32 (sfExpiration); + const beast::uint32 uExpiration = mTxn.getFieldU32 (sfExpiration); const bool bHaveExpiration = mTxn.isFieldPresent (sfExpiration); const bool bHaveCancel = mTxn.isFieldPresent (sfOfferSequence); - const uint32 uCancelSequence = mTxn.getFieldU32 (sfOfferSequence); - const uint32 uAccountSequenceNext = mTxnAccount->getFieldU32 (sfSequence); - const uint32 uSequence = mTxn.getSequence (); + const beast::uint32 uCancelSequence = mTxn.getFieldU32 (sfOfferSequence); + const beast::uint32 uAccountSequenceNext = mTxnAccount->getFieldU32 (sfSequence); + const beast::uint32 uSequence = mTxn.getSequence (); const uint256 uLedgerIndex = Ledger::getOfferIndex (mTxnAccountID, uSequence); @@ -404,12 +404,12 @@ TER OfferCreateTransactor::doApply () const uint160 uPaysCurrency = saTakerPays.getCurrency (); const uint160 uGetsCurrency = saTakerGets.getCurrency (); - const uint64 uRate = STAmount::getRate (saTakerGets, saTakerPays); + const beast::uint64 uRate = STAmount::getRate (saTakerGets, saTakerPays); TER terResult = tesSUCCESS; uint256 uDirectory; // Delete hints. - uint64 uOwnerNode; - uint64 uBookNode; + beast::uint64 uOwnerNode; + beast::uint64 uBookNode; LedgerEntrySet& lesActive = mEngine->getNodes (); LedgerEntrySet lesCheckpoint = lesActive; // Checkpoint with just fees paid. diff --git a/src/ripple_app/transactors/PaymentTransactor.cpp b/src/ripple_app/transactors/PaymentTransactor.cpp index 926771ebad..9ca5e87423 100644 --- a/src/ripple_app/transactors/PaymentTransactor.cpp +++ b/src/ripple_app/transactors/PaymentTransactor.cpp @@ -26,7 +26,7 @@ SETUP_LOG (PaymentTransactor) TER PaymentTransactor::doApply () { // Ripple if source or destination is non-native or if there are paths. - const uint32 uTxFlags = mTxn.getFlags (); + const beast::uint32 uTxFlags = mTxn.getFlags (); const bool bPartialPayment = isSetBit (uTxFlags, tfPartialPayment); const bool bLimitQuality = isSetBit (uTxFlags, tfLimitQuality); const bool bNoRippleDirect = isSetBit (uTxFlags, tfNoRippleDirect); @@ -223,8 +223,8 @@ TER PaymentTransactor::doApply () { // Direct XRP payment. - const uint32 uOwnerCount = mTxnAccount->getFieldU32 (sfOwnerCount); - const uint64 uReserve = mEngine->getLedger ()->getReserve (uOwnerCount); + const beast::uint32 uOwnerCount = mTxnAccount->getFieldU32 (sfOwnerCount); + const beast::uint64 uReserve = mEngine->getLedger ()->getReserve (uOwnerCount); // Make sure have enough reserve to send. Allow final spend to use reserve for fee. if (mPriorBalance < saDstAmount + std::max(uReserve, mTxn.getTransactionFee ().getNValue ())) diff --git a/src/ripple_app/transactors/RegularKeySetTransactor.cpp b/src/ripple_app/transactors/RegularKeySetTransactor.cpp index ed7d8d2c82..07b7464a55 100644 --- a/src/ripple_app/transactors/RegularKeySetTransactor.cpp +++ b/src/ripple_app/transactors/RegularKeySetTransactor.cpp @@ -21,7 +21,7 @@ namespace ripple { SETUP_LOG (RegularKeySetTransactor) -uint64 RegularKeySetTransactor::calculateBaseFee () +beast::uint64 RegularKeySetTransactor::calculateBaseFee () { if ( mTxnAccount && (! (mTxnAccount->getFlags () & lsfPasswordSpent)) @@ -39,7 +39,7 @@ TER RegularKeySetTransactor::doApply () { Log::out() << "RegularKeySet>"; - const uint32 uTxFlags = mTxn.getFlags (); + const beast::uint32 uTxFlags = mTxn.getFlags (); if (uTxFlags & tfUniversalMask) { diff --git a/src/ripple_app/transactors/RegularKeySetTransactor.h b/src/ripple_app/transactors/RegularKeySetTransactor.h index c8ebd7b39e..dbff06f704 100644 --- a/src/ripple_app/transactors/RegularKeySetTransactor.h +++ b/src/ripple_app/transactors/RegularKeySetTransactor.h @@ -24,9 +24,12 @@ namespace ripple { class RegularKeySetTransactor : public Transactor { - uint64 calculateBaseFee (); + beast::uint64 calculateBaseFee (); public: - RegularKeySetTransactor (const SerializedTransaction& txn, TransactionEngineParams params, TransactionEngine* engine) : Transactor (txn, params, engine) {} + RegularKeySetTransactor (const SerializedTransaction& txn, + TransactionEngineParams params, + TransactionEngine* engine) + : Transactor (txn, params, engine) {} TER checkFee (); TER doApply (); }; diff --git a/src/ripple_app/transactors/Transactor.cpp b/src/ripple_app/transactors/Transactor.cpp index 6d89017426..4c18104fd6 100644 --- a/src/ripple_app/transactors/Transactor.cpp +++ b/src/ripple_app/transactors/Transactor.cpp @@ -79,7 +79,7 @@ Transactor::Transactor ( SerializedTransaction const& txn, TransactionEngineParams params, TransactionEngine* engine, - Journal journal) + beast::Journal journal) : mTxn (txn) , mEngine (engine) , mParams (params) @@ -95,7 +95,7 @@ void Transactor::calculateFee () calculateBaseFee (), isSetBit (mParams, tapADMIN))); } -uint64 Transactor::calculateBaseFee () +beast::uint64 Transactor::calculateBaseFee () { return getConfig ().FEE_DEFAULT; } @@ -171,8 +171,8 @@ TER Transactor::checkSig () TER Transactor::checkSeq () { - uint32 t_seq = mTxn.getSequence (); - uint32 a_seq = mTxnAccount->getFieldU32 (sfSequence); + beast::uint32 t_seq = mTxn.getSequence (); + beast::uint32 a_seq = mTxnAccount->getFieldU32 (sfSequence); m_journal.trace << "Aseq=" << a_seq << ", Tseq=" << t_seq; diff --git a/src/ripple_app/transactors/Transactor.h b/src/ripple_app/transactors/Transactor.h index e643aab559..61a3e8a998 100644 --- a/src/ripple_app/transactors/Transactor.h +++ b/src/ripple_app/transactors/Transactor.h @@ -46,7 +46,7 @@ protected: bool mSigMaster; RippleAddress mSigningPubKey; - Journal m_journal; + beast::Journal m_journal; virtual TER preCheck (); virtual TER checkSeq (); @@ -55,7 +55,7 @@ protected: void calculateFee (); // Returns the fee, not scaled for load (Should be in fee units. FIXME) - virtual uint64 calculateBaseFee (); + virtual beast::uint64 calculateBaseFee (); virtual TER checkSig (); virtual TER doApply () = 0; @@ -64,7 +64,7 @@ protected: const SerializedTransaction& txn, TransactionEngineParams params, TransactionEngine* engine, - Journal journal = Journal ()); + beast::Journal journal = beast::Journal ()); virtual bool mustHaveValidAccount () { diff --git a/src/ripple_app/transactors/TrustSetTransactor.cpp b/src/ripple_app/transactors/TrustSetTransactor.cpp index a95bde585a..34b2c6455d 100644 --- a/src/ripple_app/transactors/TrustSetTransactor.cpp +++ b/src/ripple_app/transactors/TrustSetTransactor.cpp @@ -33,8 +33,8 @@ TER TrustSetTransactor::doApply () uint160 uDstAccountID = saLimitAmount.getIssuer (); const bool bHigh = mTxnAccountID > uDstAccountID; // true, iff current is high account. - uint32 uQualityIn = bQualityIn ? mTxn.getFieldU32 (sfQualityIn) : 0; - uint32 uQualityOut = bQualityOut ? mTxn.getFieldU32 (sfQualityOut) : 0; + beast::uint32 uQualityIn = bQualityIn ? mTxn.getFieldU32 (sfQualityIn) : 0; + beast::uint32 uQualityOut = bQualityOut ? mTxn.getFieldU32 (sfQualityOut) : 0; if (!saLimitAmount.isLegalNet ()) return temBAD_AMOUNT; @@ -45,7 +45,7 @@ TER TrustSetTransactor::doApply () if (bQualityOut && QUALITY_ONE == uQualityOut) uQualityOut = 0; - const uint32 uTxFlags = mTxn.getFlags (); + const beast::uint32 uTxFlags = mTxn.getFlags (); if (uTxFlags & tfTrustSetMask) { @@ -115,9 +115,9 @@ TER TrustSetTransactor::doApply () return tecNO_DST; } - const uint32 uOwnerCount = mTxnAccount->getFieldU32 (sfOwnerCount); + const beast::uint32 uOwnerCount = mTxnAccount->getFieldU32 (sfOwnerCount); // The reserve required to create the line. - const uint64 uReserveCreate = (uOwnerCount < 2) ? 0 : mEngine->getLedger ()->getReserve (uOwnerCount + 1); + const beast::uint64 uReserveCreate = (uOwnerCount < 2) ? 0 : mEngine->getLedger ()->getReserve (uOwnerCount + 1); STAmount saLimitAllow = saLimitAmount; saLimitAllow.setIssuer (mTxnAccountID); @@ -130,10 +130,10 @@ TER TrustSetTransactor::doApply () STAmount saLowLimit; STAmount saHighBalance; STAmount saHighLimit; - uint32 uLowQualityIn; - uint32 uLowQualityOut; - uint32 uHighQualityIn; - uint32 uHighQualityOut; + beast::uint32 uLowQualityIn; + beast::uint32 uLowQualityOut; + beast::uint32 uHighQualityIn; + beast::uint32 uHighQualityOut; const uint160& uLowAccountID = !bHigh ? mTxnAccountID : uDstAccountID; const uint160& uHighAccountID = bHigh ? mTxnAccountID : uDstAccountID; SLE::ref sleLowAccount = !bHigh ? mTxnAccount : sleDst; @@ -219,8 +219,8 @@ TER TrustSetTransactor::doApply () uHighQualityOut = bHigh ? 0 : sleRippleState->getFieldU32 (sfHighQualityOut); } - const uint32 uFlagsIn = sleRippleState->getFieldU32 (sfFlags); - uint32 uFlagsOut = uFlagsIn; + const beast::uint32 uFlagsIn = sleRippleState->getFieldU32 (sfFlags); + beast::uint32 uFlagsOut = uFlagsIn; if (bSetNoRipple && !bClearNoRipple && (bHigh ? saHighBalance : saLowBalance).isGEZero()) { diff --git a/src/ripple_app/transactors/WalletAddTransactor.cpp b/src/ripple_app/transactors/WalletAddTransactor.cpp index 4977214a4a..baa14a89b2 100644 --- a/src/ripple_app/transactors/WalletAddTransactor.cpp +++ b/src/ripple_app/transactors/WalletAddTransactor.cpp @@ -31,7 +31,7 @@ TER WalletAddTransactor::doApply () const RippleAddress naMasterPubKey = RippleAddress::createAccountPublic (vucPubKey); const uint160 uDstAccountID = naMasterPubKey.getAccountID (); - const uint32 uTxFlags = mTxn.getFlags (); + const beast::uint32 uTxFlags = mTxn.getFlags (); if (uTxFlags & tfUniversalMask) { @@ -62,8 +62,8 @@ TER WalletAddTransactor::doApply () STAmount saDstAmount = mTxn.getFieldAmount (sfAmount); const STAmount saSrcBalance = mTxnAccount->getFieldAmount (sfBalance); - const uint32 uOwnerCount = mTxnAccount->getFieldU32 (sfOwnerCount); - const uint64 uReserve = mEngine->getLedger ()->getReserve (uOwnerCount); + const beast::uint32 uOwnerCount = mTxnAccount->getFieldU32 (sfOwnerCount); + const beast::uint64 uReserve = mEngine->getLedger ()->getReserve (uOwnerCount); STAmount saPaid = mTxn.getTransactionFee (); // Make sure have enough reserve to send. Allow final spend to use reserve for fee. diff --git a/src/ripple_app/tx/Transaction.cpp b/src/ripple_app/tx/Transaction.cpp index 27bf91749d..a576149a31 100644 --- a/src/ripple_app/tx/Transaction.cpp +++ b/src/ripple_app/tx/Transaction.cpp @@ -61,9 +61,9 @@ Transaction::Transaction ( TxType ttKind, const RippleAddress& naPublicKey, const RippleAddress& naSourceAccount, - uint32 uSeq, + beast::uint32 uSeq, const STAmount& saFee, - uint32 uSourceTag) : + beast::uint32 uSourceTag) : mAccountFrom (naSourceAccount), mFromPubKey (naPublicKey), mInLedger (0), mStatus (NEW), mResult (temUNCERTAIN) { assert (mFromPubKey.isValid ()); @@ -128,7 +128,7 @@ bool Transaction::checkSign () const return mTransaction->checkSign (mFromPubKey); } -void Transaction::setStatus (TransStatus ts, uint32 lseq) +void Transaction::setStatus (TransStatus ts, beast::uint32 lseq) { mStatus = ts; mInLedger = lseq; @@ -138,7 +138,7 @@ Transaction::pointer Transaction::transactionFromSQL (Database* db, bool bValida { Serializer rawTxn; std::string status; - uint32 inLedger; + beast::uint32 inLedger; int txSize = 2048; rawTxn.resize (txSize); @@ -200,7 +200,7 @@ Transaction::pointer Transaction::transactionFromSQL (const std::string& sql) { Serializer rawTxn; std::string status; - uint32 inLedger; + beast::uint32 inLedger; int txSize = 2048; rawTxn.resize (txSize); @@ -275,7 +275,7 @@ Transaction::pointer Transaction::load (uint256 const& id) return transactionFromSQL (sql); } -bool Transaction::convertToTransactions (uint32 firstLedgerSeq, uint32 secondLedgerSeq, +bool Transaction::convertToTransactions (beast::uint32 firstLedgerSeq, beast::uint32 secondLedgerSeq, bool checkFirstTransactions, bool checkSecondTransactions, const SHAMap::Delta& inMap, std::map >& outMap) { diff --git a/src/ripple_app/tx/Transaction.h b/src/ripple_app/tx/Transaction.h index d7b34e01c0..55fd182595 100644 --- a/src/ripple_app/tx/Transaction.h +++ b/src/ripple_app/tx/Transaction.h @@ -60,9 +60,9 @@ public: TxType ttKind, const RippleAddress & naPublicKey, // To prove transaction is consistent and authorized. const RippleAddress & naSourceAccount, // To identify the paying account. - uint32 uSeq, // To order transactions. + beast::uint32 uSeq, // To order transactions. const STAmount & saFee, // Transaction fee. - uint32 uSourceTag); // User call back value. + beast::uint32 uSourceTag); // User call back value. bool sign (const RippleAddress & naAccountPrivate); @@ -99,12 +99,12 @@ public: return mTransaction->getTransactionFee (); } - uint32 getFromAccountSeq () const + beast::uint32 getFromAccountSeq () const { return mTransaction->getSequence (); } - uint32 getSourceTag () const + beast::uint32 getSourceTag () const { return mTransaction->getFieldU32 (sfSourceTag); } @@ -135,7 +135,7 @@ public: mResult = terResult; } - void setStatus (TransStatus status, uint32 ledgerSeq); + void setStatus (TransStatus status, beast::uint32 ledgerSeq); void setStatus (TransStatus status) { @@ -159,9 +159,13 @@ public: static Transaction::pointer load (uint256 const & id); // conversion function - static bool convertToTransactions (uint32 ourLedgerSeq, uint32 otherLedgerSeq, - bool checkFirstTransactions, bool checkSecondTransactions, const SHAMap::Delta & inMap, - std::map >& outMap); + static bool convertToTransactions (beast::uint32 ourLedgerSeq, + beast::uint32 otherLedgerSeq, + bool checkFirstTransactions, + bool checkSecondTransactions, + const SHAMap::Delta & inMap, + std::map >& outMap); static bool isHexTxID (const std::string&); diff --git a/src/ripple_app/tx/TransactionAcquire.cpp b/src/ripple_app/tx/TransactionAcquire.cpp index d18e4f272f..1dabb6765f 100644 --- a/src/ripple_app/tx/TransactionAcquire.cpp +++ b/src/ripple_app/tx/TransactionAcquire.cpp @@ -223,7 +223,7 @@ SHAMapAddNode TransactionAcquire::takeNodes (const std::list& nodeID { if (mHaveRoot) WriteLog (lsDEBUG, TransactionAcquire) << "Got root TXS node, already have it"; - else if (!mMap->addRootNode (getHash (), *nodeDatait, snfWIRE, NULL).isGood()) + else if (!mMap->addRootNode (getHash (), *nodeDatait, snfWIRE, nullptr).isGood()) { WriteLog (lsWARNING, TransactionAcquire) << "TX acquire got bad root node"; } diff --git a/src/ripple_app/tx/TransactionEngine.cpp b/src/ripple_app/tx/TransactionEngine.cpp index bea3d314fa..dbd566d95e 100644 --- a/src/ripple_app/tx/TransactionEngine.cpp +++ b/src/ripple_app/tx/TransactionEngine.cpp @@ -109,7 +109,7 @@ TER TransactionEngine::applyTransaction (const SerializedTransaction& txn, Trans std::unique_ptr transactor = Transactor::makeTransactor (txn, params, this); - if (transactor.get () == NULL) + if (transactor.get () == nullptr) { WriteLog (lsWARNING, TransactionEngine) << "applyTransaction: Invalid transaction: unknown transaction type"; return temUNKNOWN; @@ -137,8 +137,8 @@ TER TransactionEngine::applyTransaction (const SerializedTransaction& txn, Trans terResult = terNO_ACCOUNT; else { - uint32 t_seq = txn.getSequence (); - uint32 a_seq = txnAcct->getFieldU32 (sfSequence); + beast::uint32 t_seq = txn.getSequence (); + beast::uint32 a_seq = txnAcct->getFieldU32 (sfSequence); if (a_seq < t_seq) terResult = terPRE_SEQ; diff --git a/src/ripple_app/tx/TransactionMaster.cpp b/src/ripple_app/tx/TransactionMaster.cpp index 13e16c734b..0b2d1f5222 100644 --- a/src/ripple_app/tx/TransactionMaster.cpp +++ b/src/ripple_app/tx/TransactionMaster.cpp @@ -23,7 +23,7 @@ TransactionMaster::TransactionMaster () { } -bool TransactionMaster::inLedger (uint256 const& hash, uint32 ledger) +bool TransactionMaster::inLedger (uint256 const& hash, beast::uint32 ledger) { Transaction::pointer txn = mCache.fetch (hash); @@ -51,8 +51,9 @@ Transaction::pointer TransactionMaster::fetch (uint256 const& txnID, bool checkD return txn; } -SerializedTransaction::pointer TransactionMaster::fetch (SHAMapItem::ref item, SHAMapTreeNode::TNType type, - bool checkDisk, uint32 uCommitLedger) +SerializedTransaction::pointer TransactionMaster::fetch (SHAMapItem::ref item, + SHAMapTreeNode::TNType type, + bool checkDisk, beast::uint32 uCommitLedger) { SerializedTransaction::pointer txn; Transaction::pointer iTx = getApp().getMasterTransaction ().fetch (item->getTag (), false); diff --git a/src/ripple_app/tx/TransactionMaster.h b/src/ripple_app/tx/TransactionMaster.h index 8cbb14e113..fa8429d82e 100644 --- a/src/ripple_app/tx/TransactionMaster.h +++ b/src/ripple_app/tx/TransactionMaster.h @@ -22,17 +22,17 @@ // Tracks all transactions in memory -class TransactionMaster : LeakChecked +class TransactionMaster : beast::LeakChecked { public: TransactionMaster (); Transaction::pointer fetch (uint256 const& , bool checkDisk); SerializedTransaction::pointer fetch (SHAMapItem::ref item, SHAMapTreeNode:: TNType type, - bool checkDisk, uint32 uCommitLedger); + bool checkDisk, beast::uint32 uCommitLedger); // return value: true = we had the transaction already - bool inLedger (uint256 const& hash, uint32 ledger); + bool inLedger (uint256 const& hash, beast::uint32 ledger); bool canonicalize (Transaction::pointer* pTransaction); void sweep (void); diff --git a/src/ripple_app/tx/TransactionMeta.cpp b/src/ripple_app/tx/TransactionMeta.cpp index 7de60a872d..c6b035dffe 100644 --- a/src/ripple_app/tx/TransactionMeta.cpp +++ b/src/ripple_app/tx/TransactionMeta.cpp @@ -21,7 +21,7 @@ SETUP_LOG (TransactionMetaSet) -TransactionMetaSet::TransactionMetaSet (uint256 const& txid, uint32 ledger, Blob const& vec) : +TransactionMetaSet::TransactionMetaSet (uint256 const& txid, beast::uint32 ledger, Blob const& vec) : mTransactionID (txid), mLedger (ledger), mNodes (sfAffectedNodes, 32) { Serializer s (vec); @@ -51,7 +51,8 @@ bool TransactionMetaSet::isNodeAffected (uint256 const& node) const return false; } -void TransactionMetaSet::setAffectedNode (uint256 const& node, SField::ref type, uint16 nodeType) +void TransactionMetaSet::setAffectedNode (uint256 const& node, SField::ref type, + beast::uint16 nodeType) { // make sure the node exists and force its type BOOST_FOREACH (STObject & it, mNodes) @@ -110,7 +111,7 @@ std::vector TransactionMetaSet::getAffectedAccounts () { const STAmount* lim = dynamic_cast (&field); - if (lim != NULL) + if (lim != nullptr) { uint160 issuer = lim->getIssuer (); @@ -175,7 +176,7 @@ const STObject& TransactionMetaSet::peekAffectedNode (uint256 const& node) const throw std::runtime_error ("Affected node not found"); } -void TransactionMetaSet::init (uint256 const& id, uint32 ledger) +void TransactionMetaSet::init (uint256 const& id, beast::uint32 ledger) { mTransactionID = id; mLedger = ledger; @@ -189,7 +190,7 @@ void TransactionMetaSet::swap (TransactionMetaSet& s) mNodes.swap (s.mNodes); } -bool TransactionMetaSet::thread (STObject& node, uint256 const& prevTxID, uint32 prevLgrID) +bool TransactionMetaSet::thread (STObject& node, uint256 const& prevTxID, beast::uint32 prevLgrID) { if (node.getFieldIndex (sfPreviousTxnID) == -1) { @@ -221,7 +222,7 @@ STObject TransactionMetaSet::getAsObject () const return metaData; } -void TransactionMetaSet::addRaw (Serializer& s, TER result, uint32 index) +void TransactionMetaSet::addRaw (Serializer& s, TER result, beast::uint32 index) { mResult = static_cast (result); mIndex = index; diff --git a/src/ripple_app/tx/TransactionMeta.h b/src/ripple_app/tx/TransactionMeta.h index 5ed8eb5639..224f27715e 100644 --- a/src/ripple_app/tx/TransactionMeta.h +++ b/src/ripple_app/tx/TransactionMeta.h @@ -20,25 +20,31 @@ #ifndef RIPPLE_TRANSACTIONMETA_H #define RIPPLE_TRANSACTIONMETA_H -class TransactionMetaSet : LeakChecked +class TransactionMetaSet : beast::LeakChecked { public: typedef boost::shared_ptr pointer; typedef const pointer& ref; public: - TransactionMetaSet () : mLedger (0), mIndex (static_cast (-1)), mResult (255) + TransactionMetaSet () + : mLedger (0) + , mIndex (static_cast (-1)) + , mResult (255) { - ; } - TransactionMetaSet (uint256 const& txID, uint32 ledger, uint32 index) : - mTransactionID (txID), mLedger (ledger), mIndex (static_cast (-1)), mResult (255) - { - ; - } - TransactionMetaSet (uint256 const& txID, uint32 ledger, Blob const&); - void init (uint256 const& transactionID, uint32 ledger); + TransactionMetaSet (uint256 const& txID, beast::uint32 ledger, beast::uint32 index) + : mTransactionID (txID) + , mLedger (ledger) + , mIndex (static_cast (-1)) + , mResult (255) + { + } + + TransactionMetaSet (uint256 const& txID, beast::uint32 ledger, Blob const&); + + void init (uint256 const& transactionID, beast::uint32 ledger); void clear () { mNodes.clear (); @@ -49,7 +55,7 @@ public: { return mTransactionID; } - uint32 getLgrSeq () + beast::uint32 getLgrSeq () { return mLedger; } @@ -61,13 +67,13 @@ public: { return static_cast (mResult); } - uint32 getIndex () const + beast::uint32 getIndex () const { return mIndex; } bool isNodeAffected (uint256 const& ) const; - void setAffectedNode (uint256 const& , SField::ref type, uint16 nodeType); + void setAffectedNode (uint256 const& , SField::ref type, beast::uint16 nodeType); STObject& getAffectedNode (SLE::ref node, SField::ref type); // create if needed STObject& getAffectedNode (uint256 const& ); const STObject& peekAffectedNode (uint256 const& ) const; @@ -78,7 +84,7 @@ public: { return getAsObject ().getJson (p); } - void addRaw (Serializer&, TER, uint32 index); + void addRaw (Serializer&, TER, beast::uint32 index); STObject getAsObject () const; STArray& getNodes () @@ -102,13 +108,13 @@ public: return mDelivered; } - static bool thread (STObject& node, uint256 const& prevTxID, uint32 prevLgrID); + static bool thread (STObject& node, uint256 const& prevTxID, beast::uint32 prevLgrID); private: - uint256 mTransactionID; - uint32 mLedger; - uint32 mIndex; - int mResult; + uint256 mTransactionID; + beast::uint32 mLedger; + beast::uint32 mIndex; + int mResult; boost::optional mDelivered; diff --git a/src/ripple_app/tx/TxQueue.cpp b/src/ripple_app/tx/TxQueue.cpp index 45aa08b521..9e6d529df7 100644 --- a/src/ripple_app/tx/TxQueue.cpp +++ b/src/ripple_app/tx/TxQueue.cpp @@ -19,7 +19,7 @@ class TxQueueImp : public TxQueue - , public LeakChecked + , public beast::LeakChecked { public: TxQueueImp () diff --git a/src/ripple_app/tx/TxQueue.h b/src/ripple_app/tx/TxQueue.h index 7056aced82..fcecbe2719 100644 --- a/src/ripple_app/tx/TxQueue.h +++ b/src/ripple_app/tx/TxQueue.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_TXQUEUE_H_INCLUDED #define RIPPLE_TXQUEUE_H_INCLUDED -class TxQueue : LeakChecked +class TxQueue : beast::LeakChecked { public: static TxQueue* New (); diff --git a/src/ripple_app/websocket/WSConnection.cpp b/src/ripple_app/websocket/WSConnection.cpp index 051f09583d..9675393514 100644 --- a/src/ripple_app/websocket/WSConnection.cpp +++ b/src/ripple_app/websocket/WSConnection.cpp @@ -23,7 +23,7 @@ SETUP_LOGN (WSConnection, "WSConnection") WSConnection::WSConnection (Resource::Manager& resourceManager, Resource::Consumer usage, InfoSub::Source& source, bool isPublic, - IP::Endpoint const& remoteAddress, boost::asio::io_service& io_service) + beast::IP::Endpoint const& remoteAddress, boost::asio::io_service& io_service) : InfoSub (source, usage) , m_resourceManager (resourceManager) , m_isPublic (isPublic) diff --git a/src/ripple_app/websocket/WSConnection.h b/src/ripple_app/websocket/WSConnection.h index 2bbda9b9bf..ce341982b4 100644 --- a/src/ripple_app/websocket/WSConnection.h +++ b/src/ripple_app/websocket/WSConnection.h @@ -29,7 +29,7 @@ class WSConnection : public boost::enable_shared_from_this , public InfoSub , public CountedObject - , public Uncopyable + , public beast::Uncopyable { public: static char const* getCountedObjectName () { return "WSConnection"; } @@ -39,7 +39,7 @@ protected: WSConnection (Resource::Manager& resourceManager, Resource::Consumer usage, InfoSub::Source& source, bool isPublic, - IP::Endpoint const& remoteAddress, boost::asio::io_service& io_service); + beast::IP::Endpoint const& remoteAddress, boost::asio::io_service& io_service); virtual ~WSConnection (); @@ -58,7 +58,7 @@ protected: Resource::Manager& m_resourceManager; Resource::Consumer m_usage; bool const m_isPublic; - IP::Endpoint const m_remoteAddress; + beast::IP::Endpoint const m_remoteAddress; LockType m_receiveQueueMutex; std::deque m_receiveQueue; NetworkOPs& m_netOPs; diff --git a/src/ripple_app/websocket/WSDoor.cpp b/src/ripple_app/websocket/WSDoor.cpp index 3ff490fb4d..6c3fbd04dd 100644 --- a/src/ripple_app/websocket/WSDoor.cpp +++ b/src/ripple_app/websocket/WSDoor.cpp @@ -35,7 +35,10 @@ SETUP_LOG (WSDoor) // VFALCO NOTE NetworkOPs isn't used here... // -class WSDoorImp : public WSDoor, protected Thread, LeakChecked +class WSDoorImp + : public WSDoor + , protected beast::Thread + , beast::LeakChecked { public: WSDoorImp (Resource::Manager& resourceManager, @@ -161,7 +164,7 @@ WSDoor* WSDoor::New (Resource::Manager& resourceManager, InfoSub::Source& source, std::string const& strIp, int iPort, bool bPublic, bool bProxy, boost::asio::ssl::context& ssl_context) { - ScopedPointer door; + beast::ScopedPointer door; try { diff --git a/src/ripple_app/websocket/WSDoor.h b/src/ripple_app/websocket/WSDoor.h index 172ab78f4b..115d9a66bd 100644 --- a/src/ripple_app/websocket/WSDoor.h +++ b/src/ripple_app/websocket/WSDoor.h @@ -21,7 +21,7 @@ #define RIPPLE_WSDOOR_H_INCLUDED /** Handles accepting incoming WebSocket connections. */ -class WSDoor : public Stoppable +class WSDoor : public beast::Stoppable { protected: explicit WSDoor (Stoppable& parent); diff --git a/src/ripple_app/websocket/WSServerHandler.h b/src/ripple_app/websocket/WSServerHandler.h index ffc5fe35bb..e7ffb61045 100644 --- a/src/ripple_app/websocket/WSServerHandler.h +++ b/src/ripple_app/websocket/WSServerHandler.h @@ -30,7 +30,7 @@ class WSConnectionType; struct WSServerHandlerLog; // This tag helps with mutex tracking -struct WSServerHandlerBase : public Uncopyable +struct WSServerHandlerBase : public beast::Uncopyable { }; @@ -41,7 +41,7 @@ template class WSServerHandler : public WSServerHandlerBase , public endpoint_type::handler - , public LeakChecked > + , public beast::LeakChecked > { public: typedef typename endpoint_type::handler::connection_ptr connection_ptr; diff --git a/src/ripple_basics/containers/RangeSet.cpp b/src/ripple_basics/containers/RangeSet.cpp index f99feb38d9..79e33add92 100644 --- a/src/ripple_basics/containers/RangeSet.cpp +++ b/src/ripple_basics/containers/RangeSet.cpp @@ -23,16 +23,16 @@ SETUP_LOG (RangeSet) // NOTE Why isn't this written as a template? // TODO Replace this with std calls. // -inline uint32 min (uint32 x, uint32 y) +inline beast::uint32 min (beast::uint32 x, beast::uint32 y) { return (x < y) ? x : y; } -inline uint32 max (uint32 x, uint32 y) +inline beast::uint32 max (beast::uint32 x, beast::uint32 y) { return (x > y) ? x : y; } -bool RangeSet::hasValue (uint32 v) const +bool RangeSet::hasValue (beast::uint32 v) const { BOOST_FOREACH (const value_type & it, mRanges) { @@ -42,7 +42,7 @@ bool RangeSet::hasValue (uint32 v) const return false; } -uint32 RangeSet::getFirst () const +beast::uint32 RangeSet::getFirst () const { const_iterator it = mRanges.begin (); @@ -52,7 +52,7 @@ uint32 RangeSet::getFirst () const return it->first; } -uint32 RangeSet::getNext (uint32 v) const +beast::uint32 RangeSet::getNext (beast::uint32 v) const { BOOST_FOREACH (const value_type & it, mRanges) { @@ -65,7 +65,7 @@ uint32 RangeSet::getNext (uint32 v) const return absent; } -uint32 RangeSet::getLast () const +beast::uint32 RangeSet::getLast () const { const_reverse_iterator it = mRanges.rbegin (); @@ -75,7 +75,7 @@ uint32 RangeSet::getLast () const return it->second; } -uint32 RangeSet::getPrev (uint32 v) const +beast::uint32 RangeSet::getPrev (beast::uint32 v) const { BOOST_REVERSE_FOREACH (const value_type & it, mRanges) { @@ -90,9 +90,9 @@ uint32 RangeSet::getPrev (uint32 v) const // Return the largest number not in the set that is less than the given number // -uint32 RangeSet::prevMissing (uint32 v) const +beast::uint32 RangeSet::prevMissing (beast::uint32 v) const { - uint32 result = absent; + beast::uint32 result = absent; if (v != 0) { @@ -118,7 +118,7 @@ uint32 RangeSet::prevMissing (uint32 v) const return result; } -void RangeSet::setValue (uint32 v) +void RangeSet::setValue (beast::uint32 v) { if (!hasValue (v)) { @@ -128,7 +128,7 @@ void RangeSet::setValue (uint32 v) } } -void RangeSet::setRange (uint32 minV, uint32 maxV) +void RangeSet::setRange (beast::uint32 minV, beast::uint32 maxV) { while (hasValue (minV)) { @@ -143,7 +143,7 @@ void RangeSet::setRange (uint32 minV, uint32 maxV) simplify (); } -void RangeSet::clearValue (uint32 v) +void RangeSet::clearValue (beast::uint32 v) { for (iterator it = mRanges.begin (); it != mRanges.end (); ++it) { @@ -157,7 +157,7 @@ void RangeSet::clearValue (uint32 v) } else { - uint32 oldEnd = it->second; + beast::uint32 oldEnd = it->second; mRanges.erase(it); mRanges[v + 1] = oldEnd; } @@ -168,7 +168,7 @@ void RangeSet::clearValue (uint32 v) } else { - uint32 oldEnd = it->second; + beast::uint32 oldEnd = it->second; it->second = v - 1; mRanges[v + 1] = oldEnd; } @@ -188,10 +188,10 @@ std::string RangeSet::toString () const ret += ","; if (it.first == it.second) - ret += lexicalCastThrow ((it.first)); + ret += beast::lexicalCastThrow ((it.first)); else - ret += lexicalCastThrow (it.first) + "-" - + lexicalCastThrow (it.second); + ret += beast::lexicalCastThrow (it.first) + "-" + + beast::lexicalCastThrow (it.second); } if (ret.empty ()) @@ -257,7 +257,7 @@ void RangeSet::checkInternalConsistency () const noexcept //------------------------------------------------------------------------------ -class RangeSetTests : public UnitTest +class RangeSetTests : public beast::UnitTest { public: RangeSetTests () : UnitTest ("RangeSet", "ripple") diff --git a/src/ripple_basics/containers/RangeSet.h b/src/ripple_basics/containers/RangeSet.h index 5e6f1fde8b..d6ebb5005c 100644 --- a/src/ripple_basics/containers/RangeSet.h +++ b/src/ripple_basics/containers/RangeSet.h @@ -26,28 +26,28 @@ class RangeSet { public: - static const uint32 absent = static_cast (-1); + static const beast::uint32 absent = static_cast (-1); public: RangeSet () { } - bool hasValue (uint32) const; + bool hasValue (beast::uint32) const; - uint32 getFirst () const; - uint32 getNext (uint32) const; - uint32 getLast () const; - uint32 getPrev (uint32) const; + beast::uint32 getFirst () const; + beast::uint32 getNext (beast::uint32) const; + beast::uint32 getLast () const; + beast::uint32 getPrev (beast::uint32) const; // largest number not in the set that is less than the given number - uint32 prevMissing (uint32) const; + beast::uint32 prevMissing (beast::uint32) const; // Add an item to the set - void setValue (uint32); + void setValue (beast::uint32); // Add the closed interval to the set - void setRange (uint32, uint32); + void setRange (beast::uint32, beast::uint32); - void clearValue (uint32); + void clearValue (beast::uint32); std::string toString () const; @@ -61,14 +61,14 @@ private: void simplify (); private: - typedef std::map Map; + typedef std::map Map; typedef Map::const_iterator const_iterator; typedef Map::const_reverse_iterator const_reverse_iterator; typedef Map::value_type value_type; typedef Map::iterator iterator; - static bool contains (value_type const& it, uint32 v) + static bool contains (value_type const& it, beast::uint32 v) { return (it.first <= v) && (it.second >= v); } diff --git a/src/ripple_basics/log/Log.h b/src/ripple_basics/log/Log.h index 0bf481bf4c..f1b6de299c 100644 --- a/src/ripple_basics/log/Log.h +++ b/src/ripple_basics/log/Log.h @@ -21,7 +21,7 @@ #define RIPPLE_BASICS_LOG_H_INCLUDED /** RAII helper for writing to the LogSink. */ -class Log : public Uncopyable +class Log : public beast::Uncopyable { public: explicit Log (LogSeverity s); diff --git a/src/ripple_basics/log/LogFile.cpp b/src/ripple_basics/log/LogFile.cpp index e33da16d16..2cef1364dd 100644 --- a/src/ripple_basics/log/LogFile.cpp +++ b/src/ripple_basics/log/LogFile.cpp @@ -38,7 +38,7 @@ bool LogFile::open (boost::filesystem::path const& path) bool wasOpened = false; // VFALCO TODO Make this work with Unicode file paths - ScopedPointer stream ( + beast::ScopedPointer stream ( new std::ofstream (path.c_str (), std::fstream::app)); if (stream->good ()) diff --git a/src/ripple_basics/log/LogFile.h b/src/ripple_basics/log/LogFile.h index fcef00f245..7acd2ae536 100644 --- a/src/ripple_basics/log/LogFile.h +++ b/src/ripple_basics/log/LogFile.h @@ -30,7 +30,7 @@ @note None of the listed interfaces are thread-safe. */ -class LogFile : public Uncopyable +class LogFile : public beast::Uncopyable { public: /** Construct with no associated system file. @@ -99,7 +99,7 @@ public: inline void writeln (std::string const& str) { writeln (str.c_str ()); } private: - ScopedPointer m_stream; + beast::ScopedPointer m_stream; boost::filesystem::path m_path; }; diff --git a/src/ripple_basics/log/LogPartition.cpp b/src/ripple_basics/log/LogPartition.cpp index e3fed2e306..b9e9a4cfe0 100644 --- a/src/ripple_basics/log/LogPartition.cpp +++ b/src/ripple_basics/log/LogPartition.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -void LogPartition::write (Journal::Severity level, std::string const& text) +void LogPartition::write (beast::Journal::Severity level, std::string const& text) { std::string output; LogSeverity const logSeverity (convertSeverity (level)); @@ -33,7 +33,7 @@ LogPartition::LogPartition (std::string const& name) : mNextLog (headLog) , mName (canonicalFileName (name.c_str())) { - severity (Journal::kWarning); + severity (beast::Journal::kWarning); // VFALCO TODO Use an intrusive list. headLog = this; } @@ -135,8 +135,9 @@ LogPartition::Severities LogPartition::getSeverities () //------------------------------------------------------------------------------ -LogSeverity LogPartition::convertSeverity (Journal::Severity level) +LogSeverity LogPartition::convertSeverity (beast::Journal::Severity level) { + using beast::Journal; switch (level) { case Journal::kTrace: return lsTRACE; @@ -154,8 +155,9 @@ LogSeverity LogPartition::convertSeverity (Journal::Severity level) return lsFATAL; } -Journal::Severity LogPartition::convertLogSeverity (LogSeverity level) +beast::Journal::Severity LogPartition::convertLogSeverity (LogSeverity level) { + using beast::Journal; switch (level) { case lsTRACE: return Journal::kTrace; diff --git a/src/ripple_basics/log/LogPartition.h b/src/ripple_basics/log/LogPartition.h index c471c12354..70a9d01ca0 100644 --- a/src/ripple_basics/log/LogPartition.h +++ b/src/ripple_basics/log/LogPartition.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_BASICS_LOGPARTITION_H_INCLUDED #define RIPPLE_BASICS_LOGPARTITION_H_INCLUDED -class LogPartition : public Journal::Sink +class LogPartition : public beast::Journal::Sink { public: //-------------------------------------------------------------------------- @@ -29,7 +29,7 @@ public: // //-------------------------------------------------------------------------- - void write (Journal::Severity level, std::string const& text); + void write (beast::Journal::Severity level, std::string const& text); //-------------------------------------------------------------------------- @@ -56,9 +56,9 @@ public: /** Returns a Journal using the specified LogPartition type key. */ template - static Journal getJournal () + static beast::Journal getJournal () { - return Journal (get ()); + return beast::Journal (get ()); } /** Returns a cleaned up source code file name. */ @@ -82,8 +82,8 @@ public: /** Convert the Journal::Severity to and from a LogSeverity. */ /** @{ */ - static LogSeverity convertSeverity (Journal::Severity level); - static Journal::Severity convertLogSeverity (LogSeverity level); + static LogSeverity convertSeverity (beast::Journal::Severity level); + static beast::Journal::Severity convertLogSeverity (LogSeverity level); /** @} */ /** Retrieve the name for a log partition. */ @@ -115,7 +115,7 @@ struct LogPartitionType : LogPartition template LogPartition& LogPartition::get () { - return *SharedSingleton < + return *beast::SharedSingleton < detail::LogPartitionType >::getInstance(); } diff --git a/src/ripple_basics/log/LogSink.cpp b/src/ripple_basics/log/LogSink.cpp index 76c3470693..0e9cc5ae7e 100644 --- a/src/ripple_basics/log/LogSink.cpp +++ b/src/ripple_basics/log/LogSink.cpp @@ -143,8 +143,8 @@ void LogSink::write (std::string const& line, bool toStdErr, ScopedLockType&) void LogSink::write_console (std::string const& text) { #if BEAST_MSVC - if (beast_isRunningUnderDebugger ()) - Logger::outputDebugString (text.c_str()); + if (beast::beast_isRunningUnderDebugger ()) + beast::Logger::outputDebugString (text.c_str()); #endif } @@ -181,6 +181,6 @@ std::string LogSink::replaceFirstSecretWithAsterisks (std::string s) LogSink::Ptr LogSink::get () { - return SharedSingleton ::getInstance (); + return beast::SharedSingleton ::getInstance (); } diff --git a/src/ripple_basics/log/LogSink.h b/src/ripple_basics/log/LogSink.h index e06c05ba0d..b08dfa5f90 100644 --- a/src/ripple_basics/log/LogSink.h +++ b/src/ripple_basics/log/LogSink.h @@ -72,7 +72,7 @@ public: static std::string replaceFirstSecretWithAsterisks (std::string s); /** Returns a pointer to the singleton. */ - typedef SharedPtr > Ptr; + typedef beast::SharedPtr > Ptr; static Ptr get (); private: diff --git a/src/ripple_basics/log/LoggedTimings.h b/src/ripple_basics/log/LoggedTimings.h index cade4f1a41..df33b7bed9 100644 --- a/src/ripple_basics/log/LoggedTimings.h +++ b/src/ripple_basics/log/LoggedTimings.h @@ -76,19 +76,19 @@ inline double cleanElapsed (double seconds) noexcept template double timedDestroy (Object& object) { - int64 const startTime (Time::getHighResolutionTicks ()); + beast::int64 const startTime (beast::Time::getHighResolutionTicks ()); detail::Destroyer ::destroy (object); - return Time::highResolutionTicksToSeconds ( - Time::getHighResolutionTicks () - startTime); + return beast::Time::highResolutionTicksToSeconds ( + beast::Time::getHighResolutionTicks () - startTime); } /** Log the timed destruction of an object if the time exceeds a threshold. */ template void logTimedDestroy ( - Object& object, String objectDescription, double thresholdSeconds = 1) + Object& object, beast::String objectDescription, double thresholdSeconds = 1) { double const seconds = timedDestroy (object); @@ -98,7 +98,7 @@ void logTimedDestroy ( Log (severity, LogPartition::get ()) << objectDescription << " took "<< - String (detail::cleanElapsed (seconds)) << + beast::String (detail::cleanElapsed (seconds)) << " seconds to destroy"; } } @@ -107,21 +107,21 @@ void logTimedDestroy ( /** Log a timed function call if the time exceeds a threshold. */ template -void logTimedCall (Journal::Stream stream, - String description, +void logTimedCall (beast::Journal::Stream stream, + beast::String description, char const* fileName, int lineNumber, Function f, double thresholdSeconds = 1) { - double const seconds = measureFunctionCallTime (f); + double const seconds = beast::measureFunctionCallTime (f); if (seconds > thresholdSeconds) { stream << description << " took "<< - String (detail::cleanElapsed (seconds)) << + beast::String (detail::cleanElapsed (seconds)) << " seconds to execute at " << - Debug::getSourceLocation (fileName, lineNumber); + beast::Debug::getSourceLocation (fileName, lineNumber); } } diff --git a/src/ripple_basics/ripple_basics.h b/src/ripple_basics/ripple_basics.h index ff699d55aa..87a58e5127 100644 --- a/src/ripple_basics/ripple_basics.h +++ b/src/ripple_basics/ripple_basics.h @@ -41,8 +41,6 @@ namespace ripple { -using namespace beast; - #include "types/BasicTypes.h" # include "log/LogSeverity.h" diff --git a/src/ripple_basics/types/BasicTypes.h b/src/ripple_basics/types/BasicTypes.h index 34ef19ef34..5e26744835 100644 --- a/src/ripple_basics/types/BasicTypes.h +++ b/src/ripple_basics/types/BasicTypes.h @@ -24,11 +24,11 @@ This lets us switch between tracked and untracked mutexes. */ #if RIPPLE_TRACK_MUTEXES -typedef TrackedMutexType RippleMutex; -typedef TrackedMutexType RippleRecursiveMutex; +typedef beast::TrackedMutexType RippleMutex; +typedef beast::TrackedMutexType RippleRecursiveMutex; #else -typedef UntrackedMutexType RippleMutex; -typedef UntrackedMutexType RippleRecursiveMutex; +typedef beast::UntrackedMutexType RippleMutex; +typedef beast::UntrackedMutexType RippleRecursiveMutex; #endif typedef boost::recursive_mutex DeprecatedRecursiveMutex; diff --git a/src/ripple_basics/utility/CountedObject.h b/src/ripple_basics/utility/CountedObject.h index e71e56b7ef..bbb6b96695 100644 --- a/src/ripple_basics/utility/CountedObject.h +++ b/src/ripple_basics/utility/CountedObject.h @@ -95,7 +95,7 @@ private: @ingroup ripple_basics */ template -class CountedObject : LeakChecked > +class CountedObject : beast::LeakChecked > { public: CountedObject () @@ -130,7 +130,7 @@ private: private: static Counter& getCounter () { - return StaticObject ::get(); + return beast::StaticObject ::get(); } }; diff --git a/src/ripple_basics/utility/IniFile.cpp b/src/ripple_basics/utility/IniFile.cpp index 9c43c3794b..63cfce7c0a 100644 --- a/src/ripple_basics/utility/IniFile.cpp +++ b/src/ripple_basics/utility/IniFile.cpp @@ -141,9 +141,10 @@ bool SectionSingleB (Section& secSource, const std::string& strSection, std::str return bSingle; } -StringPairArray parseKeyValueSection (Section& secSource, String const& strSection) +beast::StringPairArray +parseKeyValueSection (Section& secSource, beast::String const& strSection) { - StringPairArray result; + beast::StringPairArray result; // yuck. std::string const stdStrSection (strSection.toStdString ()); @@ -156,14 +157,14 @@ StringPairArray parseKeyValueSection (Section& secSource, String const& strSecti { for (Entries::const_iterator iter = entries->begin (); iter != entries->end (); ++iter) { - String const line (iter->c_str ()); + beast::String const line (iter->c_str ()); int const equalPos = line.indexOfChar ('='); if (equalPos != -1) { - String const key = line.substring (0, equalPos); - String const value = line.substring (equalPos + 1, line.length ()); + beast::String const key = line.substring (0, equalPos); + beast::String const value = line.substring (equalPos + 1, line.length ()); result.set (key, value); } diff --git a/src/ripple_basics/utility/IniFile.h b/src/ripple_basics/utility/IniFile.h index 978300c0af..4f02dc259b 100644 --- a/src/ripple_basics/utility/IniFile.h +++ b/src/ripple_basics/utility/IniFile.h @@ -38,6 +38,7 @@ Section::mapped_type* SectionEntries (Section& secSource, const std::string& str Each line is in the form =. Spaces are considered part of the key and value. */ -StringPairArray parseKeyValueSection (Section& secSource, String const& strSection); +beast::StringPairArray +parseKeyValueSection (Section& secSource, beast::String const& strSection); #endif diff --git a/src/ripple_basics/utility/StringUtilities.cpp b/src/ripple_basics/utility/StringUtilities.cpp index c984a0d741..9a8e15005c 100644 --- a/src/ripple_basics/utility/StringUtilities.cpp +++ b/src/ripple_basics/utility/StringUtilities.cpp @@ -46,7 +46,7 @@ std::string strprintf (const char* format, ...) limit *= 2; p = new char[limit]; - if (p == NULL) + if (p == nullptr) throw std::bad_alloc (); } @@ -217,7 +217,7 @@ bool parseIpPort (const std::string& strSource, std::string& strIP, int& iPort) if (bValid) { strIP = addrIP.to_string (); - iPort = strPortRaw.empty () ? -1 : lexicalCastThrow (strPortRaw); + iPort = strPortRaw.empty () ? -1 : beast::lexicalCastThrow (strPortRaw); } } @@ -243,7 +243,7 @@ bool parseUrl (const std::string& strUrl, std::string& strScheme, std::string& s boost::algorithm::to_lower (strScheme); - iPort = strPort.empty () ? -1 : lexicalCast (strPort); + iPort = strPort.empty () ? -1 : beast::lexicalCast (strPort); // Log::out() << strUrl << " : " << bMatch << " : '" << strDomain << "' : '" << strPort << "' : " << iPort << " : '" << strPath << "'"; } @@ -256,28 +256,29 @@ bool parseUrl (const std::string& strUrl, std::string& strScheme, std::string& s // Quality parsing // - integers as is. // - floats multiplied by a billion -bool parseQuality (const std::string& strSource, uint32& uQuality) +bool parseQuality (const std::string& strSource, beast::uint32& uQuality) { - uQuality = lexicalCast (strSource); + uQuality = beast::lexicalCast (strSource); if (!uQuality) { - float fQuality = lexicalCast (strSource); + float fQuality = beast::lexicalCast (strSource); if (fQuality) - uQuality = (uint32) (QUALITY_ONE * fQuality); + uQuality = (beast::uint32) (QUALITY_ONE * fQuality); } return !!uQuality; } -StringPairArray parseDelimitedKeyValueString (String parameters, beast_wchar delimiter) +beast::StringPairArray parseDelimitedKeyValueString (beast::String parameters, + beast::beast_wchar delimiter) { - StringPairArray keyValues; + beast::StringPairArray keyValues; while (parameters.isNotEmpty ()) { - String pair; + beast::String pair; { int const delimiterPos = parameters.indexOfChar (delimiter); @@ -292,7 +293,7 @@ StringPairArray parseDelimitedKeyValueString (String parameters, beast_wchar del { pair = parameters; - parameters = String::empty; + parameters = beast::String::empty; } } @@ -300,8 +301,8 @@ StringPairArray parseDelimitedKeyValueString (String parameters, beast_wchar del if (equalPos != -1) { - String const key = pair.substring (0, equalPos); - String const value = pair.substring (equalPos + 1, pair.length ()); + beast::String const key = pair.substring (0, equalPos); + beast::String const value = pair.substring (equalPos + 1, pair.length ()); keyValues.set (key, value); } @@ -312,7 +313,7 @@ StringPairArray parseDelimitedKeyValueString (String parameters, beast_wchar del //------------------------------------------------------------------------------ -class StringUtilitiesTests : public UnitTest +class StringUtilitiesTests : public beast::UnitTest { public: void testUnHexSuccess (std::string strIn, std::string strExpected) diff --git a/src/ripple_basics/utility/StringUtilities.h b/src/ripple_basics/utility/StringUtilities.h index 10e3f64370..635a255cd5 100644 --- a/src/ripple_basics/utility/StringUtilities.h +++ b/src/ripple_basics/utility/StringUtilities.h @@ -63,7 +63,7 @@ inline std::string strHex (Blob const& vucData) return strHex (vucData.begin (), vucData.size ()); } -inline std::string strHex (const uint64 uiHost) +inline std::string strHex (const beast::uint64 uiHost) { uint64_t uBig = htobe64 (uiHost); @@ -112,7 +112,7 @@ Blob strCopy (const std::string& strSrc); std::string strCopy (Blob const& vucSrc); bool parseIpPort (const std::string& strSource, std::string& strIP, int& iPort); -bool parseQuality (const std::string& strSource, uint32& uQuality); +bool parseQuality (const std::string& strSource, beast::uint32& uQuality); inline std::string strGetEnv (const std::string& strKey) { @@ -129,6 +129,7 @@ bool parseUrl (const std::string& strUrl, std::string& strScheme, std::string& s =['|'=] */ -extern StringPairArray parseDelimitedKeyValueString (String s, beast_wchar delimiter='|'); +extern beast::StringPairArray +parseDelimitedKeyValueString (beast::String s, beast::beast_wchar delimiter='|'); #endif diff --git a/src/ripple_basics/utility/UptimeTimer.cpp b/src/ripple_basics/utility/UptimeTimer.cpp index 638e7cb444..e3a8495920 100644 --- a/src/ripple_basics/utility/UptimeTimer.cpp +++ b/src/ripple_basics/utility/UptimeTimer.cpp @@ -34,7 +34,7 @@ int UptimeTimer::getElapsedSeconds () const if (m_isUpdatingManually) { - memoryBarrier(); + beast::memoryBarrier(); result = m_elapsedTime; } else diff --git a/src/ripple_core/functional/Config.cpp b/src/ripple_core/functional/Config.cpp index 89ad3fc69a..80d2150702 100644 --- a/src/ripple_core/functional/Config.cpp +++ b/src/ripple_core/functional/Config.cpp @@ -39,14 +39,14 @@ */ template void parseAddresses (OutputSequence& out, InputIterator first, InputIterator last, - Journal::Stream stream = Journal::Stream ()) + beast::Journal::Stream stream = beast::Journal::Stream ()) { while (first != last) { auto const str (*first); ++first; { - IP::Endpoint const addr (IP::Endpoint::from_string (str)); + beast::IP::Endpoint const addr (beast::IP::Endpoint::from_string (str)); if (! is_unspecified (addr)) { out.push_back (addr); @@ -54,7 +54,7 @@ void parseAddresses (OutputSequence& out, InputIterator first, InputIterator las } } { - IP::Endpoint const addr (IP::Endpoint::from_string_altform (str)); + beast::IP::Endpoint const addr (beast::IP::Endpoint::from_string_altform (str)); if (! is_unspecified (addr)) { out.push_back (addr); @@ -342,17 +342,17 @@ void Config::load () (void) SectionSingleB (secConfig, SECTION_PEER_IP, PEER_IP); if (SectionSingleB (secConfig, SECTION_PEER_PRIVATE, strTemp)) - PEER_PRIVATE = lexicalCastThrow (strTemp); + PEER_PRIVATE = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_PEERS_MAX, strTemp)) - PEERS_MAX = lexicalCastThrow (strTemp); + PEERS_MAX = beast::lexicalCastThrow (strTemp); smtTmp = SectionEntries (secConfig, SECTION_RPC_ADMIN_ALLOW); if (smtTmp) { - std::vector parsedAddresses; - //parseAddresses, std::vector::const_iterator> + std::vector parsedAddresses; + //parseAddresses, std::vector::const_iterator> // (parsedAddresses, (*smtTmp).cbegin(), (*smtTmp).cend()); parseAddresses (parsedAddresses, (*smtTmp).cbegin(), (*smtTmp).cend()); RPC_ADMIN_ALLOW.insert (RPC_ADMIN_ALLOW.end(), @@ -381,14 +381,14 @@ void Config::load () secConfig, ConfigSection::importNodeDatabase ()); if (SectionSingleB (secConfig, SECTION_PEER_PORT, strTemp)) - peerListeningPort = lexicalCastThrow (strTemp); + peerListeningPort = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_PEER_PROXY_PORT, strTemp)) { - peerPROXYListeningPort = lexicalCastThrow (strTemp); + peerPROXYListeningPort = beast::lexicalCastThrow (strTemp); if (peerPROXYListeningPort != 0 && peerPROXYListeningPort == peerListeningPort) - FatalError ("Peer and proxy listening ports can't be the same.", + beast::FatalError ("Peer and proxy listening ports can't be the same.", __FILE__, __LINE__); } else @@ -402,13 +402,13 @@ void Config::load () //--------------------------------------- if (SectionSingleB (secConfig, SECTION_RPC_PORT, strTemp)) - m_rpcPort = lexicalCastThrow (strTemp); + m_rpcPort = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, "ledger_creator" , strTemp)) - LEDGER_CREATOR = lexicalCastThrow (strTemp); + LEDGER_CREATOR = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_RPC_ALLOW_REMOTE, strTemp)) - RPC_ALLOW_REMOTE = lexicalCastThrow (strTemp); + RPC_ALLOW_REMOTE = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_NODE_SIZE, strTemp)) { @@ -424,7 +424,7 @@ void Config::load () NODE_SIZE = 4; else { - NODE_SIZE = lexicalCastThrow (strTemp); + NODE_SIZE = beast::lexicalCastThrow (strTemp); if (NODE_SIZE < 0) NODE_SIZE = 0; @@ -434,41 +434,41 @@ void Config::load () } if (SectionSingleB (secConfig, SECTION_ELB_SUPPORT, strTemp)) - ELB_SUPPORT = lexicalCastThrow (strTemp); + ELB_SUPPORT = beast::lexicalCastThrow (strTemp); (void) SectionSingleB (secConfig, SECTION_WEBSOCKET_IP, WEBSOCKET_IP); if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PORT, strTemp)) - WEBSOCKET_PORT = lexicalCastThrow (strTemp); + WEBSOCKET_PORT = beast::lexicalCastThrow (strTemp); (void) SectionSingleB (secConfig, SECTION_WEBSOCKET_PUBLIC_IP, WEBSOCKET_PUBLIC_IP); if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PUBLIC_PORT, strTemp)) - WEBSOCKET_PUBLIC_PORT = lexicalCastThrow (strTemp); + WEBSOCKET_PUBLIC_PORT = beast::lexicalCastThrow (strTemp); (void) SectionSingleB (secConfig, SECTION_WEBSOCKET_PROXY_IP, WEBSOCKET_PROXY_IP); if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PROXY_PORT, strTemp)) - WEBSOCKET_PROXY_PORT = lexicalCastThrow (strTemp); + WEBSOCKET_PROXY_PORT = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_WEBSOCKET_SECURE, strTemp)) - WEBSOCKET_SECURE = lexicalCastThrow (strTemp); + WEBSOCKET_SECURE = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PUBLIC_SECURE, strTemp)) - WEBSOCKET_PUBLIC_SECURE = lexicalCastThrow (strTemp); + WEBSOCKET_PUBLIC_SECURE = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PROXY_SECURE, strTemp)) - WEBSOCKET_PROXY_SECURE = lexicalCastThrow (strTemp); + WEBSOCKET_PROXY_SECURE = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PING_FREQ, strTemp)) - WEBSOCKET_PING_FREQ = lexicalCastThrow (strTemp); + WEBSOCKET_PING_FREQ = beast::lexicalCastThrow (strTemp); SectionSingleB (secConfig, SECTION_WEBSOCKET_SSL_CERT, WEBSOCKET_SSL_CERT); SectionSingleB (secConfig, SECTION_WEBSOCKET_SSL_CHAIN, WEBSOCKET_SSL_CHAIN); SectionSingleB (secConfig, SECTION_WEBSOCKET_SSL_KEY, WEBSOCKET_SSL_KEY); if (SectionSingleB (secConfig, SECTION_RPC_SECURE, strTemp)) - RPC_SECURE = lexicalCastThrow (strTemp); + RPC_SECURE = beast::lexicalCastThrow (strTemp); SectionSingleB (secConfig, SECTION_RPC_SSL_CERT, RPC_SSL_CERT); SectionSingleB (secConfig, SECTION_RPC_SSL_CHAIN, RPC_SSL_CHAIN); @@ -479,7 +479,7 @@ void Config::load () SectionSingleB (secConfig, SECTION_SSL_VERIFY_DIR, SSL_VERIFY_DIR); if (SectionSingleB (secConfig, SECTION_SSL_VERIFY, strTemp)) - SSL_VERIFY = lexicalCastThrow (strTemp); + SSL_VERIFY = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_VALIDATION_SEED, strTemp)) { @@ -507,37 +507,37 @@ void Config::load () if (SectionSingleB (secConfig, SECTION_PEER_SCAN_INTERVAL_MIN, strTemp)) // Minimum for min is 60 seconds. - PEER_SCAN_INTERVAL_MIN = std::max (60, lexicalCastThrow (strTemp)); + PEER_SCAN_INTERVAL_MIN = std::max (60, beast::lexicalCastThrow (strTemp)); if (SectionSingleB (secConfig, SECTION_PEER_START_MAX, strTemp)) - PEER_START_MAX = std::max (1, lexicalCastThrow (strTemp)); + PEER_START_MAX = std::max (1, beast::lexicalCastThrow (strTemp)); if (SectionSingleB (secConfig, SECTION_PEER_CONNECT_LOW_WATER, strTemp)) - PEER_CONNECT_LOW_WATER = std::max (1, lexicalCastThrow (strTemp)); + PEER_CONNECT_LOW_WATER = std::max (1, beast::lexicalCastThrow (strTemp)); if (SectionSingleB (secConfig, SECTION_NETWORK_QUORUM, strTemp)) - NETWORK_QUORUM = std::max (0, lexicalCastThrow (strTemp)); + NETWORK_QUORUM = std::max (0, beast::lexicalCastThrow (strTemp)); if (SectionSingleB (secConfig, SECTION_VALIDATION_QUORUM, strTemp)) - VALIDATION_QUORUM = std::max (0, lexicalCastThrow (strTemp)); + VALIDATION_QUORUM = std::max (0, beast::lexicalCastThrow (strTemp)); if (SectionSingleB (secConfig, SECTION_FEE_ACCOUNT_RESERVE, strTemp)) - FEE_ACCOUNT_RESERVE = lexicalCastThrow (strTemp); + FEE_ACCOUNT_RESERVE = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_FEE_OWNER_RESERVE, strTemp)) - FEE_OWNER_RESERVE = lexicalCastThrow (strTemp); + FEE_OWNER_RESERVE = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_FEE_NICKNAME_CREATE, strTemp)) - FEE_NICKNAME_CREATE = lexicalCastThrow (strTemp); + FEE_NICKNAME_CREATE = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_FEE_OFFER, strTemp)) - FEE_OFFER = lexicalCastThrow (strTemp); + FEE_OFFER = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_FEE_DEFAULT, strTemp)) - FEE_DEFAULT = lexicalCastThrow (strTemp); + FEE_DEFAULT = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_FEE_OPERATION, strTemp)) - FEE_CONTRACT_OPERATION = lexicalCastThrow (strTemp); + FEE_CONTRACT_OPERATION = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_LEDGER_HISTORY, strTemp)) { @@ -548,7 +548,7 @@ void Config::load () else if (strTemp == "none") LEDGER_HISTORY = 0; else - LEDGER_HISTORY = lexicalCastThrow (strTemp); + LEDGER_HISTORY = beast::lexicalCastThrow (strTemp); } if (SectionSingleB (secConfig, SECTION_FETCH_DEPTH, strTemp)) { @@ -559,23 +559,23 @@ void Config::load () else if (strTemp == "full") FETCH_DEPTH = 1000000000u; else - FETCH_DEPTH = lexicalCastThrow (strTemp); + FETCH_DEPTH = beast::lexicalCastThrow (strTemp); if (FETCH_DEPTH < 10) FETCH_DEPTH = 10; } if (SectionSingleB (secConfig, SECTION_PATH_SEARCH_OLD, strTemp)) - PATH_SEARCH_OLD = lexicalCastThrow (strTemp); + PATH_SEARCH_OLD = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_PATH_SEARCH, strTemp)) - PATH_SEARCH = lexicalCastThrow (strTemp); + PATH_SEARCH = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_PATH_SEARCH_FAST, strTemp)) - PATH_SEARCH_FAST = lexicalCastThrow (strTemp); + PATH_SEARCH_FAST = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_PATH_SEARCH_MAX, strTemp)) - PATH_SEARCH_MAX = lexicalCastThrow (strTemp); + PATH_SEARCH_MAX = beast::lexicalCastThrow (strTemp); if (SectionSingleB (secConfig, SECTION_ACCOUNT_PROBE_MAX, strTemp)) - ACCOUNT_PROBE_MAX = lexicalCastThrow (strTemp); + ACCOUNT_PROBE_MAX = beast::lexicalCastThrow (strTemp); (void) SectionSingleB (secConfig, SECTION_SMS_FROM, SMS_FROM); (void) SectionSingleB (secConfig, SECTION_SMS_KEY, SMS_KEY); @@ -649,49 +649,49 @@ Config& getConfig () //------------------------------------------------------------------------------ -File Config::getConfigDir () const +beast::File Config::getConfigDir () const { - String const s (CONFIG_FILE.native().c_str ()); + beast::String const s (CONFIG_FILE.native().c_str ()); if (s.isNotEmpty ()) - return File (s).getParentDirectory (); - return File::nonexistent (); + return beast::File (s).getParentDirectory (); + return beast::File::nonexistent (); } -File Config::getDatabaseDir () const +beast::File Config::getDatabaseDir () const { - String const s (DATA_DIR.native().c_str()); + beast::String const s (DATA_DIR.native().c_str()); if (s.isNotEmpty ()) - return File (s); - return File::nonexistent (); + return beast::File (s); + return beast::File::nonexistent (); } -File Config::getValidatorsFile () const +beast::File Config::getValidatorsFile () const { - String const s (VALIDATORS_FILE.native().c_str()); - if (s.isNotEmpty() && getConfigDir() != File::nonexistent()) + beast::String const s (VALIDATORS_FILE.native().c_str()); + if (s.isNotEmpty() && getConfigDir() != beast::File::nonexistent()) return getConfigDir().getChildFile (s); - return File::nonexistent (); + return beast::File::nonexistent (); } -URL Config::getValidatorsURL () const +beast::URL Config::getValidatorsURL () const { //String s = "https://" + VALIDATORS_SITE + VALIDATORS_URI; - String s = VALIDATORS_SITE; - return ParsedURL (s).url (); + beast::String s = VALIDATORS_SITE; + return beast::ParsedURL (s).url (); } //------------------------------------------------------------------------------ void Config::setRpcIpAndOptionalPort (std::string const& newAddress) { - String const s (newAddress.c_str ()); + beast::String const s (newAddress.c_str ()); int const colonPosition = s.lastIndexOfChar (':'); if (colonPosition != -1) { - String const ipPart = s.substring (0, colonPosition); - String const portPart = s.substring (colonPosition + 1, s.length ()); + beast::String const ipPart = s.substring (0, colonPosition); + beast::String const portPart = s.substring (colonPosition + 1, s.length ()); setRpcIP (ipPart.toRawUTF8 ()); setRpcPort (portPart.getIntValue ()); @@ -743,7 +743,7 @@ Config::Role Config::getAdminRole (Json::Value const& params, beast::IP::Endpoin } // Meets IP restriction for admin. - IP::Endpoint const remote_addr (remoteIp.at_port (0)); + beast::IP::Endpoint const remote_addr (remoteIp.at_port (0)); bool bAdminIP = false; for (auto const& allow_addr : RPC_ADMIN_ALLOW) @@ -771,7 +771,7 @@ Config::Role Config::getAdminRole (Json::Value const& params, beast::IP::Endpoin } //------------------------------------------------------------------------------ -File const& Config::getModuleDatabasePath () +beast::File const& Config::getModuleDatabasePath () { return m_moduleDbPath; } diff --git a/src/ripple_core/functional/Config.h b/src/ripple_core/functional/Config.h index 99b928b36c..3ff3e358e0 100644 --- a/src/ripple_core/functional/Config.h +++ b/src/ripple_core/functional/Config.h @@ -127,13 +127,13 @@ public: { public: Error () noexcept - : m_what (String::empty) + : m_what (beast::String::empty) , m_fileName ("") , m_lineNumber (0) { } - Error (String what, char const* fileName, int lineNumber) noexcept + Error (beast::String what, char const* fileName, int lineNumber) noexcept : m_what (what) , m_fileName (fileName) , m_lineNumber (lineNumber) @@ -143,10 +143,10 @@ public: explicit operator bool() const noexcept { - return m_what != String::empty; + return m_what != beast::String::empty; } - String what () const noexcept + beast::String what () const noexcept { return m_what; } @@ -162,7 +162,7 @@ public: } private: - String m_what; + beast::String m_what; char const* m_fileName; int m_lineNumber; }; @@ -182,10 +182,10 @@ public: // Settings related to the configuration file location and directories /** Returns the directory from which the configuration file was loaded. */ - File getConfigDir () const; + beast::File getConfigDir () const; /** Returns the directory in which the current database files are located. */ - File getDatabaseDir () const; + beast::File getDatabaseDir () const; // LEGACY FIELDS, REMOVE ASAP boost::filesystem::path CONFIG_FILE; // used by UniqueNodeList @@ -200,10 +200,10 @@ public: // Settings related to validators /** Return the path to the separate, optional validators file. */ - File getValidatorsFile () const; + beast::File getValidatorsFile () const; /** Returns the optional URL to a trusted network source of validators. */ - URL getValidatorsURL () const; + beast::URL getValidatorsURL () const; // DEPRECATED boost::filesystem::path VALIDATORS_FILE; // As specifed in rippled.cfg. @@ -244,9 +244,9 @@ public: /** Convert the RPC/port combination to a readable string. */ - String const getRpcAddress () + beast::String const getRpcAddress () { - String s; + beast::String s; s << m_rpcIP.c_str () << ":" << m_rpcPort; @@ -262,7 +262,7 @@ public: ADMIN, FORBID }; - Role getAdminRole (Json::Value const& params, IP::Endpoint const& remoteIp) const; + Role getAdminRole (Json::Value const& params, beast::IP::Endpoint const& remoteIp) const; /** Listening port number for peer connections. */ int peerListeningPort; @@ -286,7 +286,7 @@ private: private: /** The folder where new module databases should be located */ - File m_moduleDbPath; + beast::File m_moduleDbPath; public: //-------------------------------------------------------------------------- @@ -296,12 +296,12 @@ public: stored in a file named after the module (e.g. "peerfinder.sqlite") that is inside that directory. */ - File const& getModuleDatabasePath (); + beast::File const& getModuleDatabasePath (); //-------------------------------------------------------------------------- /** Parameters for the insight collection module */ - StringPairArray insightSettings; + beast::StringPairArray insightSettings; /** Parameters for the main NodeStore database. @@ -310,7 +310,7 @@ public: @see Database */ - StringPairArray nodeDatabase; + beast::StringPairArray nodeDatabase; /** Parameters for the ephemeral NodeStore database. @@ -322,7 +322,7 @@ public: @see Database */ - StringPairArray ephemeralNodeDatabase; + beast::StringPairArray ephemeralNodeDatabase; /** Parameters for importing an old database in to the current node database. If this is not empty, then it specifies the key/value parameters for @@ -333,7 +333,7 @@ public: @see parseDelimitedKeyValueString */ bool doImport; - StringPairArray importNodeDatabase; + beast::StringPairArray importNodeDatabase; // // @@ -451,25 +451,25 @@ public: RippleAddress NODE_SEED, NODE_PUB, NODE_PRIV; // Fee schedule (All below values are in fee units) - uint64 FEE_DEFAULT; // Default fee. - uint64 FEE_ACCOUNT_RESERVE; // Amount of units not allowed to send. - uint64 FEE_OWNER_RESERVE; // Amount of units not allowed to send per owner entry. - uint64 FEE_NICKNAME_CREATE; // Fee to create a nickname. - uint64 FEE_OFFER; // Rate per day. + beast::uint64 FEE_DEFAULT; // Default fee. + beast::uint64 FEE_ACCOUNT_RESERVE; // Amount of units not allowed to send. + beast::uint64 FEE_OWNER_RESERVE; // Amount of units not allowed to send per owner entry. + beast::uint64 FEE_NICKNAME_CREATE; // Fee to create a nickname. + beast::uint64 FEE_OFFER; // Rate per day. int FEE_CONTRACT_OPERATION; // fee for each contract operation // Node storage configuration - uint32 LEDGER_HISTORY; - uint32 FETCH_DEPTH; + beast::uint32 LEDGER_HISTORY; + beast::uint32 FETCH_DEPTH; int NODE_SIZE; // Client behavior int ACCOUNT_PROBE_MAX; // How far to scan for accounts. // Signing signatures. - uint32 SIGN_TRANSACTION; - uint32 SIGN_VALIDATION; - uint32 SIGN_PROPOSAL; + beast::uint32 SIGN_TRANSACTION; + beast::uint32 SIGN_VALIDATION; + beast::uint32 SIGN_PROPOSAL; bool SSL_VERIFY; std::string SSL_VERIFY_FILE; diff --git a/src/ripple_core/functional/ConfigSections.h b/src/ripple_core/functional/ConfigSections.h index a87acf8b1c..59ed90ede9 100644 --- a/src/ripple_core/functional/ConfigSections.h +++ b/src/ripple_core/functional/ConfigSections.h @@ -28,9 +28,9 @@ // struct ConfigSection { - static String nodeDatabase () { return "node_db"; } - static String tempNodeDatabase () { return "temp_db"; } - static String importNodeDatabase () { return "import_db"; } + static beast::String nodeDatabase () { return "node_db"; } + static beast::String tempNodeDatabase () { return "temp_db"; } + static beast::String importNodeDatabase () { return "import_db"; } }; // VFALCO TODO Rename and replace these macros with variables. diff --git a/src/ripple_core/functional/Job.cpp b/src/ripple_core/functional/Job.cpp index 2fb145c9a1..3a9ea417cf 100644 --- a/src/ripple_core/functional/Job.cpp +++ b/src/ripple_core/functional/Job.cpp @@ -25,7 +25,7 @@ Job::Job () { } -Job::Job (JobType type, uint64 index) +Job::Job (JobType type, beast::uint64 index) : mType (type) , mJobIndex (index) { @@ -33,7 +33,7 @@ Job::Job (JobType type, uint64 index) Job::Job (JobType type, std::string const& name, - uint64 index, + beast::uint64 index, LoadMonitor& lm, std::function const& job, CancelCallback cancelCallback) diff --git a/src/ripple_core/functional/Job.h b/src/ripple_core/functional/Job.h index 6a90a7df9c..e6e4339709 100644 --- a/src/ripple_core/functional/Job.h +++ b/src/ripple_core/functional/Job.h @@ -90,12 +90,12 @@ public: //Job (Job const& other); - Job (JobType type, uint64 index); + Job (JobType type, beast::uint64 index); // VFALCO TODO try to remove the dependency on LoadMonitor. Job (JobType type, std::string const& name, - uint64 index, + beast::uint64 index, LoadMonitor& lm, std::function const& job, CancelCallback cancelCallback); @@ -126,7 +126,7 @@ public: private: CancelCallback m_cancelCallback; JobType mType; - uint64 mJobIndex; + beast::uint64 mJobIndex; std::function mJob; LoadEvent::pointer m_loadEvent; std::string mName; diff --git a/src/ripple_core/functional/JobQueue.cpp b/src/ripple_core/functional/JobQueue.cpp index ebbcea519e..b0c3612d3e 100644 --- a/src/ripple_core/functional/JobQueue.cpp +++ b/src/ripple_core/functional/JobQueue.cpp @@ -31,16 +31,16 @@ namespace ripple { class JobQueueImp : public JobQueue - , private Workers::Callback + , private beast::Workers::Callback { public: typedef std::set JobSet; typedef std::map JobDataMap; - typedef CriticalSection::ScopedLockType ScopedLock; + typedef beast::CriticalSection::ScopedLockType ScopedLock; - Journal m_journal; - CriticalSection m_mutex; - uint64 m_lastJob; + beast::Journal m_journal; + beast::CriticalSection m_mutex; + beast::uint64 m_lastJob; JobSet m_jobSet; JobDataMap m_jobData; JobTypeData m_invalidJobData; @@ -48,13 +48,13 @@ public: // The number of jobs currently in processTask() int m_processCount; - Workers m_workers; + beast::Workers m_workers; CancelCallback m_cancelCallback; // statistics tracking - insight::Collector::ptr m_collector; - insight::Gauge job_count; - insight::Hook hook; + beast::insight::Collector::ptr m_collector; + beast::insight::Gauge job_count; + beast::insight::Hook hook; //-------------------------------------------------------------------------- static JobTypes const& getJobTypes () @@ -65,8 +65,8 @@ public: } //-------------------------------------------------------------------------- - JobQueueImp (insight::Collector::ptr const& collector, - Stoppable& parent, Journal journal) + JobQueueImp (beast::insight::Collector::ptr const& collector, + Stoppable& parent, beast::Journal journal) : JobQueue ("JobQueue", parent) , m_journal (journal) , m_lastJob (0) @@ -99,7 +99,7 @@ public: ~JobQueueImp () { // Must unhook before destroying - hook = insight::Hook (); + hook = beast::insight::Hook (); } void collect () @@ -220,7 +220,7 @@ public: } else if (c == 0) { - c = SystemStats::getNumCpus (); + c = beast::SystemStats::getNumCpus (); // VFALCO NOTE According to boost, hardware_concurrency cannot return // negative numbers/ @@ -283,7 +283,7 @@ public: Json::Value ret (Json::objectValue); ret["threads"] = m_workers.getNumberOfThreads (); - ret["cpu"] = String::fromNumber (m_workers.getUtilization() * 100) + "%"; + ret["cpu"] = beast::String::fromNumber (m_workers.getUtilization() * 100) + "%"; Json::Value priorities = Json::arrayValue; @@ -549,7 +549,7 @@ private: // if (!isStopping() || !data.info.skip ()) { - Thread::setCurrentThreadName (data.name ()); + beast::Thread::setCurrentThreadName (data.name ()); m_journal.trace << "Doing " << data.name () << " job"; Job::clock_type::time_point const start_time ( @@ -641,7 +641,7 @@ private: if (report) { - Journal::ScopedStream s (m_journal.debug); + beast::Journal::ScopedStream s (m_journal.debug); for (JobDataMap::const_iterator iter (counts.begin()); iter != counts.end(); ++iter) @@ -673,8 +673,8 @@ JobQueue::JobQueue (char const* name, Stoppable& parent) //------------------------------------------------------------------------------ std::unique_ptr make_JobQueue ( - insight::Collector::ptr const& collector, - Stoppable& parent, Journal journal) + beast::insight::Collector::ptr const& collector, + beast::Stoppable& parent, beast::Journal journal) { return std::make_unique (collector, parent, journal); } diff --git a/src/ripple_core/functional/JobQueue.h b/src/ripple_core/functional/JobQueue.h index 6f8fe315ee..1f54f9d908 100644 --- a/src/ripple_core/functional/JobQueue.h +++ b/src/ripple_core/functional/JobQueue.h @@ -22,7 +22,7 @@ namespace ripple { -class JobQueue : public Stoppable +class JobQueue : public beast::Stoppable { protected: JobQueue (char const* name, Stoppable& parent); @@ -66,8 +66,8 @@ public: virtual Json::Value getJson (int c = 0) = 0; }; -std::unique_ptr make_JobQueue (insight::Collector::ptr const& collector, - Stoppable& parent, Journal journal); +std::unique_ptr make_JobQueue (beast::insight::Collector::ptr const& collector, + beast::Stoppable& parent, beast::Journal journal); } diff --git a/src/ripple_core/functional/JobTypeData.h b/src/ripple_core/functional/JobTypeData.h index 7a21015f62..8e18be058e 100644 --- a/src/ripple_core/functional/JobTypeData.h +++ b/src/ripple_core/functional/JobTypeData.h @@ -31,7 +31,7 @@ private: LoadMonitor m_load; /* Support for insight */ - insight::Collector::ptr m_collector; + beast::insight::Collector::ptr m_collector; public: /* The job category which we represent */ @@ -47,11 +47,11 @@ public: int deferred; /* Notification callbacks */ - insight::Event dequeue; - insight::Event execute; + beast::insight::Event dequeue; + beast::insight::Event execute; explicit JobTypeData (JobTypeInfo const& info_, - insight::Collector::ptr const& collector) noexcept + beast::insight::Collector::ptr const& collector) noexcept : m_collector (collector) , info (info_) , waiting (0) diff --git a/src/ripple_core/functional/JobTypeInfo.h b/src/ripple_core/functional/JobTypeInfo.h index 0db57aa5f0..ba62a22040 100644 --- a/src/ripple_core/functional/JobTypeInfo.h +++ b/src/ripple_core/functional/JobTypeInfo.h @@ -40,15 +40,15 @@ private: bool const m_special; /** Average and peak latencies for this job type. 0 is none specified */ - uint64 const m_avgLatency; - uint64 const m_peakLatency; + beast::uint64 const m_avgLatency; + beast::uint64 const m_peakLatency; public: // Not default constructible JobTypeInfo () = delete; JobTypeInfo (JobType type, std::string name, int limit, - bool skip, bool special, uint64 avgLatency, uint64 peakLatency) + bool skip, bool special, beast::uint64 avgLatency, beast::uint64 peakLatency) : m_type (type) , m_name (name) , m_limit (limit) @@ -85,12 +85,12 @@ public: return m_special; } - uint64 getAverageLatency () const + beast::uint64 getAverageLatency () const { return m_avgLatency; } - uint64 getPeakLatency () const + beast::uint64 getPeakLatency () const { return m_peakLatency; } diff --git a/src/ripple_core/functional/JobTypes.h b/src/ripple_core/functional/JobTypes.h index 250dcbc7b8..5df60035f1 100644 --- a/src/ripple_core/functional/JobTypes.h +++ b/src/ripple_core/functional/JobTypes.h @@ -198,7 +198,7 @@ public: private: void add(JobType jt, std::string name, int limit, - bool skip, bool special, uint64 avgLatency, uint64 peakLatency) + bool skip, bool special, beast::uint64 avgLatency, beast::uint64 peakLatency) { assert (m_map.find (jt) == m_map.end ()); diff --git a/src/ripple_core/functional/LoadEvent.cpp b/src/ripple_core/functional/LoadEvent.cpp index 0c88bef409..6bedb919c4 100644 --- a/src/ripple_core/functional/LoadEvent.cpp +++ b/src/ripple_core/functional/LoadEvent.cpp @@ -21,7 +21,7 @@ LoadEvent::LoadEvent (LoadMonitor& monitor, const std::string& name, bool should : m_loadMonitor (monitor) , m_isRunning (false) , m_name (name) - , m_timeStopped (RelativeTime::fromStartup()) + , m_timeStopped (beast::RelativeTime::fromStartup()) , m_secondsWaiting (0) , m_secondsRunning (0) { @@ -62,7 +62,7 @@ void LoadEvent::reName (const std::string& name) void LoadEvent::start () { - RelativeTime const currentTime (RelativeTime::fromStartup()); + beast::RelativeTime const currentTime (beast::RelativeTime::fromStartup()); // If we already called start, this call will replace the previous one. if (m_isRunning) @@ -82,7 +82,7 @@ void LoadEvent::stop () { bassert (m_isRunning); - m_timeStopped = RelativeTime::fromStartup(); + m_timeStopped = beast::RelativeTime::fromStartup(); m_secondsRunning += (m_timeStopped - m_timeStarted).inSeconds(); m_isRunning = false; diff --git a/src/ripple_core/functional/LoadEvent.h b/src/ripple_core/functional/LoadEvent.h index c48313c215..01918652aa 100644 --- a/src/ripple_core/functional/LoadEvent.h +++ b/src/ripple_core/functional/LoadEvent.h @@ -70,8 +70,8 @@ private: LoadMonitor& m_loadMonitor; bool m_isRunning; std::string m_name; - RelativeTime m_timeStopped; - RelativeTime m_timeStarted; + beast::RelativeTime m_timeStopped; + beast::RelativeTime m_timeStarted; double m_secondsWaiting; double m_secondsRunning; }; diff --git a/src/ripple_core/functional/LoadFeeTrack.h b/src/ripple_core/functional/LoadFeeTrack.h index 5b230acfb8..bed002d46a 100644 --- a/src/ripple_core/functional/LoadFeeTrack.h +++ b/src/ripple_core/functional/LoadFeeTrack.h @@ -35,28 +35,31 @@ class LoadFeeTrack public: /** Create a new tracker. */ - static LoadFeeTrack* New (Journal journal); + static LoadFeeTrack* New (beast::Journal journal); virtual ~LoadFeeTrack () { } // Scale from fee units to millionths of a ripple - virtual uint64 scaleFeeBase (uint64 fee, uint64 baseFee, uint32 referenceFeeUnits) = 0; + virtual beast::uint64 scaleFeeBase (beast::uint64 fee, beast::uint64 baseFee, + beast::uint32 referenceFeeUnits) = 0; // Scale using load as well as base rate - virtual uint64 scaleFeeLoad (uint64 fee, uint64 baseFee, uint32 referenceFeeUnits, bool bAdmin) = 0; + virtual beast::uint64 scaleFeeLoad (beast::uint64 fee, beast::uint64 baseFee, + beast::uint32 referenceFeeUnits, + bool bAdmin) = 0; - virtual void setRemoteFee (uint32) = 0; + virtual void setRemoteFee (beast::uint32) = 0; - virtual uint32 getRemoteFee () = 0; - virtual uint32 getLocalFee () = 0; - virtual uint32 getClusterFee () = 0; + virtual beast::uint32 getRemoteFee () = 0; + virtual beast::uint32 getLocalFee () = 0; + virtual beast::uint32 getClusterFee () = 0; - virtual uint32 getLoadBase () = 0; - virtual uint32 getLoadFactor () = 0; + virtual beast::uint32 getLoadBase () = 0; + virtual beast::uint32 getLoadFactor () = 0; - virtual Json::Value getJson (uint64 baseFee, uint32 referenceFeeUnits) = 0; + virtual Json::Value getJson (beast::uint64 baseFee, beast::uint32 referenceFeeUnits) = 0; - virtual void setClusterFee (uint32) = 0; + virtual void setClusterFee (beast::uint32) = 0; virtual bool raiseLocalFee () = 0; virtual bool lowerLocalFee () = 0; virtual bool isLoadedLocal () = 0; diff --git a/src/ripple_core/functional/LoadFeeTrackImp.cpp b/src/ripple_core/functional/LoadFeeTrackImp.cpp index 8bf37d7aea..ef6ebca5ba 100644 --- a/src/ripple_core/functional/LoadFeeTrackImp.cpp +++ b/src/ripple_core/functional/LoadFeeTrackImp.cpp @@ -17,14 +17,14 @@ */ //============================================================================== -LoadFeeTrack* LoadFeeTrack::New (Journal journal) +LoadFeeTrack* LoadFeeTrack::New (beast::Journal journal) { return new LoadFeeTrackImp (journal); } //------------------------------------------------------------------------------ -class LoadFeeTrackTests : public UnitTest +class LoadFeeTrackTests : public beast::UnitTest { public: LoadFeeTrackTests () : UnitTest ("LoadFeeTrack", "ripple") diff --git a/src/ripple_core/functional/LoadFeeTrackImp.h b/src/ripple_core/functional/LoadFeeTrackImp.h index 75dd0d361d..081cf6936a 100644 --- a/src/ripple_core/functional/LoadFeeTrackImp.h +++ b/src/ripple_core/functional/LoadFeeTrackImp.h @@ -23,7 +23,7 @@ class LoadFeeTrackImp : public LoadFeeTrack { public: - explicit LoadFeeTrackImp (Journal journal = Journal()) + explicit LoadFeeTrackImp (beast::Journal journal = beast::Journal()) : m_journal (journal) , mLock (this, "LoadFeeTrackImp", __FILE__, __LINE__) , mLocalTxnLoadFee (lftNormalFee) @@ -34,9 +34,9 @@ public: } // Scale using load as well as base rate - uint64 scaleFeeLoad (uint64 fee, uint64 baseFee, uint32 referenceFeeUnits, bool bAdmin) + beast::uint64 scaleFeeLoad (beast::uint64 fee, beast::uint64 baseFee, beast::uint32 referenceFeeUnits, bool bAdmin) { - static uint64 midrange (0x00000000FFFFFFFF); + static beast::uint64 midrange (0x00000000FFFFFFFF); bool big = (fee > midrange); @@ -45,10 +45,10 @@ public: else // normal fee, multiply first for accuracy fee *= referenceFeeUnits; - uint32 feeFactor = std::max (mLocalTxnLoadFee, mRemoteTxnLoadFee); + beast::uint32 feeFactor = std::max (mLocalTxnLoadFee, mRemoteTxnLoadFee); // Let admins pay the normal fee until the local load exceeds four times the remote - uint32 uRemFee = std::max(mRemoteTxnLoadFee, mClusterTxnLoadFee); + beast::uint32 uRemFee = std::max(mRemoteTxnLoadFee, mClusterTxnLoadFee); if (bAdmin && (feeFactor > uRemFee) && (feeFactor < (4 * uRemFee))) feeFactor = uRemFee; @@ -66,41 +66,41 @@ public: } // Scale from fee units to millionths of a ripple - uint64 scaleFeeBase (uint64 fee, uint64 baseFee, uint32 referenceFeeUnits) + beast::uint64 scaleFeeBase (beast::uint64 fee, beast::uint64 baseFee, beast::uint32 referenceFeeUnits) { return mulDiv (fee, referenceFeeUnits, baseFee); } - uint32 getRemoteFee () + beast::uint32 getRemoteFee () { ScopedLockType sl (mLock, __FILE__, __LINE__); return mRemoteTxnLoadFee; } - uint32 getLocalFee () + beast::uint32 getLocalFee () { ScopedLockType sl (mLock, __FILE__, __LINE__); return mLocalTxnLoadFee; } - uint32 getLoadBase () + beast::uint32 getLoadBase () { return lftNormalFee; } - uint32 getLoadFactor () + beast::uint32 getLoadFactor () { ScopedLockType sl (mLock, __FILE__, __LINE__); return std::max(mClusterTxnLoadFee, std::max (mLocalTxnLoadFee, mRemoteTxnLoadFee)); } - void setClusterFee (uint32 fee) + void setClusterFee (beast::uint32 fee) { ScopedLockType sl (mLock, __FILE__, __LINE__); mClusterTxnLoadFee = fee; } - uint32 getClusterFee () + beast::uint32 getClusterFee () { ScopedLockType sl (mLock, __FILE__, __LINE__); return mClusterTxnLoadFee; @@ -130,7 +130,7 @@ public: return (raiseCount != 0) || (mLocalTxnLoadFee != lftNormalFee) || (mClusterTxnLoadFee != lftNormalFee); } - void setRemoteFee (uint32 f) + void setRemoteFee (beast::uint32 f) { ScopedLockType sl (mLock, __FILE__, __LINE__); mRemoteTxnLoadFee = f; @@ -143,7 +143,7 @@ public: if (++raiseCount < 2) return false; - uint32 origFee = mLocalTxnLoadFee; + beast::uint32 origFee = mLocalTxnLoadFee; if (mLocalTxnLoadFee < mRemoteTxnLoadFee) // make sure this fee takes effect mLocalTxnLoadFee = mRemoteTxnLoadFee; @@ -163,7 +163,7 @@ public: bool lowerLocalFee () { ScopedLockType sl (mLock, __FILE__, __LINE__); - uint32 origFee = mLocalTxnLoadFee; + beast::uint32 origFee = mLocalTxnLoadFee; raiseCount = 0; mLocalTxnLoadFee -= (mLocalTxnLoadFee / lftFeeDecFraction ); // reduce by 1/4 @@ -178,7 +178,7 @@ public: return true; } - Json::Value getJson (uint64 baseFee, uint32 referenceFeeUnits) + Json::Value getJson (beast::uint64 baseFee, beast::uint32 referenceFeeUnits) { Json::Value j (Json::objectValue); @@ -199,11 +199,11 @@ public: private: // VFALCO TODO Move this function to some "math utilities" file // compute (value)*(mul)/(div) - avoid overflow but keep precision - uint64 mulDiv (uint64 value, uint32 mul, uint64 div) + beast::uint64 mulDiv (beast::uint64 value, beast::uint32 mul, beast::uint64 div) { // VFALCO TODO replace with beast::literal64bitUnsigned () // - static uint64 boundary = (0x00000000FFFFFFFF); + static beast::uint64 boundary = (0x00000000FFFFFFFF); if (value > boundary) // Large value, avoid overflow return (value / div) * mul; @@ -217,14 +217,14 @@ private: static const int lftFeeDecFraction = 4; // decrease fee by 1/4 static const int lftFeeMax = lftNormalFee * 1000000; - Journal m_journal; + beast::Journal m_journal; typedef RippleMutex LockType; typedef LockType::ScopedLockType ScopedLockType; LockType mLock; - uint32 mLocalTxnLoadFee; // Scale factor, lftNormalFee = normal fee - uint32 mRemoteTxnLoadFee; // Scale factor, lftNormalFee = normal fee - uint32 mClusterTxnLoadFee; // Scale factor, lftNormalFee = normal fee + beast::uint32 mLocalTxnLoadFee; // Scale factor, lftNormalFee = normal fee + beast::uint32 mRemoteTxnLoadFee; // Scale factor, lftNormalFee = normal fee + beast::uint32 mClusterTxnLoadFee; // Scale factor, lftNormalFee = normal fee int raiseCount; }; diff --git a/src/ripple_core/functional/LoadMonitor.cpp b/src/ripple_core/functional/LoadMonitor.cpp index 13088c59e7..21f4aca45e 100644 --- a/src/ripple_core/functional/LoadMonitor.cpp +++ b/src/ripple_core/functional/LoadMonitor.cpp @@ -138,7 +138,7 @@ std::string LoadMonitor::printElapsed (double seconds) void LoadMonitor::addLoadSample (LoadEvent const& sample) { std::string const& name (sample.name()); - RelativeTime const latency (sample.getSecondsTotal()); + beast::RelativeTime const latency (sample.getSecondsTotal()); if (latency.inSeconds() > 0.5) { @@ -167,13 +167,13 @@ void LoadMonitor::addLoadSample (LoadEvent const& sample) mLatencyMSPeak = latencyPeak; } -void LoadMonitor::setTargetLatency (uint64 avg, uint64 pk) +void LoadMonitor::setTargetLatency (beast::uint64 avg, beast::uint64 pk) { mTargetLatencyAvg = avg; mTargetLatencyPk = pk; } -bool LoadMonitor::isOverTarget (uint64 avg, uint64 peak) +bool LoadMonitor::isOverTarget (beast::uint64 avg, beast::uint64 peak) { return (mTargetLatencyPk && (peak > mTargetLatencyPk)) || (mTargetLatencyAvg && (avg > mTargetLatencyAvg)); diff --git a/src/ripple_core/functional/LoadMonitor.h b/src/ripple_core/functional/LoadMonitor.h index 321e4a4ff5..8fe318b4db 100644 --- a/src/ripple_core/functional/LoadMonitor.h +++ b/src/ripple_core/functional/LoadMonitor.h @@ -35,18 +35,18 @@ public: void addLoadSample (LoadEvent const& sample); - void setTargetLatency (uint64 avg, uint64 pk); + void setTargetLatency (beast::uint64 avg, beast::uint64 pk); - bool isOverTarget (uint64 avg, uint64 peak); + bool isOverTarget (beast::uint64 avg, beast::uint64 peak); // VFALCO TODO make this return the values in a struct. struct Stats { Stats(); - uint64 count; - uint64 latencyAvg; - uint64 latencyPeak; + beast::uint64 count; + beast::uint64 latencyAvg; + beast::uint64 latencyPeak; bool isOverloaded; }; @@ -63,13 +63,13 @@ private: typedef LockType::ScopedLockType ScopedLockType; LockType mLock; - uint64 mCounts; - int mLatencyEvents; - uint64 mLatencyMSAvg; - uint64 mLatencyMSPeak; - uint64 mTargetLatencyAvg; - uint64 mTargetLatencyPk; - int mLastUpdate; + beast::uint64 mCounts; + int mLatencyEvents; + beast::uint64 mLatencyMSAvg; + beast::uint64 mLatencyMSPeak; + beast::uint64 mTargetLatencyAvg; + beast::uint64 mTargetLatencyPk; + int mLastUpdate; }; #endif diff --git a/src/ripple_core/nodestore/api/Database.h b/src/ripple_core/nodestore/api/Database.h index 1157946c98..583808dc9a 100644 --- a/src/ripple_core/nodestore/api/Database.h +++ b/src/ripple_core/nodestore/api/Database.h @@ -49,7 +49,7 @@ public: This is used for diagnostics and may not reflect the actual path or paths used by the underlying backend. */ - virtual String getName () const = 0; + virtual beast::String getName () const = 0; /** Fetch an object. If the object is known to be not in the database, isn't found in the @@ -97,7 +97,7 @@ public: @return `true` if the object was stored? */ virtual void store (NodeObjectType type, - uint32 ledgerIndex, + beast::uint32 ledgerIndex, Blob& data, uint256 const& hash) = 0; diff --git a/src/ripple_core/nodestore/api/Factory.h b/src/ripple_core/nodestore/api/Factory.h index eb6f5717e8..963e79d89c 100644 --- a/src/ripple_core/nodestore/api/Factory.h +++ b/src/ripple_core/nodestore/api/Factory.h @@ -30,7 +30,7 @@ public: virtual ~Factory () = 0; /** Retrieve the name of this factory. */ - virtual String getName () const = 0; + virtual beast::String getName () const = 0; /** Create an instance of this factory's backend. @param keyBytes The fixed number of bytes per key. @@ -40,7 +40,7 @@ public: */ virtual std::unique_ptr createInstance (size_t keyBytes, Parameters const& parameters, Scheduler& scheduler, - Journal journal) = 0; + beast::Journal journal) = 0; }; } diff --git a/src/ripple_core/nodestore/api/Manager.h b/src/ripple_core/nodestore/api/Manager.h index 3aba115b75..de15bebc6f 100644 --- a/src/ripple_core/nodestore/api/Manager.h +++ b/src/ripple_core/nodestore/api/Manager.h @@ -43,7 +43,7 @@ public: /** Create a backend. */ virtual std::unique_ptr make_Backend (Parameters const& parameters, - Scheduler& scheduler, Journal journal) = 0; + Scheduler& scheduler, beast::Journal journal) = 0; /** Construct a node store database. @@ -70,7 +70,7 @@ public: @return The opened database. */ virtual std::unique_ptr make_Database (std::string const& name, - Scheduler& scheduler, Journal journal, int readThreads, + Scheduler& scheduler, beast::Journal journal, int readThreads, Parameters const& backendParameters, Parameters fastBackendParameters = Parameters ()) = 0; }; diff --git a/src/ripple_core/nodestore/api/NodeObject.h b/src/ripple_core/nodestore/api/NodeObject.h index aac0a8f31f..a721f0af38 100644 --- a/src/ripple_core/nodestore/api/NodeObject.h +++ b/src/ripple_core/nodestore/api/NodeObject.h @@ -67,7 +67,7 @@ public: @note The key size can be retrieved with `Hash::sizeInBytes` */ - typedef UnsignedInteger <32> Hash; + typedef beast::UnsignedInteger <32> Hash; // Please use this one. For a reference use Ptr const& typedef boost::shared_ptr Ptr; diff --git a/src/ripple_core/nodestore/api/Types.h b/src/ripple_core/nodestore/api/Types.h index bf064a5d27..85701148b3 100644 --- a/src/ripple_core/nodestore/api/Types.h +++ b/src/ripple_core/nodestore/api/Types.h @@ -47,7 +47,7 @@ typedef std::vector Batch; /** A list of key/value parameter pairs passed to the backend. */ // VFALCO TODO Use std::string, pair, vector -typedef StringPairArray Parameters; +typedef beast::StringPairArray Parameters; } } diff --git a/src/ripple_core/nodestore/backend/HyperDBFactory.cpp b/src/ripple_core/nodestore/backend/HyperDBFactory.cpp index d194f33a35..f2a43fc45a 100644 --- a/src/ripple_core/nodestore/backend/HyperDBFactory.cpp +++ b/src/ripple_core/nodestore/backend/HyperDBFactory.cpp @@ -25,10 +25,10 @@ namespace NodeStore { class HyperDBBackend : public Backend , public BatchWriter::Callback - , public LeakChecked + , public beast::LeakChecked { public: - Journal m_journal; + beast::Journal m_journal; size_t const m_keyBytes; Scheduler& m_scheduler; BatchWriter m_batch; @@ -36,7 +36,7 @@ public: std::unique_ptr m_db; HyperDBBackend (size_t keyBytes, Parameters const& keyValues, - Scheduler& scheduler, Journal journal) + Scheduler& scheduler, beast::Journal journal) : m_journal (journal) , m_keyBytes (keyBytes) , m_scheduler (scheduler) @@ -44,7 +44,7 @@ public: , m_name (keyValues ["path"].toStdString ()) { if (m_name.empty ()) - Throw (std::runtime_error ("Missing path in LevelDBFactory backend")); + beast::Throw (std::runtime_error ("Missing path in LevelDBFactory backend")); hyperleveldb::Options options; options.create_if_missing = true; @@ -76,7 +76,7 @@ public: hyperleveldb::DB* db = nullptr; hyperleveldb::Status status = hyperleveldb::DB::Open (options, m_name, &db); if (!status.ok () || !db) - Throw (std::runtime_error (std::string ( + beast::Throw (std::runtime_error (std::string ( "Unable to open/create hyperleveldb: ") + status.ToString())); m_db.reset (db); @@ -222,13 +222,13 @@ public: class HyperDBFactory : public NodeStore::Factory { public: - String getName () const + beast::String getName () const { return "HyperLevelDB"; } std::unique_ptr createInstance (size_t keyBytes, - Parameters const& keyValues, Scheduler& scheduler, Journal journal) + Parameters const& keyValues, Scheduler& scheduler, beast::Journal journal) { return std::make_unique ( keyBytes, keyValues, scheduler, journal); diff --git a/src/ripple_core/nodestore/backend/LevelDBFactory.cpp b/src/ripple_core/nodestore/backend/LevelDBFactory.cpp index 3ab6080358..06677014c4 100644 --- a/src/ripple_core/nodestore/backend/LevelDBFactory.cpp +++ b/src/ripple_core/nodestore/backend/LevelDBFactory.cpp @@ -23,19 +23,19 @@ namespace NodeStore { class LevelDBBackend : public Backend , public BatchWriter::Callback - , public LeakChecked + , public beast::LeakChecked { public: - Journal m_journal; + beast::Journal m_journal; size_t const m_keyBytes; Scheduler& m_scheduler; BatchWriter m_batch; - StringPool m_stringPool; + beast::StringPool m_stringPool; std::string m_name; std::unique_ptr m_db; LevelDBBackend (int keyBytes, Parameters const& keyValues, - Scheduler& scheduler, Journal journal) + Scheduler& scheduler, beast::Journal journal) : m_journal (journal) , m_keyBytes (keyBytes) , m_scheduler (scheduler) @@ -43,7 +43,7 @@ public: , m_name (keyValues ["path"].toStdString ()) { if (m_name.empty()) - Throw (std::runtime_error ("Missing path in LevelDBFactory backend")); + beast::Throw (std::runtime_error ("Missing path in LevelDBFactory backend")); leveldb::Options options; options.create_if_missing = true; @@ -75,7 +75,7 @@ public: leveldb::DB* db = nullptr; leveldb::Status status = leveldb::DB::Open (options, m_name, &db); if (!status.ok () || !db) - Throw (std::runtime_error (std::string("Unable to open/create leveldb: ") + status.ToString())); + beast::Throw (std::runtime_error (std::string("Unable to open/create leveldb: ") + status.ToString())); m_db.reset (db); } @@ -227,7 +227,7 @@ public: m_lruCache.reset (options.block_cache); } - String getName () const + beast::String getName () const { return "LevelDB"; } @@ -236,7 +236,7 @@ public: size_t keyBytes, Parameters const& keyValues, Scheduler& scheduler, - Journal journal) + beast::Journal journal) { return std::make_unique ( keyBytes, keyValues, scheduler, journal); diff --git a/src/ripple_core/nodestore/backend/MemoryFactory.cpp b/src/ripple_core/nodestore/backend/MemoryFactory.cpp index dcc95c6f2c..1108a91100 100644 --- a/src/ripple_core/nodestore/backend/MemoryFactory.cpp +++ b/src/ripple_core/nodestore/backend/MemoryFactory.cpp @@ -24,13 +24,13 @@ class MemoryBackend : public Backend { public: typedef std::map Map; - Journal m_journal; + beast::Journal m_journal; size_t const m_keyBytes; Map m_map; Scheduler& m_scheduler; MemoryBackend (size_t keyBytes, Parameters const& keyValues, - Scheduler& scheduler, Journal journal) + Scheduler& scheduler, beast::Journal journal) : m_journal (journal) , m_keyBytes (keyBytes) , m_scheduler (scheduler) @@ -99,14 +99,14 @@ public: class MemoryFactory : public Factory { public: - String getName () const + beast::String getName () const { return "Memory"; } std::unique_ptr createInstance ( size_t keyBytes, Parameters const& keyValues, - Scheduler& scheduler, Journal journal) + Scheduler& scheduler, beast::Journal journal) { return std::make_unique ( keyBytes, keyValues, scheduler, journal); diff --git a/src/ripple_core/nodestore/backend/NullFactory.cpp b/src/ripple_core/nodestore/backend/NullFactory.cpp index a1107112e9..eb90d2642e 100644 --- a/src/ripple_core/nodestore/backend/NullFactory.cpp +++ b/src/ripple_core/nodestore/backend/NullFactory.cpp @@ -66,13 +66,13 @@ private: class NullFactory : public Factory { public: - String getName () const + beast::String getName () const { return "none"; } std::unique_ptr createInstance ( - size_t, Parameters const&, Scheduler&, Journal) + size_t, Parameters const&, Scheduler&, beast::Journal) { return std::make_unique (); } diff --git a/src/ripple_core/nodestore/backend/RocksDBFactory.cpp b/src/ripple_core/nodestore/backend/RocksDBFactory.cpp index 331a5bc8b4..061d15d08f 100644 --- a/src/ripple_core/nodestore/backend/RocksDBFactory.cpp +++ b/src/ripple_core/nodestore/backend/RocksDBFactory.cpp @@ -55,7 +55,7 @@ public: std::size_t const id (++n); std::stringstream ss; ss << "rocksdb #" << id; - Thread::setCurrentThreadName (ss.str()); + beast::Thread::setCurrentThreadName (ss.str()); (*f)(a); } @@ -72,10 +72,10 @@ public: class RocksDBBackend : public Backend , public BatchWriter::Callback - , public LeakChecked + , public beast::LeakChecked { public: - Journal m_journal; + beast::Journal m_journal; size_t const m_keyBytes; Scheduler& m_scheduler; BatchWriter m_batch; @@ -83,7 +83,7 @@ public: std::unique_ptr m_db; RocksDBBackend (int keyBytes, Parameters const& keyValues, - Scheduler& scheduler, Journal journal, RocksDBEnv* env) + Scheduler& scheduler, beast::Journal journal, RocksDBEnv* env) : m_journal (journal) , m_keyBytes (keyBytes) , m_scheduler (scheduler) @@ -91,7 +91,7 @@ public: , m_name (keyValues ["path"].toStdString ()) { if (m_name.empty()) - Throw (std::runtime_error ("Missing path in RocksDBFactory backend")); + beast::Throw (std::runtime_error ("Missing path in RocksDBFactory backend")); rocksdb::Options options; options.create_if_missing = true; @@ -137,7 +137,7 @@ public: rocksdb::DB* db = nullptr; rocksdb::Status status = rocksdb::DB::Open (options, m_name, &db); if (!status.ok () || !db) - Throw (std::runtime_error (std::string("Unable to open/create RocksDB: ") + status.ToString())); + beast::Throw (std::runtime_error (std::string("Unable to open/create RocksDB: ") + status.ToString())); m_db.reset (db); } @@ -299,14 +299,14 @@ public: { } - String getName () const + beast::String getName () const { return "RocksDB"; } std::unique_ptr createInstance ( size_t keyBytes, Parameters const& keyValues, - Scheduler& scheduler, Journal journal) + Scheduler& scheduler, beast::Journal journal) { return std::make_unique ( keyBytes, keyValues, scheduler, journal, &m_env); diff --git a/src/ripple_core/nodestore/impl/DatabaseImp.h b/src/ripple_core/nodestore/impl/DatabaseImp.h index 3ff509993c..54281d7bb3 100644 --- a/src/ripple_core/nodestore/impl/DatabaseImp.h +++ b/src/ripple_core/nodestore/impl/DatabaseImp.h @@ -28,10 +28,10 @@ namespace NodeStore { class DatabaseImp : public Database - , public LeakChecked + , public beast::LeakChecked { public: - Journal m_journal; + beast::Journal m_journal; Scheduler& m_scheduler; // Persistent key/value storage. std::unique_ptr m_backend; @@ -58,7 +58,7 @@ public: int readThreads, std::unique_ptr backend, std::unique_ptr fastBackend, - Journal journal) + beast::Journal journal) : m_journal (journal) , m_scheduler (scheduler) , m_backend (std::move (backend)) @@ -87,7 +87,7 @@ public: th.join (); } - String getName () const + beast::String getName () const { return m_backend->getName (); } @@ -118,7 +118,7 @@ public: std::unique_lock lock (m_readLock); // Wake in two generations - uint64 const wakeGeneration = m_readGen + 2; + beast::uint64 const wakeGeneration = m_readGen + 2; while (!m_readShut && !m_readSet.empty () && (m_readGen < wakeGeneration)) m_readGenCondVar.wait (lock); @@ -232,7 +232,7 @@ public: //------------------------------------------------------------------------------ void store (NodeObjectType type, - uint32 index, + beast::uint32 index, Blob& data, uint256 const& hash) { @@ -283,7 +283,7 @@ public: // Entry point for async read threads void threadEntry () { - Thread::setCurrentThreadName ("prefetch"); + beast::Thread::setCurrentThreadName ("prefetch"); while (1) { uint256 hash; diff --git a/src/ripple_core/nodestore/impl/DecodedBlob.cpp b/src/ripple_core/nodestore/impl/DecodedBlob.cpp index f11420eb55..2c0afb4566 100644 --- a/src/ripple_core/nodestore/impl/DecodedBlob.cpp +++ b/src/ripple_core/nodestore/impl/DecodedBlob.cpp @@ -38,12 +38,12 @@ DecodedBlob::DecodedBlob (void const* key, void const* value, int valueBytes) m_ledgerIndex = LedgerIndex (-1); m_objectType = hotUNKNOWN; m_objectData = nullptr; - m_dataBytes = bmax (0, valueBytes - 9); + m_dataBytes = beast::bmax (0, valueBytes - 9); if (valueBytes > 4) { LedgerIndex const* index = static_cast (value); - m_ledgerIndex = ByteOrder::swapIfLittleEndian (*index); + m_ledgerIndex = beast::ByteOrder::swapIfLittleEndian (*index); } // VFALCO NOTE What about bytes 4 through 7 inclusive? diff --git a/src/ripple_core/nodestore/impl/EncodedBlob.cpp b/src/ripple_core/nodestore/impl/EncodedBlob.cpp index cce11f55f7..2e46e5644f 100644 --- a/src/ripple_core/nodestore/impl/EncodedBlob.cpp +++ b/src/ripple_core/nodestore/impl/EncodedBlob.cpp @@ -30,13 +30,13 @@ void EncodedBlob::prepare (NodeObject::Ptr const& object) m_data.ensureSize (m_size); // These sizes must be the same! - static_bassert (sizeof (uint32) == sizeof (object->getIndex ())); + static_bassert (sizeof (beast::uint32) == sizeof (object->getIndex ())); { - uint32* buf = static_cast (m_data.getData ()); + beast::uint32* buf = static_cast (m_data.getData ()); - buf [0] = ByteOrder::swapIfLittleEndian (object->getIndex ()); - buf [1] = ByteOrder::swapIfLittleEndian (object->getIndex ()); + buf [0] = beast::ByteOrder::swapIfLittleEndian (object->getIndex ()); + buf [1] = beast::ByteOrder::swapIfLittleEndian (object->getIndex ()); } { diff --git a/src/ripple_core/nodestore/impl/EncodedBlob.h b/src/ripple_core/nodestore/impl/EncodedBlob.h index 040e64e1d0..2b821ef609 100644 --- a/src/ripple_core/nodestore/impl/EncodedBlob.h +++ b/src/ripple_core/nodestore/impl/EncodedBlob.h @@ -37,7 +37,7 @@ public: private: void const* m_key; - MemoryBlock m_data; + beast::MemoryBlock m_data; size_t m_size; }; diff --git a/src/ripple_core/nodestore/impl/Manager.cpp b/src/ripple_core/nodestore/impl/Manager.cpp index e7342f99eb..7385acd785 100644 --- a/src/ripple_core/nodestore/impl/Manager.cpp +++ b/src/ripple_core/nodestore/impl/Manager.cpp @@ -80,7 +80,7 @@ public: } std::unique_ptr make_Backend (Parameters const& parameters, - Scheduler& scheduler, Journal journal) + Scheduler& scheduler, beast::Journal journal) { std::unique_ptr backend; @@ -109,7 +109,7 @@ public: } std::unique_ptr make_Database (std::string const& name, - Scheduler& scheduler, Journal journal, int readThreads, + Scheduler& scheduler, beast::Journal journal, int readThreads, Parameters const& backendParameters, Parameters fastBackendParameters) { diff --git a/src/ripple_core/nodestore/tests/BackendTests.cpp b/src/ripple_core/nodestore/tests/BackendTests.cpp index 9c870bbcc6..1e62bc9489 100644 --- a/src/ripple_core/nodestore/tests/BackendTests.cpp +++ b/src/ripple_core/nodestore/tests/BackendTests.cpp @@ -25,16 +25,17 @@ namespace NodeStore { class BackendTests : public TestBase { public: - void testBackend (String type, int64 const seedValue, int numObjectsToTest = 2000) + void testBackend (beast::String type, beast::int64 const seedValue, + int numObjectsToTest = 2000) { std::unique_ptr manager (make_Manager ()); DummyScheduler scheduler; - beginTestCase (String ("Backend type=") + type); + beginTestCase (beast::String ("Backend type=") + type); - StringPairArray params; - File const path (File::createTempFile ("node_db")); + beast::StringPairArray params; + beast::File const path (beast::File::createTempFile ("node_db")); params.set ("type", type); params.set ("path", path.getFullPathName ()); @@ -42,7 +43,7 @@ public: Batch batch; createPredictableBatch (batch, 0, numObjectsToTest, seedValue); - Journal j ((journal ())); + beast::Journal j ((journal ())); { // Open the backend @@ -62,7 +63,7 @@ public: { // Reorder and read the copy again Batch copy; - UnitTestUtilities::repeatableShuffle (batch.size (), batch, seedValue); + beast::UnitTestUtilities::repeatableShuffle (batch.size (), batch, seedValue); fetchCopyOfBatch (*backend, ©, batch); expect (areBatchesEqual (batch, copy), "Should be equal"); } diff --git a/src/ripple_core/nodestore/tests/BasicTests.cpp b/src/ripple_core/nodestore/tests/BasicTests.cpp index 16f90050c0..d6c3394a25 100644 --- a/src/ripple_core/nodestore/tests/BasicTests.cpp +++ b/src/ripple_core/nodestore/tests/BasicTests.cpp @@ -30,7 +30,7 @@ public: } // Make sure predictable object generation works! - void testBatches (int64 const seedValue) + void testBatches (beast::int64 const seedValue) { beginTestCase ("batch"); @@ -49,7 +49,7 @@ public: } // Checks encoding/decoding blobs - void testBlobs (int64 const seedValue) + void testBlobs (beast::int64 const seedValue) { beginTestCase ("encoding"); @@ -76,7 +76,7 @@ public: void runTest () { - int64 const seedValue = 50; + beast::int64 const seedValue = 50; testBatches (seedValue); diff --git a/src/ripple_core/nodestore/tests/DatabaseTests.cpp b/src/ripple_core/nodestore/tests/DatabaseTests.cpp index 758fcf2cbc..2de3bbdd70 100644 --- a/src/ripple_core/nodestore/tests/DatabaseTests.cpp +++ b/src/ripple_core/nodestore/tests/DatabaseTests.cpp @@ -34,14 +34,14 @@ public: //-------------------------------------------------------------------------- - void testImport (String destBackendType, String srcBackendType, int64 seedValue) + void testImport (beast::String destBackendType, beast::String srcBackendType, beast::int64 seedValue) { std::unique_ptr manager (make_Manager ()); DummyScheduler scheduler; - File const node_db (File::createTempFile ("node_db")); - StringPairArray srcParams; + beast::File const node_db (beast::File::createTempFile ("node_db")); + beast::StringPairArray srcParams; srcParams.set ("type", srcBackendType); srcParams.set ("path", node_db.getFullPathName ()); @@ -49,7 +49,7 @@ public: Batch batch; createPredictableBatch (batch, 0, numObjectsToTest, seedValue); - Journal j ((journal ())); + beast::Journal j ((journal ())); // Write to source db { @@ -66,15 +66,15 @@ public: "test", scheduler, j, 2, srcParams)); // Set up the destination database - File const dest_db (File::createTempFile ("dest_db")); - StringPairArray destParams; + beast::File const dest_db (beast::File::createTempFile ("dest_db")); + beast::StringPairArray destParams; destParams.set ("type", destBackendType); destParams.set ("path", dest_db.getFullPathName ()); std::unique_ptr dest (manager->make_Database ( "test", scheduler, j, 2, destParams)); - beginTestCase (String ("import into '") + destBackendType + "' from '" + srcBackendType + "'"); + beginTestCase (beast::String ("import into '") + destBackendType + "' from '" + srcBackendType + "'"); // Do the import dest->import (*src); @@ -91,30 +91,30 @@ public: //-------------------------------------------------------------------------- - void testNodeStore (String type, + void testNodeStore (beast::String type, bool const useEphemeralDatabase, bool const testPersistence, - int64 const seedValue, + beast::int64 const seedValue, int numObjectsToTest = 2000) { std::unique_ptr manager (make_Manager ()); DummyScheduler scheduler; - String s; - s << String ("NodeStore backend '") + type + "'"; + beast::String s; + s << beast::String ("NodeStore backend '") + type + "'"; if (useEphemeralDatabase) s << " (with ephemeral database)"; beginTestCase (s); - File const node_db (File::createTempFile ("node_db")); - StringPairArray nodeParams; + beast::File const node_db (beast::File::createTempFile ("node_db")); + beast::StringPairArray nodeParams; nodeParams.set ("type", type); nodeParams.set ("path", node_db.getFullPathName ()); - File const temp_db (File::createTempFile ("temp_db")); - StringPairArray tempParams; + beast::File const temp_db (beast::File::createTempFile ("temp_db")); + beast::StringPairArray tempParams; if (useEphemeralDatabase) { tempParams.set ("type", type); @@ -125,7 +125,7 @@ public: Batch batch; createPredictableBatch (batch, 0, numObjectsToTest, seedValue); - Journal j ((journal ())); + beast::Journal j ((journal ())); { // Open the database @@ -145,7 +145,7 @@ public: { // Reorder and read the copy again Batch copy; - UnitTestUtilities::repeatableShuffle (batch.size (), batch, seedValue); + beast::UnitTestUtilities::repeatableShuffle (batch.size (), batch, seedValue); fetchCopyOfBatch (*db, ©, batch); expect (areBatchesEqual (batch, copy), "Should be equal"); } @@ -172,7 +172,7 @@ public: { // Verify the ephemeral db std::unique_ptr db (manager->make_Database ("test", - scheduler, j, 2, tempParams, StringPairArray ())); + scheduler, j, 2, tempParams, beast::StringPairArray ())); // Read it back in Batch copy; @@ -188,7 +188,7 @@ public: //-------------------------------------------------------------------------- - void runBackendTests (bool useEphemeralDatabase, int64 const seedValue) + void runBackendTests (bool useEphemeralDatabase, beast::int64 const seedValue) { testNodeStore ("leveldb", useEphemeralDatabase, true, seedValue); @@ -207,7 +207,7 @@ public: //-------------------------------------------------------------------------- - void runImportTests (int64 const seedValue) + void runImportTests (beast::int64 const seedValue) { testImport ("leveldb", "leveldb", seedValue); @@ -228,7 +228,7 @@ public: void runTest () { - int64 const seedValue = 50; + beast::int64 const seedValue = 50; testNodeStore ("memory", false, false, seedValue); diff --git a/src/ripple_core/nodestore/tests/TestBase.h b/src/ripple_core/nodestore/tests/TestBase.h index c9e70ecb8b..14e61ad1d5 100644 --- a/src/ripple_core/nodestore/tests/TestBase.h +++ b/src/ripple_core/nodestore/tests/TestBase.h @@ -25,7 +25,7 @@ namespace NodeStore { // Some common code for the unit tests // -class TestBase : public UnitTest +class TestBase : public beast::UnitTest { public: // Tunable parameters @@ -40,14 +40,14 @@ public: class PredictableObjectFactory { public: - explicit PredictableObjectFactory (int64 seedValue) + explicit PredictableObjectFactory (beast::int64 seedValue) : m_seedValue (seedValue) { } NodeObject::Ptr createObject (int index) { - Random r (m_seedValue + index); + beast::Random r (m_seedValue + index); NodeObjectType type; switch (r.nextInt (4)) @@ -76,12 +76,13 @@ public: } private: - int64 const m_seedValue; + beast::int64 const m_seedValue; }; public: // Create a predictable batch of objects - static void createPredictableBatch (Batch& batch, int startingIndex, int numObjects, int64 seedValue) + static void createPredictableBatch (Batch& batch, int startingIndex, + int numObjects, beast::int64 seedValue) { batch.reserve (numObjects); @@ -181,8 +182,8 @@ public: } } - TestBase (String name, UnitTest::When when = UnitTest::runNormal) - : UnitTest (name, "ripple", when) + TestBase (beast::String name, beast::UnitTest::When when = beast::UnitTest::runNormal) + : beast::UnitTest (name, "ripple", when) { } }; diff --git a/src/ripple_core/nodestore/tests/TimingTests.cpp b/src/ripple_core/nodestore/tests/TimingTests.cpp index 8827598e0b..634b768be8 100644 --- a/src/ripple_core/nodestore/tests/TimingTests.cpp +++ b/src/ripple_core/nodestore/tests/TimingTests.cpp @@ -42,34 +42,34 @@ public: void start () { - m_startTime = Time::getHighResolutionTicks (); + m_startTime = beast::Time::getHighResolutionTicks (); } double getElapsed () { - int64 const now = Time::getHighResolutionTicks(); + beast::int64 const now = beast::Time::getHighResolutionTicks(); - return Time::highResolutionTicksToSeconds (now - m_startTime); + return beast::Time::highResolutionTicksToSeconds (now - m_startTime); } private: - int64 m_startTime; + beast::int64 m_startTime; }; //-------------------------------------------------------------------------- - void testBackend (String type, int64 const seedValue) + void testBackend (beast::String type, beast::int64 const seedValue) { std::unique_ptr manager (make_Manager ()); DummyScheduler scheduler; - String s; + beast::String s; s << "Testing backend '" << type << "' performance"; beginTestCase (s); - StringPairArray params; - File const path (File::createTempFile ("node_db")); + beast::StringPairArray params; + beast::File const path (beast::File::createTempFile ("node_db")); params.set ("type", type); params.set ("path", path.getFullPathName ()); @@ -79,7 +79,7 @@ public: NodeStore::Batch batch2; createPredictableBatch (batch2, 0, numObjectsToTest, seedValue); - Journal j ((journal ())); + beast::Journal j ((journal ())); // Open the backend std::unique_ptr backend (manager->make_Backend ( @@ -91,14 +91,14 @@ public: t.start (); storeBatch (*backend, batch1); s = ""; - s << " Single write: " << String (t.getElapsed (), 2) << " seconds"; + s << " Single write: " << beast::String (t.getElapsed (), 2) << " seconds"; logMessage (s); // Bulk write batch test t.start (); backend->storeBatch (batch2); s = ""; - s << " Batch write: " << String (t.getElapsed (), 2) << " seconds"; + s << " Batch write: " << beast::String (t.getElapsed (), 2) << " seconds"; logMessage (s); // Read test @@ -107,7 +107,7 @@ public: fetchCopyOfBatch (*backend, ©, batch1); fetchCopyOfBatch (*backend, ©, batch2); s = ""; - s << " Batch read: " << String (t.getElapsed (), 2) << " seconds"; + s << " Batch read: " << beast::String (t.getElapsed (), 2) << " seconds"; logMessage (s); } diff --git a/src/ripple_data/crypto/CKey.cpp b/src/ripple_data/crypto/CKey.cpp index 46aaac6cae..4e2ad62873 100644 --- a/src/ripple_data/crypto/CKey.cpp +++ b/src/ripple_data/crypto/CKey.cpp @@ -25,7 +25,7 @@ // VFALCO TODO move inlined stuff from CKey into here -class CKeyTests : public UnitTest +class CKeyTests : public beast::UnitTest { public: CKeyTests () : UnitTest ("CKey", "ripple") diff --git a/src/ripple_data/crypto/CKey.h b/src/ripple_data/crypto/CKey.h index b1040c14f8..93a5888e43 100644 --- a/src/ripple_data/crypto/CKey.h +++ b/src/ripple_data/crypto/CKey.h @@ -93,7 +93,7 @@ public: { pkey = EC_KEY_new_by_curve_name (NID_secp256k1); - if (pkey == NULL) + if (pkey == nullptr) throw key_error ("CKey::CKey() : EC_KEY_new_by_curve_name failed"); EC_KEY_set_conv_form (pkey, POINT_CONVERSION_COMPRESSED); @@ -105,7 +105,7 @@ public: { pkey = EC_KEY_dup (b.pkey); - if (pkey == NULL) + if (pkey == nullptr) throw key_error ("CKey::CKey(const CKey&) : EC_KEY_dup failed"); EC_KEY_set_conv_form (pkey, POINT_CONVERSION_COMPRESSED); @@ -159,14 +159,14 @@ public: assert (pkey); } - CKey (uint256 const& privateKey) : pkey (NULL), fSet (false) + CKey (uint256 const& privateKey) : pkey (nullptr), fSet (false) { // XXX Broken pkey is null. SetPrivateKeyU (privateKey); } #if 0 - CKey (const RippleAddress& masterKey, int keyNum, bool isPublic) : pkey (NULL), fSet (false) + CKey (const RippleAddress& masterKey, int keyNum, bool isPublic) : pkey (nullptr), fSet (false) { if (isPublic) SetPubSeq (masterKey, keyNum); @@ -202,7 +202,7 @@ public: { const BIGNUM* bn = EC_KEY_get0_private_key (pkey); - if (bn == NULL) + if (bn == nullptr) throw key_error ("CKey::GetPrivateKeyU: EC_KEY_get0_private_key failed"); privKey.zero (); @@ -212,7 +212,7 @@ public: bool SetPrivateKeyU (uint256 const& key, bool bThrow = false) { // XXX Broken if pkey is not set. - BIGNUM* bn = BN_bin2bn (key.begin (), key.size (), NULL); + BIGNUM* bn = BN_bin2bn (key.begin (), key.size (), nullptr); bool bSuccess = !!EC_KEY_set_private_key (pkey, bn); BN_clear_free (bn); @@ -253,7 +253,7 @@ public: Blob GetPubKey () const { - unsigned int nSize = i2o_ECPublicKey (pkey, NULL); + unsigned int nSize = i2o_ECPublicKey (pkey, nullptr); assert (nSize <= 33); if (!nSize) diff --git a/src/ripple_data/crypto/CKeyDeterministic.cpp b/src/ripple_data/crypto/CKeyDeterministic.cpp index cfa02f12b9..4043535c95 100644 --- a/src/ripple_data/crypto/CKeyDeterministic.cpp +++ b/src/ripple_data/crypto/CKeyDeterministic.cpp @@ -41,14 +41,14 @@ EC_KEY* CKey::GenerateRootDeterministicKey (const uint128& seed) { BN_CTX* ctx = BN_CTX_new (); - if (!ctx) return NULL; + if (!ctx) return nullptr; EC_KEY* pkey = EC_KEY_new_by_curve_name (NID_secp256k1); if (!pkey) { BN_CTX_free (ctx); - return NULL; + return nullptr; } EC_KEY_set_conv_form (pkey, POINT_CONVERSION_COMPRESSED); @@ -59,7 +59,7 @@ EC_KEY* CKey::GenerateRootDeterministicKey (const uint128& seed) { BN_CTX_free (ctx); EC_KEY_free (pkey); - return NULL; + return nullptr; } if (!EC_GROUP_get_order (EC_KEY_get0_group (pkey), order, ctx)) @@ -68,10 +68,10 @@ EC_KEY* CKey::GenerateRootDeterministicKey (const uint128& seed) BN_free (order); EC_KEY_free (pkey); BN_CTX_free (ctx); - return NULL; + return nullptr; } - BIGNUM* privKey = NULL; + BIGNUM* privKey = nullptr; int seq = 0; do @@ -84,7 +84,7 @@ EC_KEY* CKey::GenerateRootDeterministicKey (const uint128& seed) s.secureErase (); privKey = BN_bin2bn ((const unsigned char*) &root, sizeof (root), privKey); - if (privKey == NULL) + if (privKey == nullptr) { EC_KEY_free (pkey); BN_free (order); @@ -104,12 +104,12 @@ EC_KEY* CKey::GenerateRootDeterministicKey (const uint128& seed) EC_KEY_free (pkey); BN_clear_free (privKey); BN_CTX_free (ctx); - return NULL; + return nullptr; } EC_POINT* pubKey = EC_POINT_new (EC_KEY_get0_group (pkey)); - if (!EC_POINT_mul (EC_KEY_get0_group (pkey), pubKey, privKey, NULL, NULL, ctx)) + if (!EC_POINT_mul (EC_KEY_get0_group (pkey), pubKey, privKey, nullptr, nullptr, ctx)) { // compute the corresponding public key point assert (false); @@ -117,7 +117,7 @@ EC_KEY* CKey::GenerateRootDeterministicKey (const uint128& seed) EC_POINT_free (pubKey); EC_KEY_free (pkey); BN_CTX_free (ctx); - return NULL; + return nullptr; } BN_clear_free (privKey); @@ -128,7 +128,7 @@ EC_KEY* CKey::GenerateRootDeterministicKey (const uint128& seed) EC_POINT_free (pubKey); EC_KEY_free (pkey); BN_CTX_free (ctx); - return NULL; + return nullptr; } EC_POINT_free (pubKey); @@ -146,10 +146,10 @@ EC_KEY* CKey::GenerateRootDeterministicKey (const uint128& seed) // <-- root public generator in EC format EC_KEY* CKey::GenerateRootPubKey (BIGNUM* pubGenerator) { - if (pubGenerator == NULL) + if (pubGenerator == nullptr) { assert (false); - return NULL; + return nullptr; } EC_KEY* pkey = EC_KEY_new_by_curve_name (NID_secp256k1); @@ -157,19 +157,19 @@ EC_KEY* CKey::GenerateRootPubKey (BIGNUM* pubGenerator) if (!pkey) { BN_free (pubGenerator); - return NULL; + return nullptr; } EC_KEY_set_conv_form (pkey, POINT_CONVERSION_COMPRESSED); - EC_POINT* pubPoint = EC_POINT_bn2point (EC_KEY_get0_group (pkey), pubGenerator, NULL, NULL); + EC_POINT* pubPoint = EC_POINT_bn2point (EC_KEY_get0_group (pkey), pubGenerator, nullptr, nullptr); BN_free (pubGenerator); if (!pubPoint) { assert (false); EC_KEY_free (pkey); - return NULL; + return nullptr; } if (!EC_KEY_set_public_key (pkey, pubPoint)) @@ -177,7 +177,7 @@ EC_KEY* CKey::GenerateRootPubKey (BIGNUM* pubGenerator) assert (false); EC_POINT_free (pubPoint); EC_KEY_free (pkey); - return NULL; + return nullptr; } EC_POINT_free (pubPoint); @@ -189,7 +189,7 @@ EC_KEY* CKey::GenerateRootPubKey (BIGNUM* pubGenerator) static BIGNUM* makeHash (const RippleAddress& pubGen, int seq, BIGNUM* order) { int subSeq = 0; - BIGNUM* ret = NULL; + BIGNUM* ret = nullptr; do { @@ -201,7 +201,7 @@ static BIGNUM* makeHash (const RippleAddress& pubGen, int seq, BIGNUM* order) s.secureErase (); ret = BN_bin2bn ((const unsigned char*) &root, sizeof (root), ret); - if (!ret) return NULL; + if (!ret) return nullptr; } while (BN_is_zero (ret) || (BN_cmp (ret, order) >= 0)); @@ -252,7 +252,7 @@ EC_KEY* CKey::GeneratePublicDeterministicKey (const RippleAddress& pubGen, int s if (success) { // Calculate the corresponding public key. - EC_POINT_mul (EC_KEY_get0_group (pkey), newPoint, hash, NULL, NULL, ctx); + EC_POINT_mul (EC_KEY_get0_group (pkey), newPoint, hash, nullptr, nullptr, ctx); // Add the master public key and set. EC_POINT_add (EC_KEY_get0_group (pkey), newPoint, newPoint, rootPubKey, ctx); @@ -271,7 +271,7 @@ EC_KEY* CKey::GeneratePublicDeterministicKey (const RippleAddress& pubGen, int s if (pkey && !success) EC_KEY_free (pkey); - return success ? pkey : NULL; + return success ? pkey : nullptr; } EC_KEY* CKey::GeneratePrivateDeterministicKey (const RippleAddress& pubGen, uint256 const& u, int seq) @@ -286,25 +286,25 @@ EC_KEY* CKey::GeneratePrivateDeterministicKey (const RippleAddress& pubGen, cons // privateKey(n) = (rootPrivateKey + Hash(pubHash|seq)) % order BN_CTX* ctx = BN_CTX_new (); - if (ctx == NULL) return NULL; + if (ctx == nullptr) return nullptr; EC_KEY* pkey = EC_KEY_new_by_curve_name (NID_secp256k1); - if (pkey == NULL) + if (pkey == nullptr) { BN_CTX_free (ctx); - return NULL; + return nullptr; } EC_KEY_set_conv_form (pkey, POINT_CONVERSION_COMPRESSED); BIGNUM* order = BN_new (); - if (order == NULL) + if (order == nullptr) { BN_CTX_free (ctx); EC_KEY_free (pkey); - return NULL; + return nullptr; } if (!EC_GROUP_get_order (EC_KEY_get0_group (pkey), order, ctx)) @@ -312,18 +312,18 @@ EC_KEY* CKey::GeneratePrivateDeterministicKey (const RippleAddress& pubGen, cons BN_free (order); BN_CTX_free (ctx); EC_KEY_free (pkey); - return NULL; + return nullptr; } // calculate the private additional key BIGNUM* privKey = makeHash (pubGen, seq, order); - if (privKey == NULL) + if (privKey == nullptr) { BN_free (order); BN_CTX_free (ctx); EC_KEY_free (pkey); - return NULL; + return nullptr; } // calculate the final private key @@ -339,16 +339,16 @@ EC_KEY* CKey::GeneratePrivateDeterministicKey (const RippleAddress& pubGen, cons BN_clear_free (privKey); BN_CTX_free (ctx); EC_KEY_free (pkey); - return NULL; + return nullptr; } - if (EC_POINT_mul (EC_KEY_get0_group (pkey), pubKey, privKey, NULL, NULL, ctx) == 0) + if (EC_POINT_mul (EC_KEY_get0_group (pkey), pubKey, privKey, nullptr, nullptr, ctx) == 0) { BN_clear_free (privKey); EC_POINT_free (pubKey); EC_KEY_free (pkey); BN_CTX_free (ctx); - return NULL; + return nullptr; } BN_clear_free (privKey); diff --git a/src/ripple_data/crypto/CKeyECIES.cpp b/src/ripple_data/crypto/CKeyECIES.cpp index 30d45d9895..588864cd22 100644 --- a/src/ripple_data/crypto/CKeyECIES.cpp +++ b/src/ripple_data/crypto/CKeyECIES.cpp @@ -77,7 +77,7 @@ void CKey::getECIESSecret (CKey& otherKey, ECIES_ENC_KEY_TYPE& enc_key, ECIES_HM else throw std::runtime_error ("no private key"); unsigned char rawbuf[512]; - int buflen = ECDH_compute_key (rawbuf, 512, EC_KEY_get0_public_key (pubkey), privkey, NULL); + int buflen = ECDH_compute_key (rawbuf, 512, EC_KEY_get0_public_key (pubkey), privkey, nullptr); if (buflen < ECIES_MIN_SEC) throw std::runtime_error ("ecdh key failed"); @@ -97,7 +97,7 @@ static ECIES_HMAC_TYPE makeHMAC (const ECIES_HMAC_KEY_TYPE& secret, Blob const& HMAC_CTX ctx; HMAC_CTX_init (&ctx); - if (HMAC_Init_ex (&ctx, secret.begin (), ECIES_HMAC_KEY_SIZE, ECIES_HMAC_ALGO, NULL) != 1) + if (HMAC_Init_ex (&ctx, secret.begin (), ECIES_HMAC_KEY_SIZE, ECIES_HMAC_ALGO, nullptr) != 1) { HMAC_CTX_cleanup (&ctx); throw std::runtime_error ("init hmac"); @@ -140,7 +140,7 @@ Blob CKey::encryptECIES (CKey& otherKey, Blob const& plaintext) EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX_init (&ctx); - if (EVP_EncryptInit_ex (&ctx, ECIES_ENC_ALGO, NULL, secret.begin (), iv.begin ()) != 1) + if (EVP_EncryptInit_ex (&ctx, ECIES_ENC_ALGO, nullptr, secret.begin (), iv.begin ()) != 1) { EVP_CIPHER_CTX_cleanup (&ctx); secret.zero (); @@ -217,7 +217,7 @@ Blob CKey::decryptECIES (CKey& otherKey, Blob const& ciphertext) ECIES_HMAC_KEY_TYPE hmacKey; getECIESSecret (otherKey, secret, hmacKey); - if (EVP_DecryptInit_ex (&ctx, ECIES_ENC_ALGO, NULL, secret.begin (), iv.begin ()) != 1) + if (EVP_DecryptInit_ex (&ctx, ECIES_ENC_ALGO, nullptr, secret.begin (), iv.begin ()) != 1) { secret.zero (); hmacKey.zero (); diff --git a/src/ripple_data/crypto/RFC1751.cpp b/src/ripple_data/crypto/RFC1751.cpp index 71201ca58e..72200d7e7a 100644 --- a/src/ripple_data/crypto/RFC1751.cpp +++ b/src/ripple_data/crypto/RFC1751.cpp @@ -483,11 +483,11 @@ void RFC1751::getEnglishFromKey (std::string& strHuman, const std::string& strKe strHuman = strFirst + " " + strSecond; } -String RFC1751::getWordFromBlob (void const* data, size_t bytes) +beast::String RFC1751::getWordFromBlob (void const* data, size_t bytes) { - uint32 hash; + beast::uint32 hash; - Murmur::Hash (data, bytes, 0, &hash); + beast::Murmur::Hash (data, bytes, 0, &hash); return s_dictionary [hash % (sizeof (s_dictionary) / sizeof (s_dictionary [0]))]; } diff --git a/src/ripple_data/crypto/RFC1751.h b/src/ripple_data/crypto/RFC1751.h index abbdb6ffd3..cb235bb898 100644 --- a/src/ripple_data/crypto/RFC1751.h +++ b/src/ripple_data/crypto/RFC1751.h @@ -34,7 +34,7 @@ public: it to turn the pubkey_node into an easily remembered and identified 4 character string. */ - static String getWordFromBlob (void const* data, size_t bytes); + static beast::String getWordFromBlob (void const* data, size_t bytes); private: static unsigned long extract (char* s, int start, int length); diff --git a/src/ripple_data/protocol/BuildInfo.cpp b/src/ripple_data/protocol/BuildInfo.cpp index 59a1cb0299..44f08d6775 100644 --- a/src/ripple_data/protocol/BuildInfo.cpp +++ b/src/ripple_data/protocol/BuildInfo.cpp @@ -77,23 +77,23 @@ BuildInfo::Protocol const& BuildInfo::getMinimumProtocol () // //------------------------------------------------------------------------------ -String const& BuildInfo::getVersionString () +beast::String const& BuildInfo::getVersionString () { struct SanityChecker { SanityChecker () { - SemanticVersion v; + beast::SemanticVersion v; char const* const rawText = getRawVersionString (); if (! v.parse (rawText) || v.print () != rawText) - FatalError ("Bad server version string", __FILE__, __LINE__); + beast::FatalError ("Bad server version string", __FILE__, __LINE__); versionString = rawText; } - String versionString; + beast::String versionString; }; static SanityChecker value; @@ -107,7 +107,7 @@ char const* BuildInfo::getFullVersionString () { PrettyPrinter () { - String s; + beast::String s; s << "Ripple-" << getVersionString (); @@ -149,19 +149,19 @@ BuildInfo::Protocol::PackedFormat BuildInfo::Protocol::toPacked () const noexcep std::string BuildInfo::Protocol::toStdString () const noexcept { - String s; + beast::String s; - s << String (vmajor) << "." << String (vminor); + s << beast::String (vmajor) << "." << beast::String (vminor); return s.toStdString (); } //------------------------------------------------------------------------------ -class BuildInfoTests : public UnitTest +class BuildInfoTests : public beast::UnitTest { public: - BuildInfoTests () : UnitTest ("BuildInfo", "ripple", runStartup) + BuildInfoTests () : beast::UnitTest ("BuildInfo", "ripple", runStartup) { } @@ -169,7 +169,7 @@ public: { beginTestCase ("version"); - SemanticVersion v; + beast::SemanticVersion v; expect (v.parse (BuildInfo::getRawVersionString ())); } diff --git a/src/ripple_data/protocol/BuildInfo.h b/src/ripple_data/protocol/BuildInfo.h index 5feecb3e57..caaf97a9f1 100644 --- a/src/ripple_data/protocol/BuildInfo.h +++ b/src/ripple_data/protocol/BuildInfo.h @@ -29,7 +29,7 @@ struct BuildInfo http://semver.org/ */ - static String const& getVersionString (); + static beast::String const& getVersionString (); /** Full server version string. @@ -53,7 +53,7 @@ struct BuildInfo //---- /** The serialized format of the protocol version. */ - typedef uint32 PackedFormat; + typedef beast::uint32 PackedFormat; Protocol (); Protocol (unsigned short vmajor, unsigned short vminor); diff --git a/src/ripple_data/protocol/FieldNames.cpp b/src/ripple_data/protocol/FieldNames.cpp index 63d2c8aea8..6b5cde066c 100644 --- a/src/ripple_data/protocol/FieldNames.cpp +++ b/src/ripple_data/protocol/FieldNames.cpp @@ -63,7 +63,8 @@ SField::SField (SerializedTypeID tid, int fv) : fieldCode (FIELD_CODE (tid, fv)) fieldMeta (sMD_Default), fieldNum (++num), signingField (true) { // call with the map mutex - fieldName = lexicalCast (tid) + "/" + lexicalCast (fv); + fieldName = beast::lexicalCast (tid) + "/" + + beast::lexicalCast (fv); codeToField[fieldCode] = this; assert ((fv != 1) || ((tid != STI_ARRAY) && (tid != STI_OBJECT))); } @@ -128,8 +129,8 @@ std::string SField::getName () const if (fieldValue == 0) return ""; - return lexicalCastThrow (static_cast (fieldType)) + "/" + - lexicalCastThrow (fieldValue); + return beast::lexicalCastThrow (static_cast (fieldType)) + "/" + + beast::lexicalCastThrow (fieldValue); } SField::ref SField::getField (const std::string& fieldName) diff --git a/src/ripple_data/protocol/HashPrefix.h b/src/ripple_data/protocol/HashPrefix.h index a4d3229aa8..22e30bf852 100644 --- a/src/ripple_data/protocol/HashPrefix.h +++ b/src/ripple_data/protocol/HashPrefix.h @@ -38,7 +38,7 @@ class HashPrefix { private: - uint32 m_prefix; + beast::uint32 m_prefix; public: HashPrefix (char a, char b, char c) @@ -51,7 +51,7 @@ public: } /** Returns the hash prefix associated with this object */ - operator uint32 () const + operator beast::uint32 () const { return m_prefix; } diff --git a/src/ripple_data/protocol/KnownFormats.h b/src/ripple_data/protocol/KnownFormats.h index 7ea052c925..6259304de3 100644 --- a/src/ripple_data/protocol/KnownFormats.h +++ b/src/ripple_data/protocol/KnownFormats.h @@ -177,7 +177,7 @@ protected: virtual void addCommonFields (Item& item) = 0; private: - OwnedArray m_formats; + beast::OwnedArray m_formats; NameMap m_names; TypeMap m_types; }; diff --git a/src/ripple_data/protocol/LedgerFormats.cpp b/src/ripple_data/protocol/LedgerFormats.cpp index 1e871686e8..55b6918d05 100644 --- a/src/ripple_data/protocol/LedgerFormats.cpp +++ b/src/ripple_data/protocol/LedgerFormats.cpp @@ -129,5 +129,5 @@ void LedgerFormats::addCommonFields (Item& item) LedgerFormats* LedgerFormats::getInstance () { - return SharedSingleton ::getInstance (); + return beast::SharedSingleton ::getInstance (); } diff --git a/src/ripple_data/protocol/Protocol.h b/src/ripple_data/protocol/Protocol.h index 250ddc7d9c..de2cbfd017 100644 --- a/src/ripple_data/protocol/Protocol.h +++ b/src/ripple_data/protocol/Protocol.h @@ -44,9 +44,9 @@ struct Protocol /** A ledger index. */ // VFALCO TODO pick one. I like Index since its not an abbreviation -typedef uint32 LedgerIndex; +typedef beast::uint32 LedgerIndex; // VFALCO NOTE "LedgerSeq" appears in some SQL statement text -typedef uint32 LedgerSeq; +typedef beast::uint32 LedgerSeq; /** A transaction identifier. */ @@ -55,7 +55,7 @@ typedef uint256 TxID; /** A transaction index. */ -typedef uint32 TxSeq; // VFALCO NOTE Should read TxIndex or TxNum +typedef beast::uint32 TxSeq; // VFALCO NOTE Should read TxIndex or TxNum /** An account hash. diff --git a/src/ripple_data/protocol/RippleAddress.cpp b/src/ripple_data/protocol/RippleAddress.cpp index 10587a22e9..1be6602b73 100644 --- a/src/ripple_data/protocol/RippleAddress.cpp +++ b/src/ripple_data/protocol/RippleAddress.cpp @@ -671,7 +671,7 @@ BIGNUM* RippleAddress::getGeneratorBN () const throw std::runtime_error (str (boost::format ("bad source: %d") % int (nVersion))); } - BIGNUM* ret = BN_bin2bn (&vchData[0], vchData.size (), NULL); + BIGNUM* ret = BN_bin2bn (&vchData[0], vchData.size (), nullptr); assert (ret); return ret; } @@ -892,7 +892,7 @@ RippleAddress RippleAddress::createSeedGeneric (const std::string& strText) //------------------------------------------------------------------------------ -class RippleAddressTests : public UnitTest +class RippleAddressTests : public beast::UnitTest { public: RippleAddressTests () : UnitTest ("RippleAddress", "ripple") @@ -970,7 +970,7 @@ static RippleAddressTests rippleAddressTests; //------------------------------------------------------------------------------ -class RippleIdentifierTests : public UnitTest +class RippleIdentifierTests : public beast::UnitTest { public: void runTest () @@ -1032,7 +1032,7 @@ public: privateKey.to_string()); } - RippleIdentifierTests () : UnitTest ("RippleIdentifier", "ripple") + RippleIdentifierTests () : beast::UnitTest ("RippleIdentifier", "ripple") { } }; diff --git a/src/ripple_data/protocol/STAmount.cpp b/src/ripple_data/protocol/STAmount.cpp index 0725241daa..9dca339c4d 100644 --- a/src/ripple_data/protocol/STAmount.cpp +++ b/src/ripple_data/protocol/STAmount.cpp @@ -19,7 +19,7 @@ SETUP_LOG (STAmount) -uint64 STAmount::uRateOne = STAmount::getRate (STAmount (1), STAmount (1)); +beast::uint64 STAmount::uRateOne = STAmount::getRate (STAmount (1), STAmount (1)); bool STAmount::issuerFromString (uint160& uDstIssuer, const std::string& sIssuer) { @@ -197,7 +197,7 @@ STAmount::STAmount (SField::ref n, const Json::Value& v) { if (mIsNative) { - int64 val = lexicalCastThrow (value.asString ()); + beast::int64 val = beast::lexicalCastThrow (value.asString ()); if (val >= 0) mValue = val; @@ -295,13 +295,13 @@ bool STAmount::setValue (const std::string& sAmount) if (!smMatch[4].matched) // integer only { - mValue = lexicalCast (std::string (smMatch[2])); + mValue = beast::lexicalCast (std::string (smMatch[2])); mOffset = 0; } else { // integer and fraction - mValue = lexicalCast (smMatch[2] + smMatch[4]); + mValue = beast::lexicalCast (smMatch[2] + smMatch[4]); mOffset = - (smMatch[4].length ()); } @@ -309,9 +309,9 @@ bool STAmount::setValue (const std::string& sAmount) { // we have an exponent if (smMatch[6].matched && (smMatch[6] == "-")) - mOffset -= lexicalCast (std::string (smMatch[7])); + mOffset -= beast::lexicalCast (std::string (smMatch[7])); else - mOffset += lexicalCast (std::string (smMatch[7])); + mOffset += beast::lexicalCast (std::string (smMatch[7])); } } catch (...) @@ -483,20 +483,20 @@ void STAmount::add (Serializer& s) const if (isZero ()) s.add64 (cNotNative); else if (mIsNegative) // 512 = not native - s.add64 (mValue | (static_cast (mOffset + 512 + 97) << (64 - 10))); + s.add64 (mValue | (static_cast (mOffset + 512 + 97) << (64 - 10))); else // 256 = positive - s.add64 (mValue | (static_cast (mOffset + 512 + 256 + 97) << (64 - 10))); + s.add64 (mValue | (static_cast (mOffset + 512 + 256 + 97) << (64 - 10))); s.add160 (mCurrency); s.add160 (mIssuer); } } -STAmount STAmount::createFromInt64 (SField::ref name, int64 value) +STAmount STAmount::createFromInt64 (SField::ref name, beast::int64 value) { return value >= 0 - ? STAmount (name, static_cast (value), false) - : STAmount (name, static_cast (-value), true); + ? STAmount (name, static_cast (value), false) + : STAmount (name, static_cast (-value), true); } void STAmount::setValue (const STAmount& a) @@ -536,7 +536,7 @@ int STAmount::compare (const STAmount& a) const STAmount* STAmount::construct (SerializerIterator& sit, SField::ref name) { - uint64 value = sit.get64 (); + beast::uint64 value = sit.get64 (); if ((value & cNotNative) == 0) { @@ -576,29 +576,29 @@ STAmount* STAmount::construct (SerializerIterator& sit, SField::ref name) return new STAmount (name, uCurrencyID, uIssuerID); } -int64 STAmount::getSNValue () const +beast::int64 STAmount::getSNValue () const { // signed native value if (!mIsNative) throw std::runtime_error ("not native"); - if (mIsNegative) return - static_cast (mValue); + if (mIsNegative) return - static_cast (mValue); - return static_cast (mValue); + return static_cast (mValue); } -void STAmount::setSNValue (int64 v) +void STAmount::setSNValue (beast::int64 v) { if (!mIsNative) throw std::runtime_error ("not native"); if (v > 0) { mIsNegative = false; - mValue = static_cast (v); + mValue = static_cast (v); } else { mIsNegative = true; - mValue = static_cast (-v); + mValue = static_cast (-v); } } @@ -609,15 +609,15 @@ std::string STAmount::getRaw () const if (mIsNative) { - if (mIsNegative) return std::string ("-") + lexicalCast (mValue); - else return lexicalCast (mValue); + if (mIsNegative) return std::string ("-") + beast::lexicalCast (mValue); + else return beast::lexicalCast (mValue); } if (mIsNegative) return mCurrency.GetHex () + ": -" + - lexicalCast (mValue) + "e" + lexicalCast (mOffset); + beast::lexicalCast (mValue) + "e" + beast::lexicalCast (mOffset); else return mCurrency.GetHex () + ": " + - lexicalCast (mValue) + "e" + lexicalCast (mOffset); + beast::lexicalCast (mValue) + "e" + beast::lexicalCast (mOffset); } std::string STAmount::getText () const @@ -628,21 +628,21 @@ std::string STAmount::getText () const if (mIsNative) { if (mIsNegative) - return std::string ("-") + lexicalCast (mValue); - else return lexicalCast (mValue); + return std::string ("-") + beast::lexicalCast (mValue); + else return beast::lexicalCast (mValue); } if ((mOffset != 0) && ((mOffset < -25) || (mOffset > -5))) { if (mIsNegative) - return std::string ("-") + lexicalCast (mValue) + - "e" + lexicalCast (mOffset); + return std::string ("-") + beast::lexicalCast (mValue) + + "e" + beast::lexicalCast (mOffset); else - return lexicalCast (mValue) + "e" + lexicalCast (mOffset); + return beast::lexicalCast (mValue) + "e" + beast::lexicalCast (mOffset); } std::string val = "000000000000000000000000000"; - val += lexicalCast (mValue); + val += beast::lexicalCast (mValue); val += "00000000000000000000000"; std::string pre = val.substr (0, mOffset + 43); @@ -744,7 +744,7 @@ STAmount STAmount::operator- (void) const return STAmount (getFName (), mCurrency, mIssuer, mValue, mOffset, mIsNative, !mIsNegative); } -STAmount& STAmount::operator= (uint64 v) +STAmount& STAmount::operator= (beast::uint64 v) { // does not copy name, does not change currency type mOffset = 0; @@ -756,52 +756,52 @@ STAmount& STAmount::operator= (uint64 v) return *this; } -STAmount& STAmount::operator+= (uint64 v) +STAmount& STAmount::operator+= (beast::uint64 v) { if (mIsNative) - setSNValue (getSNValue () + static_cast (v)); + setSNValue (getSNValue () + static_cast (v)); else *this += STAmount (mCurrency, v); return *this; } -STAmount& STAmount::operator-= (uint64 v) +STAmount& STAmount::operator-= (beast::uint64 v) { if (mIsNative) - setSNValue (getSNValue () - static_cast (v)); + setSNValue (getSNValue () - static_cast (v)); else *this -= STAmount (mCurrency, v); return *this; } -bool STAmount::operator< (uint64 v) const +bool STAmount::operator< (beast::uint64 v) const { - return getSNValue () < static_cast (v); + return getSNValue () < static_cast (v); } -bool STAmount::operator> (uint64 v) const +bool STAmount::operator> (beast::uint64 v) const { - return getSNValue () > static_cast (v); + return getSNValue () > static_cast (v); } -bool STAmount::operator<= (uint64 v) const +bool STAmount::operator<= (beast::uint64 v) const { - return getSNValue () <= static_cast (v); + return getSNValue () <= static_cast (v); } -bool STAmount::operator>= (uint64 v) const +bool STAmount::operator>= (beast::uint64 v) const { - return getSNValue () >= static_cast (v); + return getSNValue () >= static_cast (v); } -STAmount STAmount::operator+ (uint64 v) const +STAmount STAmount::operator+ (beast::uint64 v) const { - return STAmount (getFName (), getSNValue () + static_cast (v)); + return STAmount (getFName (), getSNValue () + static_cast (v)); } -STAmount STAmount::operator- (uint64 v) const +STAmount STAmount::operator- (beast::uint64 v) const { - return STAmount (getFName (), getSNValue () - static_cast (v)); + return STAmount (getFName (), getSNValue () - static_cast (v)); } STAmount::operator double () const @@ -831,7 +831,7 @@ STAmount operator+ (const STAmount& v1, const STAmount& v2) return STAmount (v1.getFName (), v1.getSNValue () + v2.getSNValue ()); int ov1 = v1.mOffset, ov2 = v2.mOffset; - int64 vv1 = static_cast (v1.mValue), vv2 = static_cast (v2.mValue); + beast::int64 vv1 = static_cast (v1.mValue), vv2 = static_cast (v2.mValue); if (v1.mIsNegative) vv1 = -vv1; @@ -849,9 +849,9 @@ STAmount operator+ (const STAmount& v1, const STAmount& v2) ++ov2; } - // this addition cannot overflow an int64, it can overflow an STAmount and the constructor will throw + // this addition cannot overflow an beast::int64, it can overflow an STAmount and the constructor will throw - int64 fv = vv1 + vv2; + beast::int64 fv = vv1 + vv2; if ((fv >= -10) && (fv <= 10)) return STAmount (v1.getFName (), v1.mCurrency, v1.mIssuer); @@ -874,7 +874,7 @@ STAmount operator- (const STAmount& v1, const STAmount& v2) } int ov1 = v1.mOffset, ov2 = v2.mOffset; - int64 vv1 = static_cast (v1.mValue), vv2 = static_cast (v2.mValue); + beast::int64 vv1 = static_cast (v1.mValue), vv2 = static_cast (v2.mValue); if (v1.mIsNegative) vv1 = -vv1; @@ -892,9 +892,9 @@ STAmount operator- (const STAmount& v1, const STAmount& v2) ++ov2; } - // this subtraction cannot overflow an int64, it can overflow an STAmount and the constructor will throw + // this subtraction cannot overflow an beast::int64, it can overflow an STAmount and the constructor will throw - int64 fv = vv1 - vv2; + beast::int64 fv = vv1 - vv2; if ((fv >= -10) && (fv <= 10)) return STAmount (v1.getFName (), v1.mCurrency, v1.mIssuer); @@ -912,7 +912,7 @@ STAmount STAmount::divide (const STAmount& num, const STAmount& den, const uint1 if (num.isZero ()) return STAmount (uCurrencyID, uIssuerID); - uint64 numVal = num.mValue, denVal = den.mValue; + beast::uint64 numVal = num.mValue, denVal = den.mValue; int numOffset = num.mOffset, denOffset = den.mOffset; if (num.mIsNative) @@ -935,7 +935,7 @@ STAmount STAmount::divide (const STAmount& num, const STAmount& den, const uint1 if ((BN_add_word64 (&v, numVal) != 1) || (BN_mul_word64 (&v, tenTo17) != 1) || - (BN_div_word64 (&v, denVal) == ((uint64) - 1))) + (BN_div_word64 (&v, denVal) == ((beast::uint64) - 1))) { throw std::runtime_error ("internal bn error"); } @@ -954,8 +954,8 @@ STAmount STAmount::multiply (const STAmount& v1, const STAmount& v2, const uint1 if (v1.mIsNative && v2.mIsNative && uCurrencyID.isZero ()) { - uint64 minV = (v1.getSNValue () < v2.getSNValue ()) ? v1.getSNValue () : v2.getSNValue (); - uint64 maxV = (v1.getSNValue () < v2.getSNValue ()) ? v2.getSNValue () : v1.getSNValue (); + beast::uint64 minV = (v1.getSNValue () < v2.getSNValue ()) ? v1.getSNValue () : v2.getSNValue (); + beast::uint64 maxV = (v1.getSNValue () < v2.getSNValue ()) ? v2.getSNValue () : v1.getSNValue (); if (minV > 3000000000ull) // sqrt(cMaxNative) throw std::runtime_error ("Native value overflow"); @@ -966,7 +966,7 @@ STAmount STAmount::multiply (const STAmount& v1, const STAmount& v2, const uint1 return STAmount (v1.getFName (), minV * maxV); } - uint64 value1 = v1.mValue, value2 = v2.mValue; + beast::uint64 value1 = v1.mValue, value2 = v2.mValue; int offset1 = v1.mOffset, offset2 = v2.mOffset; if (v1.mIsNative) @@ -993,7 +993,7 @@ STAmount STAmount::multiply (const STAmount& v1, const STAmount& v2, const uint1 if ((BN_add_word64 (&v, value1) != 1) || (BN_mul_word64 (&v, value2) != 1) || - (BN_div_word64 (&v, tenTo14) == ((uint64) - 1))) + (BN_div_word64 (&v, tenTo14) == ((beast::uint64) - 1))) { throw std::runtime_error ("internal bn error"); } @@ -1014,7 +1014,7 @@ STAmount STAmount::multiply (const STAmount& v1, const STAmount& v2, const uint1 // A lower rate is better for the person taking the order. // The taker gets more for less with a lower rate. // Zero is returned if the offer is worthless. -uint64 STAmount::getRate (const STAmount& offerOut, const STAmount& offerIn) +beast::uint64 STAmount::getRate (const STAmount& offerOut, const STAmount& offerIn) { if (offerOut.isZero ()) return 0; @@ -1028,7 +1028,7 @@ uint64 STAmount::getRate (const STAmount& offerOut, const STAmount& offerIn) assert ((r.getExponent () >= -100) && (r.getExponent () <= 155)); - uint64 ret = r.getExponent () + 100; + beast::uint64 ret = r.getExponent () + 100; return (ret << (64 - 8)) | r.getMantissa (); } @@ -1039,12 +1039,12 @@ uint64 STAmount::getRate (const STAmount& offerOut, const STAmount& offerIn) } } -STAmount STAmount::setRate (uint64 rate) +STAmount STAmount::setRate (beast::uint64 rate) { if (rate == 0) return STAmount (CURRENCY_ONE, ACCOUNT_ONE); - uint64 mantissa = rate & ~ (255ull << (64 - 8)); + beast::uint64 mantissa = rate & ~ (255ull << (64 - 8)); int exponent = static_cast (rate >> (64 - 8)) - 100; return STAmount (CURRENCY_ONE, ACCOUNT_ONE, mantissa, exponent); @@ -1078,7 +1078,7 @@ STAmount STAmount::setRate (uint64 rate) // <-- saOfferIssuerFee: Actual bool STAmount::applyOffer ( const bool bSell, - const uint32 uTakerPaysRate, const uint32 uOfferPaysRate, + const beast::uint32 uTakerPaysRate, const beast::uint32 uOfferPaysRate, const STAmount& saOfferRate, const STAmount& saOfferFunds, const STAmount& saTakerFunds, const STAmount& saOfferPays, const STAmount& saOfferGets, @@ -1258,7 +1258,7 @@ STAmount STAmount::getRound () const if (mIsNative) return *this; - uint64 valueDigits = mValue % 1000000000ull; + beast::uint64 valueDigits = mValue % 1000000000ull; if (valueDigits == 1) return STAmount (mCurrency, mIssuer, mValue - 1, mOffset, mIsNegative); @@ -1273,7 +1273,7 @@ void STAmount::roundSelf () if (mIsNative) return; - uint64 valueDigits = mValue % 1000000000ull; + beast::uint64 valueDigits = mValue % 1000000000ull; if (valueDigits == 1) { @@ -1318,10 +1318,10 @@ Json::Value STAmount::getJson (int) const //------------------------------------------------------------------------------ -class STAmountTests : public UnitTest +class STAmountTests : public beast::UnitTest { public: - STAmountTests () : UnitTest ("STAmount", "ripple") + STAmountTests () : beast::UnitTest ("STAmount", "ripple") { } @@ -1382,7 +1382,7 @@ public: expect (! prod1.isNative ()); - STAmount prod2 (CURRENCY_ONE, ACCOUNT_ONE, static_cast (a) * static_cast (b)); + STAmount prod2 (CURRENCY_ONE, ACCOUNT_ONE, static_cast (a) * static_cast (b)); if (prod1 != prod2) { @@ -1782,7 +1782,7 @@ public: for (int i = 0; i < 16; ++i) { - uint64 r = rand (); + beast::uint64 r = rand (); r <<= 32; r |= rand (); b.setuint64 (r); @@ -1855,22 +1855,22 @@ public: STAmount bigDsmall = STAmount::divide (smallValue, bigValue, CURRENCY_ONE, ACCOUNT_ONE); - expect (bigDsmall.isZero (), String ("small/big != 0: ") + bigDsmall.getText ()); + expect (bigDsmall.isZero (), beast::String ("small/big != 0: ") + bigDsmall.getText ()); bigDsmall = STAmount::divide (smallValue, bigNative, CURRENCY_ONE, uint160 ()); - expect (bigDsmall.isZero (), String ("small/bigNative != 0: ") + bigDsmall.getText ()); + expect (bigDsmall.isZero (), beast::String ("small/bigNative != 0: ") + bigDsmall.getText ()); bigDsmall = STAmount::divide (smallValue, bigValue, uint160 (), uint160 ()); - expect (bigDsmall.isZero (), String ("(small/big)->N != 0: ") + bigDsmall.getText ()); + expect (bigDsmall.isZero (), beast::String ("(small/big)->N != 0: ") + bigDsmall.getText ()); bigDsmall = STAmount::divide (smallValue, bigNative, uint160 (), uint160 ()); - expect (bigDsmall.isZero (), String ("(small/bigNative)->N != 0: ") + bigDsmall.getText ()); + expect (bigDsmall.isZero (), beast::String ("(small/bigNative)->N != 0: ") + bigDsmall.getText ()); // very bad offer - uint64 r = STAmount::getRate (smallValue, bigValue); + beast::uint64 r = STAmount::getRate (smallValue, bigValue); expect (r == 0, "getRate(smallOut/bigIn) != 0"); @@ -1890,7 +1890,7 @@ public: #if 0 beginTestCase ("rounding "); - uint64 value = 25000000000000000ull; + beast::uint64 value = 25000000000000000ull; int offset = -14; STAmount::canonicalizeRound (false, value, offset, true); diff --git a/src/ripple_data/protocol/STAmountRound.cpp b/src/ripple_data/protocol/STAmountRound.cpp index 6033de6719..751eee17d5 100644 --- a/src/ripple_data/protocol/STAmountRound.cpp +++ b/src/ripple_data/protocol/STAmountRound.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -void STAmount::canonicalizeRound (bool isNative, uint64& value, int& offset, bool roundUp) +void STAmount::canonicalizeRound (bool isNative, beast::uint64& value, int& offset, bool roundUp) { if (!roundUp) // canonicalize already rounds down return; @@ -72,7 +72,7 @@ STAmount STAmount::addRound (const STAmount& v1, const STAmount& v2, bool roundU return STAmount (v1.getFName (), v1.getSNValue () + v2.getSNValue ()); int ov1 = v1.mOffset, ov2 = v2.mOffset; - int64 vv1 = static_cast (v1.mValue), vv2 = static_cast (v2.mValue); + beast::int64 vv1 = static_cast (v1.mValue), vv2 = static_cast (v2.mValue); if (v1.mIsNegative) vv1 = -vv1; @@ -110,19 +110,19 @@ STAmount STAmount::addRound (const STAmount& v1, const STAmount& v2, bool roundU ++ov2; } - int64 fv = vv1 + vv2; + beast::int64 fv = vv1 + vv2; if ((fv >= -10) && (fv <= 10)) return STAmount (v1.getFName (), v1.mCurrency, v1.mIssuer); else if (fv >= 0) { - uint64 v = static_cast (fv); + beast::uint64 v = static_cast (fv); canonicalizeRound (false, v, ov1, roundUp); return STAmount (v1.getFName (), v1.mCurrency, v1.mIssuer, v, ov1, false); } else { - uint64 v = static_cast (-fv); + beast::uint64 v = static_cast (-fv); canonicalizeRound (false, v, ov1, !roundUp); return STAmount (v1.getFName (), v1.mCurrency, v1.mIssuer, v, ov1, true); } @@ -142,7 +142,7 @@ STAmount STAmount::subRound (const STAmount& v1, const STAmount& v2, bool roundU return STAmount (v1.getFName (), v1.getSNValue () - v2.getSNValue ()); int ov1 = v1.mOffset, ov2 = v2.mOffset; - int64 vv1 = static_cast (v1.mValue), vv2 = static_cast (v2.mValue); + beast::int64 vv1 = static_cast (v1.mValue), vv2 = static_cast (v2.mValue); if (v1.mIsNegative) vv1 = -vv1; @@ -180,19 +180,19 @@ STAmount STAmount::subRound (const STAmount& v1, const STAmount& v2, bool roundU ++ov2; } - int64 fv = vv1 + vv2; + beast::int64 fv = vv1 + vv2; if ((fv >= -10) && (fv <= 10)) return STAmount (v1.getFName (), v1.mCurrency, v1.mIssuer); else if (fv >= 0) { - uint64 v = static_cast (fv); + beast::uint64 v = static_cast (fv); canonicalizeRound (false, v, ov1, roundUp); return STAmount (v1.getFName (), v1.mCurrency, v1.mIssuer, v, ov1, false); } else { - uint64 v = static_cast (-fv); + beast::uint64 v = static_cast (-fv); canonicalizeRound (false, v, ov1, !roundUp); return STAmount (v1.getFName (), v1.mCurrency, v1.mIssuer, v, ov1, true); } @@ -206,8 +206,8 @@ STAmount STAmount::mulRound (const STAmount& v1, const STAmount& v2, if (v1.mIsNative && v2.mIsNative && uCurrencyID.isZero ()) { - uint64 minV = (v1.getSNValue () < v2.getSNValue ()) ? v1.getSNValue () : v2.getSNValue (); - uint64 maxV = (v1.getSNValue () < v2.getSNValue ()) ? v2.getSNValue () : v1.getSNValue (); + beast::uint64 minV = (v1.getSNValue () < v2.getSNValue ()) ? v1.getSNValue () : v2.getSNValue (); + beast::uint64 maxV = (v1.getSNValue () < v2.getSNValue ()) ? v2.getSNValue () : v1.getSNValue (); if (minV > 3000000000ull) // sqrt(cMaxNative) throw std::runtime_error ("Native value overflow"); @@ -218,7 +218,7 @@ STAmount STAmount::mulRound (const STAmount& v1, const STAmount& v2, return STAmount (v1.getFName (), minV * maxV); } - uint64 value1 = v1.mValue, value2 = v2.mValue; + beast::uint64 value1 = v1.mValue, value2 = v2.mValue; int offset1 = v1.mOffset, offset2 = v2.mOffset; if (v1.mIsNative) @@ -250,13 +250,13 @@ STAmount STAmount::mulRound (const STAmount& v1, const STAmount& v2, if (resultNegative != roundUp) // rounding down is automatic when we divide BN_add_word64 (&v, tenTo14m1); - if (BN_div_word64 (&v, tenTo14) == ((uint64) - 1)) + if (BN_div_word64 (&v, tenTo14) == ((beast::uint64) - 1)) throw std::runtime_error ("internal bn error"); // 10^16 <= product <= 10^18 assert (BN_num_bytes (&v) <= 64); - uint64 amount = v.getuint64 (); + beast::uint64 amount = v.getuint64 (); int offset = offset1 + offset2 + 14; canonicalizeRound (uCurrencyID.isZero (), amount, offset, resultNegative != roundUp); return STAmount (uCurrencyID, uIssuerID, amount, offset, resultNegative); @@ -271,7 +271,7 @@ STAmount STAmount::divRound (const STAmount& num, const STAmount& den, if (num.isZero ()) return STAmount (uCurrencyID, uIssuerID); - uint64 numVal = num.mValue, denVal = den.mValue; + beast::uint64 numVal = num.mValue, denVal = den.mValue; int numOffset = num.mOffset, denOffset = den.mOffset; if (num.mIsNative) @@ -299,13 +299,13 @@ STAmount STAmount::divRound (const STAmount& num, const STAmount& den, if (resultNegative != roundUp) // Rounding down is automatic when we divide BN_add_word64 (&v, denVal - 1); - if (BN_div_word64 (&v, denVal) == ((uint64) - 1)) + if (BN_div_word64 (&v, denVal) == ((beast::uint64) - 1)) throw std::runtime_error ("internal bn error"); // 10^16 <= quotient <= 10^18 assert (BN_num_bytes (&v) <= 64); - uint64 amount = v.getuint64 (); + beast::uint64 amount = v.getuint64 (); int offset = numOffset - denOffset - 17; canonicalizeRound (uCurrencyID.isZero (), amount, offset, resultNegative != roundUp); return STAmount (uCurrencyID, uIssuerID, amount, offset, resultNegative); diff --git a/src/ripple_data/protocol/STParsedJSON.cpp b/src/ripple_data/protocol/STParsedJSON.cpp index 130f2e4602..a96fb41598 100644 --- a/src/ripple_data/protocol/STParsedJSON.cpp +++ b/src/ripple_data/protocol/STParsedJSON.cpp @@ -192,7 +192,7 @@ bool STParsedJSON::parse (std::string const& json_name, findTypeByName (strValue)); data.push_back (new STUInt16 (field, - static_cast (txType))); + static_cast (txType))); if (*name == sfGeneric) name = &sfTransaction; @@ -203,7 +203,7 @@ bool STParsedJSON::parse (std::string const& json_name, findTypeByName (strValue)); data.push_back (new STUInt16 (field, - static_cast (type))); + static_cast (type))); if (*name == sfGeneric) name = &sfLedgerEntry; @@ -217,19 +217,19 @@ bool STParsedJSON::parse (std::string const& json_name, else { data.push_back (new STUInt16 (field, - lexicalCastThrow (strValue))); + beast::lexicalCastThrow (strValue))); } } else if (value.isInt ()) { data.push_back (new STUInt16 (field, - range_check_cast ( + range_check_cast ( value.asInt (), 0, 65535))); } else if (value.isUInt ()) { data.push_back (new STUInt16 (field, - range_check_cast ( + range_check_cast ( value.asUInt (), 0, 65535))); } else @@ -252,17 +252,17 @@ bool STParsedJSON::parse (std::string const& json_name, if (value.isString ()) { data.push_back (new STUInt32 (field, - lexicalCastThrow (value.asString ()))); + beast::lexicalCastThrow (value.asString ()))); } else if (value.isInt ()) { data.push_back (new STUInt32 (field, - range_check_cast (value.asInt (), 0u, 4294967295u))); + range_check_cast (value.asInt (), 0u, 4294967295u))); } else if (value.isUInt ()) { data.push_back (new STUInt32 (field, - static_cast (value.asUInt ()))); + static_cast (value.asUInt ()))); } else { @@ -289,13 +289,13 @@ bool STParsedJSON::parse (std::string const& json_name, else if (value.isInt ()) { data.push_back (new STUInt64 (field, - range_check_cast ( + range_check_cast ( value.asInt (), 0, 18446744073709551615ull))); } else if (value.isUInt ()) { data.push_back (new STUInt64 (field, - static_cast (value.asUInt ()))); + static_cast (value.asUInt ()))); } else { @@ -684,7 +684,7 @@ bool STParsedJSON::parse (std::string const& json_name, // first/only key in an object without copying all keys into // a vector std::string const objectName (value[i].getMemberNames()[0]);; - SField::ref const nameField (SField::getField(objectName)); + SField::ref nameField (SField::getField(objectName)); if (nameField == sfInvalid) { diff --git a/src/ripple_data/protocol/SerializedObject.cpp b/src/ripple_data/protocol/SerializedObject.cpp index f6d7590527..f90f516689 100644 --- a/src/ripple_data/protocol/SerializedObject.cpp +++ b/src/ripple_data/protocol/SerializedObject.cpp @@ -71,7 +71,7 @@ std::unique_ptr STObject::makeDefaultObject (SerializedTypeID id return std::unique_ptr (new STArray (name)); default: - WriteLog (lsFATAL, STObject) << "Object type: " << lexicalCast (id); + WriteLog (lsFATAL, STObject) << "Object type: " << beast::lexicalCast (id); assert (false); throw std::runtime_error ("Unknown object type"); } @@ -224,7 +224,7 @@ bool STObject::isValidForType () bool STObject::isFieldAllowed (SField::ref field) { - if (mType == NULL) + if (mType == nullptr) return true; return mType->getIndex (field) != -1; @@ -362,9 +362,9 @@ void STObject::add (Serializer& s, bool withSigningFields) const field->addFieldID (s); field->add (s); - if (dynamic_cast (field) != NULL) + if (dynamic_cast (field) != nullptr) s.addFieldID (STI_ARRAY, 1); - else if (dynamic_cast (field) != NULL) + else if (dynamic_cast (field) != nullptr) s.addFieldID (STI_OBJECT, 1); } } @@ -424,7 +424,7 @@ bool STObject::isEquivalent (const SerializedType& t) const return (it1 == end1) && (it2 == end2); } -uint256 STObject::getHash (uint32 prefix) const +uint256 STObject::getHash (beast::uint32 prefix) const { Serializer s; s.add32 (prefix); @@ -432,7 +432,7 @@ uint256 STObject::getHash (uint32 prefix) const return s.getSHA512Half (); } -uint256 STObject::getSigningHash (uint32 prefix) const +uint256 STObject::getSigningHash (beast::uint32 prefix) const { Serializer s; s.add32 (prefix); @@ -442,7 +442,7 @@ uint256 STObject::getSigningHash (uint32 prefix) const int STObject::getFieldIndex (SField::ref field) const { - if (mType != NULL) + if (mType != nullptr) return mType->getIndex (field); int i = 0; @@ -486,7 +486,7 @@ const SerializedType* STObject::peekAtPField (SField::ref field) const int index = getFieldIndex (field); if (index == -1) - return NULL; + return nullptr; return peekAtPIndex (index); } @@ -500,7 +500,7 @@ SerializedType* STObject::getPField (SField::ref field, bool createOkay) if (createOkay && isFree ()) return getPIndex (giveObject (makeDefaultObject (field))); - return NULL; + return nullptr; } return getPIndex (index); @@ -534,7 +534,7 @@ STObject& STObject::peekFieldObject (SField::ref field) return *cf; } -bool STObject::setFlag (uint32 f) +bool STObject::setFlag (beast::uint32 f) { STUInt32* t = dynamic_cast (getPField (sfFlags, true)); @@ -545,7 +545,7 @@ bool STObject::setFlag (uint32 f) return true; } -bool STObject::clearFlag (uint32 f) +bool STObject::clearFlag (beast::uint32 f) { STUInt32* t = dynamic_cast (getPField (sfFlags)); @@ -556,12 +556,12 @@ bool STObject::clearFlag (uint32 f) return true; } -bool STObject::isFlag (uint32 f) +bool STObject::isFlag (beast::uint32 f) { return (getFlags () & f) == f; } -uint32 STObject::getFlags (void) const +beast::uint32 STObject::getFlags (void) const { const STUInt32* t = dynamic_cast (peekAtPField (sfFlags)); @@ -649,7 +649,7 @@ unsigned char STObject::getFieldU8 (SField::ref field) const return cf->getValue (); } -uint16 STObject::getFieldU16 (SField::ref field) const +beast::uint16 STObject::getFieldU16 (SField::ref field) const { const SerializedType* rf = peekAtPField (field); @@ -666,7 +666,7 @@ uint16 STObject::getFieldU16 (SField::ref field) const return cf->getValue (); } -uint32 STObject::getFieldU32 (SField::ref field) const +beast::uint32 STObject::getFieldU32 (SField::ref field) const { const SerializedType* rf = peekAtPField (field); @@ -683,7 +683,7 @@ uint32 STObject::getFieldU32 (SField::ref field) const return cf->getValue (); } -uint64 STObject::getFieldU64 (SField::ref field) const +beast::uint64 STObject::getFieldU64 (SField::ref field) const { const SerializedType* rf = peekAtPField (field); @@ -902,7 +902,7 @@ void STObject::setFieldU8 (SField::ref field, unsigned char v) cf->setValue (v); } -void STObject::setFieldU16 (SField::ref field, uint16 v) +void STObject::setFieldU16 (SField::ref field, beast::uint16 v) { SerializedType* rf = getPField (field, true); @@ -917,7 +917,7 @@ void STObject::setFieldU16 (SField::ref field, uint16 v) cf->setValue (v); } -void STObject::setFieldU32 (SField::ref field, uint32 v) +void STObject::setFieldU32 (SField::ref field, beast::uint32 v) { SerializedType* rf = getPField (field, true); @@ -932,7 +932,7 @@ void STObject::setFieldU32 (SField::ref field, uint32 v) cf->setValue (v); } -void STObject::setFieldU64 (SField::ref field, uint64 v) +void STObject::setFieldU64 (SField::ref field, beast::uint64 v) { SerializedType* rf = getPField (field, true); @@ -1076,7 +1076,7 @@ Json::Value STObject::getJson (int options) const if (it.getSType () != STI_NOTPRESENT) { if (!it.getFName ().hasName ()) - ret[lexicalCast (index)] = it.getJson (options); + ret[beast::lexicalCast (index)] = it.getJson (options); else ret[it.getName ()] = it.getJson (options); } @@ -1185,7 +1185,7 @@ Json::Value STArray::getJson (int p) const Json::Value inner = Json::objectValue; if (!object.getFName ().hasName ()) - inner[lexicalCast (index)] = object.getJson (p); + inner[beast::lexicalCast (index)] = object.getJson (p); else inner[object.getName ()] = object.getJson (p); @@ -1253,10 +1253,10 @@ void STArray::sort (bool (*compare) (const STObject&, const STObject&)) //------------------------------------------------------------------------------ -class SerializedObjectTests : public UnitTest +class SerializedObjectTests : public beast::UnitTest { public: - SerializedObjectTests () : UnitTest ("SerializedObject", "ripple") + SerializedObjectTests () : beast::UnitTest ("SerializedObject", "ripple") { } diff --git a/src/ripple_data/protocol/SerializedObject.h b/src/ripple_data/protocol/SerializedObject.h index 4b4f113803..eb904420c7 100644 --- a/src/ripple_data/protocol/SerializedObject.h +++ b/src/ripple_data/protocol/SerializedObject.h @@ -29,12 +29,12 @@ class STObject public: static char const* getCountedObjectName () { return "STObject"; } - STObject () : mType (NULL) + STObject () : mType (nullptr) { ; } - explicit STObject (SField::ref name) : SerializedType (name), mType (NULL) + explicit STObject (SField::ref name) : SerializedType (name), mType (nullptr) { ; } @@ -50,7 +50,7 @@ public: setType (type); } - STObject (SField::ref name, boost::ptr_vector& data) : SerializedType (name), mType (NULL) + STObject (SField::ref name, boost::ptr_vector& data) : SerializedType (name), mType (nullptr) { mData.swap (data); } @@ -69,7 +69,7 @@ public: bool isFieldAllowed (SField::ref); bool isFree () const { - return mType == NULL; + return mType == nullptr; } void set (const SOTemplate&); @@ -150,13 +150,13 @@ public: return mData.size (); } - bool setFlag (uint32); - bool clearFlag (uint32); - bool isFlag(uint32); - uint32 getFlags () const; + bool setFlag (beast::uint32); + bool clearFlag (beast::uint32); + bool isFlag(beast::uint32); + beast::uint32 getFlags () const; - uint256 getHash (uint32 prefix) const; - uint256 getSigningHash (uint32 prefix) const; + uint256 getHash (beast::uint32 prefix) const; + uint256 getSigningHash (beast::uint32 prefix) const; const SerializedType& peekAtIndex (int offset) const { @@ -187,9 +187,9 @@ public: // field is optional but not present std::string getFieldString (SField::ref field) const; unsigned char getFieldU8 (SField::ref field) const; - uint16 getFieldU16 (SField::ref field) const; - uint32 getFieldU32 (SField::ref field) const; - uint64 getFieldU64 (SField::ref field) const; + beast::uint16 getFieldU16 (SField::ref field) const; + beast::uint32 getFieldU32 (SField::ref field) const; + beast::uint64 getFieldU64 (SField::ref field) const; uint128 getFieldH128 (SField::ref field) const; uint160 getFieldH160 (SField::ref field) const; uint256 getFieldH256 (SField::ref field) const; @@ -202,9 +202,9 @@ public: const STArray& getFieldArray (SField::ref field) const; void setFieldU8 (SField::ref field, unsigned char); - void setFieldU16 (SField::ref field, uint16); - void setFieldU32 (SField::ref field, uint32); - void setFieldU64 (SField::ref field, uint64); + void setFieldU16 (SField::ref field, beast::uint16); + void setFieldU32 (SField::ref field, beast::uint32); + void setFieldU64 (SField::ref field, beast::uint64); void setFieldH128 (SField::ref field, const uint128&); void setFieldH160 (SField::ref field, const uint160&); void setFieldH256 (SField::ref field, uint256 const& ); diff --git a/src/ripple_data/protocol/SerializedObjectTemplate.h b/src/ripple_data/protocol/SerializedObjectTemplate.h index b1aff7833c..54a645b0c5 100644 --- a/src/ripple_data/protocol/SerializedObjectTemplate.h +++ b/src/ripple_data/protocol/SerializedObjectTemplate.h @@ -40,7 +40,7 @@ enum SOE_Flags class SOElement { public: - SField::ref const e_field; + SField::ref e_field; SOE_Flags const flags; SOElement (SField::ref fieldName, SOE_Flags flags) diff --git a/src/ripple_data/protocol/SerializedTypes.cpp b/src/ripple_data/protocol/SerializedTypes.cpp index 34cf154f00..840ca2cf63 100644 --- a/src/ripple_data/protocol/SerializedTypes.cpp +++ b/src/ripple_data/protocol/SerializedTypes.cpp @@ -111,7 +111,7 @@ std::string STUInt8::getText () const return human; } - return lexicalCastThrow (value); + return beast::lexicalCastThrow (value); } Json::Value STUInt8::getJson (int) const @@ -160,7 +160,7 @@ std::string STUInt16::getText () const return item->getName (); } - return lexicalCastThrow (value); + return beast::lexicalCastThrow (value); } Json::Value STUInt16::getJson (int) const @@ -199,7 +199,7 @@ STUInt32* STUInt32::construct (SerializerIterator& u, SField::ref name) std::string STUInt32::getText () const { - return lexicalCastThrow (value); + return beast::lexicalCastThrow (value); } Json::Value STUInt32::getJson (int) const @@ -220,7 +220,7 @@ STUInt64* STUInt64::construct (SerializerIterator& u, SField::ref name) std::string STUInt64::getText () const { - return lexicalCastThrow (value); + return beast::lexicalCastThrow (value); } Json::Value STUInt64::getJson (int) const @@ -351,7 +351,7 @@ STVector256* STVector256::construct (SerializerIterator& u, SField::ref name) void STVector256::add (Serializer& s) const { - s.addVL (mValue.empty () ? NULL : mValue[0].begin (), mValue.size () * (256 / 8)); + s.addVL (mValue.empty () ? nullptr : mValue[0].begin (), mValue.size () * (256 / 8)); } bool STVector256::isEquivalent (const SerializedType& t) const diff --git a/src/ripple_data/protocol/SerializedTypes.h b/src/ripple_data/protocol/SerializedTypes.h index fea22fa5b9..d0609f5107 100644 --- a/src/ripple_data/protocol/SerializedTypes.h +++ b/src/ripple_data/protocol/SerializedTypes.h @@ -279,11 +279,11 @@ class STUInt16 : public SerializedType { public: - STUInt16 (uint16 v = 0) : value (v) + STUInt16 (beast::uint16 v = 0) : value (v) { ; } - STUInt16 (SField::ref n, uint16 v = 0) : SerializedType (n), value (v) + STUInt16 (SField::ref n, beast::uint16 v = 0) : SerializedType (n), value (v) { ; } @@ -303,16 +303,16 @@ public: s.add16 (value); } - uint16 getValue () const + beast::uint16 getValue () const { return value; } - void setValue (uint16 v) + void setValue (beast::uint16 v) { value = v; } - operator uint16 () const + operator beast::uint16 () const { return value; } @@ -323,7 +323,7 @@ public: } private: - uint16 value; + beast::uint16 value; STUInt16* duplicate () const { @@ -338,11 +338,11 @@ class STUInt32 : public SerializedType { public: - STUInt32 (uint32 v = 0) : value (v) + STUInt32 (beast::uint32 v = 0) : value (v) { ; } - STUInt32 (SField::ref n, uint32 v = 0) : SerializedType (n), value (v) + STUInt32 (SField::ref n, beast::uint32 v = 0) : SerializedType (n), value (v) { ; } @@ -362,16 +362,16 @@ public: s.add32 (value); } - uint32 getValue () const + beast::uint32 getValue () const { return value; } - void setValue (uint32 v) + void setValue (beast::uint32 v) { value = v; } - operator uint32 () const + operator beast::uint32 () const { return value; } @@ -382,7 +382,7 @@ public: } private: - uint32 value; + beast::uint32 value; STUInt32* duplicate () const { @@ -396,11 +396,11 @@ private: class STUInt64 : public SerializedType { public: - STUInt64 (uint64 v = 0) : value (v) + STUInt64 (beast::uint64 v = 0) : value (v) { ; } - STUInt64 (SField::ref n, uint64 v = 0) : SerializedType (n), value (v) + STUInt64 (SField::ref n, beast::uint64 v = 0) : SerializedType (n), value (v) { ; } @@ -420,16 +420,16 @@ public: s.add64 (value); } - uint64 getValue () const + beast::uint64 getValue () const { return value; } - void setValue (uint64 v) + void setValue (beast::uint64 v) { value = v; } - operator uint64 () const + operator beast::uint64 () const { return value; } @@ -440,7 +440,7 @@ public: } private: - uint64 value; + beast::uint64 value; STUInt64* duplicate () const { @@ -464,60 +464,60 @@ private: class STAmount : public SerializedType { public: - static const int cMinOffset = -96, cMaxOffset = 80; - static const uint64 cMinValue = 1000000000000000ull, cMaxValue = 9999999999999999ull; - static const uint64 cMaxNative = 9000000000000000000ull; - static const uint64 cMaxNativeN = 100000000000000000ull; // max native value on network - static const uint64 cNotNative = 0x8000000000000000ull; - static const uint64 cPosNative = 0x4000000000000000ull; + static const int cMinOffset = -96, cMaxOffset = 80; + static const beast::uint64 cMinValue = 1000000000000000ull, cMaxValue = 9999999999999999ull; + static const beast::uint64 cMaxNative = 9000000000000000000ull; + static const beast::uint64 cMaxNativeN = 100000000000000000ull; // max native value on network + static const beast::uint64 cNotNative = 0x8000000000000000ull; + static const beast::uint64 cPosNative = 0x4000000000000000ull; - static uint64 uRateOne; + static beast::uint64 uRateOne; - STAmount (uint64 v = 0, bool isNeg = false) : mValue (v), mOffset (0), mIsNative (true), mIsNegative (isNeg) + STAmount (beast::uint64 v = 0, bool isNeg = false) : mValue (v), mOffset (0), mIsNative (true), mIsNegative (isNeg) { if (v == 0) mIsNegative = false; } - STAmount (SField::ref n, uint64 v = 0, bool isNeg = false) + STAmount (SField::ref n, beast::uint64 v = 0, bool isNeg = false) : SerializedType (n), mValue (v), mOffset (0), mIsNative (true), mIsNegative (isNeg) { ; } - STAmount (SField::ref n, int64 v) : SerializedType (n), mOffset (0), mIsNative (true) + STAmount (SField::ref n, beast::int64 v) : SerializedType (n), mOffset (0), mIsNative (true) { set (v); } STAmount (const uint160& uCurrencyID, const uint160& uIssuerID, - uint64 uV = 0, int iOff = 0, bool bNegative = false) + beast::uint64 uV = 0, int iOff = 0, bool bNegative = false) : mCurrency (uCurrencyID), mIssuer (uIssuerID), mValue (uV), mOffset (iOff), mIsNegative (bNegative) { canonicalize (); } STAmount (const uint160& uCurrencyID, const uint160& uIssuerID, - uint32 uV, int iOff = 0, bool bNegative = false) + beast::uint32 uV, int iOff = 0, bool bNegative = false) : mCurrency (uCurrencyID), mIssuer (uIssuerID), mValue (uV), mOffset (iOff), mIsNegative (bNegative) { canonicalize (); } STAmount (SField::ref n, const uint160& currency, const uint160& issuer, - uint64 v = 0, int off = 0, bool isNeg = false) : + beast::uint64 v = 0, int off = 0, bool isNeg = false) : SerializedType (n), mCurrency (currency), mIssuer (issuer), mValue (v), mOffset (off), mIsNegative (isNeg) { canonicalize (); } - STAmount (const uint160& uCurrencyID, const uint160& uIssuerID, int64 v, int iOff = 0) + STAmount (const uint160& uCurrencyID, const uint160& uIssuerID, beast::int64 v, int iOff = 0) : mCurrency (uCurrencyID), mIssuer (uIssuerID), mOffset (iOff) { set (v); canonicalize (); } - STAmount (SField::ref n, const uint160& currency, const uint160& issuer, int64 v, int off = 0) + STAmount (SField::ref n, const uint160& currency, const uint160& issuer, beast::int64 v, int off = 0) : SerializedType (n), mCurrency (currency), mIssuer (issuer), mOffset (off) { set (v); @@ -540,7 +540,7 @@ public: STAmount (SField::ref, const Json::Value&); - static STAmount createFromInt64 (SField::ref n, int64 v); + static STAmount createFromInt64 (SField::ref n, beast::int64 v); static std::unique_ptr deserialize (SerializerIterator& sit, SField::ref name) { @@ -549,7 +549,7 @@ public: bool bSetJson (const Json::Value& jvSource); - static STAmount saFromRate (uint64 uRate = 0) + static STAmount saFromRate (beast::uint64 uRate = 0) { return STAmount (CURRENCY_ONE, ACCOUNT_ONE, uRate, -9, false); } @@ -567,26 +567,26 @@ public: { return mOffset; } - uint64 getMantissa () const + beast::uint64 getMantissa () const { return mValue; } // When the currency is XRP, the value in raw units. S=signed - uint64 getNValue () const + beast::uint64 getNValue () const { if (!mIsNative) throw std::runtime_error ("not native"); return mValue; } - void setNValue (uint64 v) + void setNValue (beast::uint64 v) { if (!mIsNative) throw std::runtime_error ("not native"); mValue = v; } - int64 getSNValue () const; - void setSNValue (int64); + beast::int64 getSNValue () const; + void setSNValue (beast::int64); std::string getHumanCurrency () const; @@ -692,19 +692,19 @@ public: void throwComparable (const STAmount&) const; // native currency only - bool operator< (uint64) const; - bool operator> (uint64) const; - bool operator<= (uint64) const; - bool operator>= (uint64) const; - STAmount operator+ (uint64) const; - STAmount operator- (uint64) const; + bool operator< (beast::uint64) const; + bool operator> (beast::uint64) const; + bool operator<= (beast::uint64) const; + bool operator>= (beast::uint64) const; + STAmount operator+ (beast::uint64) const; + STAmount operator- (beast::uint64) const; STAmount operator- (void) const; STAmount& operator+= (const STAmount&); STAmount& operator-= (const STAmount&); - STAmount& operator+= (uint64); - STAmount& operator-= (uint64); - STAmount& operator= (uint64); + STAmount& operator+= (beast::uint64); + STAmount& operator-= (beast::uint64); + STAmount& operator= (beast::uint64); operator double () const; @@ -758,14 +758,14 @@ public: // Someone is offering X for Y, what is the rate? // Rate: smaller is better, the taker wants the most out: in/out - static uint64 getRate (const STAmount& offerOut, const STAmount& offerIn); - static STAmount setRate (uint64 rate); + static beast::uint64 getRate (const STAmount& offerOut, const STAmount& offerIn); + static STAmount setRate (beast::uint64 rate); // Someone is offering X for Y, I try to pay Z, how much do I get? // And what's left of the offer? And how much do I actually pay? static bool applyOffer ( const bool bSell, - const uint32 uTakerPaysRate, const uint32 uOfferPaysRate, + const beast::uint32 uTakerPaysRate, const beast::uint32 uOfferPaysRate, const STAmount& saOfferRate, const STAmount& saOfferFunds, const STAmount& saTakerFunds, const STAmount& saOfferPays, const STAmount& saOfferGets, @@ -793,7 +793,7 @@ public: STAmount getRound () const; void roundSelf (); - static void canonicalizeRound (bool isNative, uint64& value, int& offset, bool roundUp); + static void canonicalizeRound (bool isNative, beast::uint64& value, int& offset, bool roundUp); private: template @@ -809,10 +809,10 @@ private: uint160 mCurrency; // Compared by ==. Always update mIsNative. uint160 mIssuer; // Not compared by ==. 0 for XRP. - uint64 mValue; - int mOffset; - bool mIsNative; // Always !mCurrency. Native is XRP. - bool mIsNegative; + beast::uint64 mValue; + int mOffset; + bool mIsNative; // Always !mCurrency. Native is XRP. + bool mIsNegative; void canonicalize (); STAmount* duplicate () const @@ -821,24 +821,25 @@ private: } static STAmount* construct (SerializerIterator&, SField::ref name); - STAmount (SField::ref name, const uint160& cur, const uint160& iss, uint64 val, int off, bool isNat, bool isNeg) + STAmount (SField::ref name, const uint160& cur, const uint160& iss, + beast::uint64 val, int off, bool isNat, bool isNeg) : SerializedType (name), mCurrency (cur), mIssuer (iss), mValue (val), mOffset (off), mIsNative (isNat), mIsNegative (isNeg) { ; } - void set (int64 v) + void set (beast::int64 v) { if (v < 0) { mIsNegative = true; - mValue = static_cast (-v); + mValue = static_cast (-v); } else { mIsNegative = false; - mValue = static_cast (v); + mValue = static_cast (v); } } @@ -847,12 +848,12 @@ private: if (v < 0) { mIsNegative = true; - mValue = static_cast (-v); + mValue = static_cast (-v); } else { mIsNegative = false; - mValue = static_cast (v); + mValue = static_cast (v); } } }; diff --git a/src/ripple_data/protocol/Serializer.cpp b/src/ripple_data/protocol/Serializer.cpp index f166eed5c9..514f4572d1 100644 --- a/src/ripple_data/protocol/Serializer.cpp +++ b/src/ripple_data/protocol/Serializer.cpp @@ -29,7 +29,7 @@ int Serializer::addZeros (size_t uBytes) return ret; } -int Serializer::add16 (uint16 i) +int Serializer::add16 (beast::uint16 i) { int ret = mData.size (); mData.push_back (static_cast (i >> 8)); @@ -37,7 +37,7 @@ int Serializer::add16 (uint16 i) return ret; } -int Serializer::add32 (uint32 i) +int Serializer::add32 (beast::uint32 i) { int ret = mData.size (); mData.push_back (static_cast (i >> 24)); @@ -47,7 +47,7 @@ int Serializer::add32 (uint32 i) return ret; } -int Serializer::add64 (uint64 i) +int Serializer::add64 (beast::uint64 i) { int ret = mData.size (); mData.push_back (static_cast (i >> 56)); @@ -103,7 +103,7 @@ int Serializer::addRaw (const void* ptr, int len) return ret; } -bool Serializer::get16 (uint16& o, int offset) const +bool Serializer::get16 (beast::uint16& o, int offset) const { if ((offset + 2) > mData.size ()) return false; @@ -114,7 +114,7 @@ bool Serializer::get16 (uint16& o, int offset) const return true; } -bool Serializer::get32 (uint32& o, int offset) const +bool Serializer::get32 (beast::uint32& o, int offset) const { if ((offset + 4) > mData.size ()) return false; @@ -129,7 +129,7 @@ bool Serializer::get32 (uint32& o, int offset) const return true; } -bool Serializer::get64 (uint64& o, int offset) const +bool Serializer::get64 (beast::uint64& o, int offset) const { if ((offset + 8) > mData.size ()) return false; @@ -362,7 +362,7 @@ uint256 Serializer::getSHA512Half (const unsigned char* data, int len) return j[0]; } -uint256 Serializer::getPrefixHash (uint32 prefix, const unsigned char* data, int len) +uint256 Serializer::getPrefixHash (beast::uint32 prefix, const unsigned char* data, int len) { char be_prefix[4]; be_prefix[0] = static_cast (prefix >> 24); @@ -603,9 +603,9 @@ unsigned char SerializerIterator::get8 () return val; } -uint16 SerializerIterator::get16 () +beast::uint16 SerializerIterator::get16 () { - uint16 val; + beast::uint16 val; if (!mSerializer.get16 (val, mPos)) throw std::runtime_error ("invalid serializer get16"); @@ -613,9 +613,9 @@ uint16 SerializerIterator::get16 () return val; } -uint32 SerializerIterator::get32 () +beast::uint32 SerializerIterator::get32 () { - uint32 val; + beast::uint32 val; if (!mSerializer.get32 (val, mPos)) throw std::runtime_error ("invalid serializer get32"); @@ -623,9 +623,9 @@ uint32 SerializerIterator::get32 () return val; } -uint64 SerializerIterator::get64 () +beast::uint64 SerializerIterator::get64 () { - uint64 val; + beast::uint64 val; if (!mSerializer.get64 (val, mPos)) throw std::runtime_error ("invalid serializer get64"); @@ -684,10 +684,10 @@ Blob SerializerIterator::getRaw (int iLength) //------------------------------------------------------------------------------ -class SerializerTests : public UnitTest +class SerializerTests : public beast::UnitTest { public: - SerializerTests () : UnitTest ("Serializer", "ripple") + SerializerTests () : beast::UnitTest ("Serializer", "ripple") { } diff --git a/src/ripple_data/protocol/Serializer.h b/src/ripple_data/protocol/Serializer.h index 41b83e75b9..2c02ed771d 100644 --- a/src/ripple_data/protocol/Serializer.h +++ b/src/ripple_data/protocol/Serializer.h @@ -60,9 +60,9 @@ public: // assemble functions int add8 (unsigned char byte); - int add16 (uint16); - int add32 (uint32); // ledger indexes, account sequence, timestamps - int add64 (uint64); // native currency amounts + int add16 (beast::uint16); + int add32 (beast::uint32); // ledger indexes, account sequence, timestamps + int add64 (beast::uint64); // native currency amounts int add128 (const uint128&); // private key generators int add160 (const uint160&); // account names, hankos int add256 (uint256 const& ); // transaction and ledger hashes @@ -78,9 +78,9 @@ public: // disassemble functions bool get8 (int&, int offset) const; bool get8 (unsigned char&, int offset) const; - bool get16 (uint16&, int offset) const; - bool get32 (uint32&, int offset) const; - bool get64 (uint64&, int offset) const; + bool get16 (beast::uint16&, int offset) const; + bool get32 (beast::uint32&, int offset) const; + bool get64 (beast::uint64&, int offset) const; bool get128 (uint128&, int offset) const; bool get160 (uint160&, int offset) const; bool get256 (uint256&, int offset) const; @@ -107,16 +107,16 @@ public: static uint256 getSHA512Half (const unsigned char* data, int len); // prefix hash functions - static uint256 getPrefixHash (uint32 prefix, const unsigned char* data, int len); - uint256 getPrefixHash (uint32 prefix) const + static uint256 getPrefixHash (beast::uint32 prefix, const unsigned char* data, int len); + uint256 getPrefixHash (beast::uint32 prefix) const { return getPrefixHash (prefix, & (mData.front ()), mData.size ()); } - static uint256 getPrefixHash (uint32 prefix, Blob const& data) + static uint256 getPrefixHash (beast::uint32 prefix, Blob const& data) { return getPrefixHash (prefix, & (data.front ()), data.size ()); } - static uint256 getPrefixHash (uint32 prefix, const std::string& strData) + static uint256 getPrefixHash (beast::uint32 prefix, const std::string& strData) { return getPrefixHash (prefix, reinterpret_cast (strData.data ()), strData.size ()); } @@ -284,9 +284,9 @@ public: // get functions throw on error unsigned char get8 (); - uint16 get16 (); - uint32 get32 (); - uint64 get64 (); + beast::uint16 get16 (); + beast::uint32 get32 (); + beast::uint64 get64 (); uint128 get128 (); uint160 get160 (); uint256 get256 (); diff --git a/src/ripple_data/protocol/TxFlags.h b/src/ripple_data/protocol/TxFlags.h index 39eccd34d8..d53540b9ae 100644 --- a/src/ripple_data/protocol/TxFlags.h +++ b/src/ripple_data/protocol/TxFlags.h @@ -34,51 +34,51 @@ class TxFlag { public: - static uint32 const requireDestTag = 0x00010000; + static beast::uint32 const requireDestTag = 0x00010000; }; // VFALCO TODO Move all flags into this container after some study. // Universal Transaction flags: -const uint32 tfFullyCanonicalSig = 0x80000000; -const uint32 tfUniversal = tfFullyCanonicalSig; -const uint32 tfUniversalMask = ~ tfUniversal; +const beast::uint32 tfFullyCanonicalSig = 0x80000000; +const beast::uint32 tfUniversal = tfFullyCanonicalSig; +const beast::uint32 tfUniversalMask = ~ tfUniversal; // AccountSet flags: // VFALCO TODO Javadoc comment every one of these constants -//const uint32 TxFlag::requireDestTag = 0x00010000; -const uint32 tfOptionalDestTag = 0x00020000; -const uint32 tfRequireAuth = 0x00040000; -const uint32 tfOptionalAuth = 0x00080000; -const uint32 tfDisallowXRP = 0x00100000; -const uint32 tfAllowXRP = 0x00200000; -const uint32 tfAccountSetMask = ~ (TxFlag::requireDestTag | tfOptionalDestTag - | tfRequireAuth | tfOptionalAuth - | tfDisallowXRP | tfAllowXRP); +//const beast::uint32 TxFlag::requireDestTag = 0x00010000; +const beast::uint32 tfOptionalDestTag = 0x00020000; +const beast::uint32 tfRequireAuth = 0x00040000; +const beast::uint32 tfOptionalAuth = 0x00080000; +const beast::uint32 tfDisallowXRP = 0x00100000; +const beast::uint32 tfAllowXRP = 0x00200000; +const beast::uint32 tfAccountSetMask = ~ (TxFlag::requireDestTag | tfOptionalDestTag + | tfRequireAuth | tfOptionalAuth + | tfDisallowXRP | tfAllowXRP); // AccountSet SetFlag/ClearFlag values -const uint32 asfRequireDest = 1; -const uint32 asfRequireAuth = 2; -const uint32 asfDisallowXRP = 3; -const uint32 asfDisableMaster = 4; -const uint32 asfAccountTxnID = 5; +const beast::uint32 asfRequireDest = 1; +const beast::uint32 asfRequireAuth = 2; +const beast::uint32 asfDisallowXRP = 3; +const beast::uint32 asfDisableMaster = 4; +const beast::uint32 asfAccountTxnID = 5; // OfferCreate flags: -const uint32 tfPassive = 0x00010000; -const uint32 tfImmediateOrCancel = 0x00020000; -const uint32 tfFillOrKill = 0x00040000; -const uint32 tfSell = 0x00080000; -const uint32 tfOfferCreateMask = ~ (tfUniversal | tfPassive | tfImmediateOrCancel | tfFillOrKill | tfSell); +const beast::uint32 tfPassive = 0x00010000; +const beast::uint32 tfImmediateOrCancel = 0x00020000; +const beast::uint32 tfFillOrKill = 0x00040000; +const beast::uint32 tfSell = 0x00080000; +const beast::uint32 tfOfferCreateMask = ~ (tfUniversal | tfPassive | tfImmediateOrCancel | tfFillOrKill | tfSell); // Payment flags: -const uint32 tfNoRippleDirect = 0x00010000; -const uint32 tfPartialPayment = 0x00020000; -const uint32 tfLimitQuality = 0x00040000; -const uint32 tfPaymentMask = ~ (tfUniversal | tfPartialPayment | tfLimitQuality | tfNoRippleDirect); +const beast::uint32 tfNoRippleDirect = 0x00010000; +const beast::uint32 tfPartialPayment = 0x00020000; +const beast::uint32 tfLimitQuality = 0x00040000; +const beast::uint32 tfPaymentMask = ~ (tfUniversal | tfPartialPayment | tfLimitQuality | tfNoRippleDirect); // TrustSet flags: -const uint32 tfSetfAuth = 0x00010000; -const uint32 tfSetNoRipple = 0x00020000; -const uint32 tfClearNoRipple = 0x00040000; -const uint32 tfTrustSetMask = ~ (tfUniversal | tfSetfAuth | tfSetNoRipple | tfClearNoRipple); +const beast::uint32 tfSetfAuth = 0x00010000; +const beast::uint32 tfSetNoRipple = 0x00020000; +const beast::uint32 tfClearNoRipple = 0x00040000; +const beast::uint32 tfTrustSetMask = ~ (tfUniversal | tfSetfAuth | tfSetNoRipple | tfClearNoRipple); #endif diff --git a/src/ripple_data/ripple_data.cpp b/src/ripple_data/ripple_data.cpp index 4001910cc3..3f97219011 100644 --- a/src/ripple_data/ripple_data.cpp +++ b/src/ripple_data/ripple_data.cpp @@ -83,10 +83,10 @@ namespace ripple #include "protocol/TxFormats.cpp" // These are for STAmount -static const uint64 tenTo14 = 100000000000000ull; -static const uint64 tenTo14m1 = tenTo14 - 1; -static const uint64 tenTo17 = tenTo14 * 1000; -static const uint64 tenTo17m1 = tenTo17 - 1; +static const beast::uint64 tenTo14 = 100000000000000ull; +static const beast::uint64 tenTo14m1 = tenTo14 - 1; +static const beast::uint64 tenTo17 = tenTo14 * 1000; +static const beast::uint64 tenTo17m1 = tenTo17 - 1; #include "protocol/STAmount.cpp" #include "protocol/STAmountRound.cpp" diff --git a/src/ripple_net/basics/HTTPClient.cpp b/src/ripple_net/basics/HTTPClient.cpp index deb57f8b10..f58d1a6003 100644 --- a/src/ripple_net/basics/HTTPClient.cpp +++ b/src/ripple_net/basics/HTTPClient.cpp @@ -72,7 +72,7 @@ private: // void HTTPClient::initializeSSLContext () { - SharedSingleton ::get(); + beast::SharedSingleton ::get(); } //------------------------------------------------------------------------------ @@ -80,13 +80,13 @@ void HTTPClient::initializeSSLContext () class HTTPClientImp : public boost::enable_shared_from_this , public HTTPClient - , LeakChecked + , beast::LeakChecked { public: HTTPClientImp (boost::asio::io_service& io_service, const unsigned short port, std::size_t responseMax) - : mSocket (io_service, SharedSingleton ::get()->context()) + : mSocket (io_service, beast::SharedSingleton ::get()->context()) , mResolver (io_service) , mHeader (maxClientHeaderBytes) , mPort (port) @@ -161,7 +161,7 @@ public: boost::shared_ptr query ( new boost::asio::ip::tcp::resolver::query ( mDeqSites[0], - lexicalCast (mPort), + beast::lexicalCast (mPort), boost::asio::ip::resolver_query_base::numeric_service)); mQuery = query; @@ -384,14 +384,14 @@ public: return; } - mStatus = lexicalCastThrow (std::string (smMatch[1])); + mStatus = beast::lexicalCastThrow (std::string (smMatch[1])); if (boost::regex_match (strHeader, smMatch, reBody)) // we got some body mBody = smMatch[1]; if (boost::regex_match (strHeader, smMatch, reSize)) { - int size = lexicalCastThrow (std::string(smMatch[1])); + int size = beast::lexicalCastThrow (std::string(smMatch[1])); if (size < mResponseMax) mResponseMax = size; diff --git a/src/ripple_net/basics/HTTPRequest.cpp b/src/ripple_net/basics/HTTPRequest.cpp index d2991f0f40..36181e8bd5 100644 --- a/src/ripple_net/basics/HTTPRequest.cpp +++ b/src/ripple_net/basics/HTTPRequest.cpp @@ -111,7 +111,7 @@ HTTPRequest::Action HTTPRequest::consume (boost::asio::streambuf& buf) } if (headerName == "content-length") - iDataSize = lexicalCastThrow (headerValue); + iDataSize = beast::lexicalCastThrow (headerValue); if (headerName == "authorization") sAuthorization = headerValue; diff --git a/src/ripple_net/basics/RPCDoor.cpp b/src/ripple_net/basics/RPCDoor.cpp index ee9f904613..0550977e2f 100644 --- a/src/ripple_net/basics/RPCDoor.cpp +++ b/src/ripple_net/basics/RPCDoor.cpp @@ -23,7 +23,7 @@ namespace ripple { SETUP_LOG (RPCDoor) -class RPCDoorImp : public RPCDoor, public LeakChecked +class RPCDoorImp : public RPCDoor, public beast::LeakChecked { public: RPCDoorImp (boost::asio::io_service& io_service, RPCServer::Handler& handler) @@ -130,14 +130,14 @@ private: RPCServer::Handler& m_rpcServerHandler; boost::asio::ip::tcp::acceptor mAcceptor; boost::asio::deadline_timer mDelayTimer; - ScopedPointer m_sslContext; + beast::ScopedPointer m_sslContext; }; //------------------------------------------------------------------------------ RPCDoor* RPCDoor::New (boost::asio::io_service& io_service, RPCServer::Handler& handler) { - ScopedPointer result (new RPCDoorImp (io_service, handler)); + beast::ScopedPointer result (new RPCDoorImp (io_service, handler)); return result.release (); } diff --git a/src/ripple_net/basics/RPCServer.h b/src/ripple_net/basics/RPCServer.h index a03c769a83..2557f2c2fe 100644 --- a/src/ripple_net/basics/RPCServer.h +++ b/src/ripple_net/basics/RPCServer.h @@ -46,7 +46,8 @@ public: @param request The RPC request string. @return The server's response. */ - virtual std::string processRequest (std::string const& request, IP::Endpoint const& remoteIPAddress) = 0; + virtual std::string processRequest (std::string const& request, + beast::IP::Endpoint const& remoteIPAddress) = 0; }; virtual ~RPCServer () { } diff --git a/src/ripple_net/basics/SNTPClient.cpp b/src/ripple_net/basics/SNTPClient.cpp index 4c41b5bb29..ffb1d3fbea 100644 --- a/src/ripple_net/basics/SNTPClient.cpp +++ b/src/ripple_net/basics/SNTPClient.cpp @@ -55,8 +55,8 @@ static uint8_t SNTPQueryData[48] = class SNTPClientImp : public SNTPClient - , public Thread - , public LeakChecked + , public beast::Thread + , public beast::LeakChecked { public: class SNTPQuery @@ -64,7 +64,7 @@ public: public: bool mReceivedReply; time_t mLocalTimeSent; - uint32 mQueryNonce; + beast::uint32 mQueryNonce; SNTPQuery (time_t j = (time_t) - 1) : mReceivedReply (false), mLocalTimeSent (j) { @@ -155,7 +155,7 @@ public: { ScopedLockType sl (mLock, __FILE__, __LINE__); - if ((mLastOffsetUpdate == (time_t) - 1) || ((mLastOffsetUpdate + NTP_TIMESTAMP_VALID) < time (NULL))) + if ((mLastOffsetUpdate == (time_t) - 1) || ((mLastOffsetUpdate + NTP_TIMESTAMP_VALID) < time (nullptr))) return false; offset = mOffset; @@ -178,7 +178,7 @@ public: return false; } - time_t now = time (NULL); + time_t now = time (nullptr); if ((best->second != (time_t) - 1) && ((best->second + NTP_MIN_QUERY) >= now)) { @@ -213,7 +213,7 @@ public: { ScopedLockType sl (mLock, __FILE__, __LINE__); SNTPQuery& query = mQueries[*sel]; - time_t now = time (NULL); + time_t now = time (nullptr); if ((query.mLocalTimeSent == now) || ((query.mLocalTimeSent + 1) == now)) { @@ -225,8 +225,8 @@ public: query.mReceivedReply = false; query.mLocalTimeSent = now; RandomNumbers::getInstance ().fill (&query.mQueryNonce); - reinterpret_cast (SNTPQueryData)[NTP_OFF_XMITTS_INT] = static_cast (time (NULL)) + NTP_UNIX_OFFSET; - reinterpret_cast (SNTPQueryData)[NTP_OFF_XMITTS_FRAC] = query.mQueryNonce; + reinterpret_cast (SNTPQueryData)[NTP_OFF_XMITTS_INT] = static_cast (time (nullptr)) + NTP_UNIX_OFFSET; + reinterpret_cast (SNTPQueryData)[NTP_OFF_XMITTS_FRAC] = query.mQueryNonce; mSocket.async_send_to (boost::asio::buffer (SNTPQueryData, 48), *sel, boost::bind (&SNTPClientImp::sendComplete, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); @@ -252,12 +252,12 @@ public: { query->second.mReceivedReply = true; - if (time (NULL) > (query->second.mLocalTimeSent + 1)) + if (time (nullptr) > (query->second.mLocalTimeSent + 1)) WriteLog (lsWARNING, SNTPClient) << "SNTP: Late response from " << mReceiveEndpoint; else if (bytes_xferd < 48) WriteLog (lsWARNING, SNTPClient) << "SNTP: Short reply from " << mReceiveEndpoint << " (" << bytes_xferd << ") " << mReceiveBuffer.size (); - else if (reinterpret_cast (&mReceiveBuffer[0])[NTP_OFF_ORGTS_FRAC] != query->second.mQueryNonce) + else if (reinterpret_cast (&mReceiveBuffer[0])[NTP_OFF_ORGTS_FRAC] != query->second.mQueryNonce) WriteLog (lsWARNING, SNTPClient) << "SNTP: Reply from " << mReceiveEndpoint << "had wrong nonce"; else processReply (); @@ -277,7 +277,7 @@ public: void processReply () { assert (mReceiveBuffer.size () >= 48); - uint32* recvBuffer = reinterpret_cast (&mReceiveBuffer.front ()); + beast::uint32* recvBuffer = reinterpret_cast (&mReceiveBuffer.front ()); unsigned info = ntohl (recvBuffer[NTP_OFF_INFO]); int64_t timev = ntohl (recvBuffer[NTP_OFF_RECVTS_INT]); @@ -295,7 +295,7 @@ public: return; } - int64 now = static_cast (time (NULL)); + beast::int64 now = static_cast (time (nullptr)); timev -= now; timev -= NTP_UNIX_OFFSET; diff --git a/src/ripple_net/basics/SNTPClient.h b/src/ripple_net/basics/SNTPClient.h index 221cd20d23..0794d29b93 100644 --- a/src/ripple_net/basics/SNTPClient.h +++ b/src/ripple_net/basics/SNTPClient.h @@ -20,13 +20,13 @@ #ifndef RIPPLE_NET_BASICS_SNTPCLIENT_H_INCLUDED #define RIPPLE_NET_BASICS_SNTPCLIENT_H_INCLUDED -class SNTPClient : public Stoppable +class SNTPClient : public beast::Stoppable { protected: - explicit SNTPClient (Stoppable& parent); + explicit SNTPClient (beast::Stoppable& parent); public: - static SNTPClient* New (Stoppable& parent); + static SNTPClient* New (beast::Stoppable& parent); virtual ~SNTPClient() { } virtual void init (std::vector const& servers) = 0; virtual void addServer (std::string const& mServer) = 0; diff --git a/src/ripple_net/basics/impl/RPCServerImp.h b/src/ripple_net/basics/impl/RPCServerImp.h index eba12f32b4..06c43625d1 100644 --- a/src/ripple_net/basics/impl/RPCServerImp.h +++ b/src/ripple_net/basics/impl/RPCServerImp.h @@ -22,7 +22,7 @@ SETUP_LOG (RPCServer) class RPCServerImp : public RPCServer , public boost::enable_shared_from_this - , public LeakChecked + , public beast::LeakChecked { public: typedef boost::shared_ptr pointer; diff --git a/src/ripple_net/rpc/InfoSub.cpp b/src/ripple_net/rpc/InfoSub.cpp index b3037d5b7e..075c97de67 100644 --- a/src/ripple_net/rpc/InfoSub.cpp +++ b/src/ripple_net/rpc/InfoSub.cpp @@ -42,7 +42,7 @@ InfoSub::InfoSub (Source& source, Consumer consumer) , m_consumer (consumer) , m_source (source) { - static Atomic s_seq_id; + static beast::Atomic s_seq_id; mSeq = ++s_seq_id; } @@ -66,7 +66,7 @@ void InfoSub::send (const Json::Value& jvObj, const std::string& sObj, bool broa send (jvObj, broadcast); } -uint64 InfoSub::getSeq () +beast::uint64 InfoSub::getSeq () { return mSeq; } @@ -75,7 +75,7 @@ void InfoSub::onSendEmpty () { } -void InfoSub::insertSubAccountInfo (RippleAddress addr, uint32 uLedgerIndex) +void InfoSub::insertSubAccountInfo (RippleAddress addr, beast::uint32 uLedgerIndex) { ScopedLockType sl (mLock, __FILE__, __LINE__); diff --git a/src/ripple_net/rpc/InfoSub.h b/src/ripple_net/rpc/InfoSub.h index 805194aaca..ec7886e04a 100644 --- a/src/ripple_net/rpc/InfoSub.h +++ b/src/ripple_net/rpc/InfoSub.h @@ -45,18 +45,18 @@ public: public: /** Abstracts the source of subscription data. */ - class Source : public Stoppable + class Source : public beast::Stoppable { protected: - Source (char const* name, Stoppable& parent); + Source (char const* name, beast::Stoppable& parent); public: // VFALCO TODO Rename the 'rt' parameters to something meaningful. virtual void subAccount (ref ispListener, const boost::unordered_set& vnaAccountIDs, - uint32 uLedgerIndex, bool rt) = 0; + beast::uint32 uLedgerIndex, bool rt) = 0; - virtual void unsubAccount (uint64 uListener, + virtual void unsubAccount (beast::uint64 uListener, const boost::unordered_set& vnaAccountIDs, bool rt) = 0; @@ -64,28 +64,28 @@ public: virtual bool subLedger (ref ispListener, Json::Value& jvResult) = 0; - virtual bool unsubLedger (uint64 uListener) = 0; + virtual bool unsubLedger (beast::uint64 uListener) = 0; virtual bool subServer (ref ispListener, Json::Value& jvResult) = 0; - virtual bool unsubServer (uint64 uListener) = 0; + virtual bool unsubServer (beast::uint64 uListener) = 0; virtual bool subBook (ref ispListener, RippleCurrency const& currencyPays, RippleCurrency const& currencyGets, RippleIssuer const& issuerPays, RippleIssuer const& issuerGets) = 0; - virtual bool unsubBook (uint64 uListener, + virtual bool unsubBook (beast::uint64 uListener, RippleCurrency const& currencyPays, RippleCurrency const& currencyGets, RippleIssuer const& issuerPays, RippleIssuer const& issuerGets) = 0; virtual bool subTransactions (ref ispListener) = 0; - virtual bool unsubTransactions (uint64 uListener) = 0; + virtual bool unsubTransactions (beast::uint64 uListener) = 0; virtual bool subRTTransactions (ref ispListener) = 0; - virtual bool unsubRTTransactions (uint64 uListener) = 0; + virtual bool unsubRTTransactions (beast::uint64 uListener) = 0; // VFALCO TODO Remove // This was added for one particular partner, it @@ -108,11 +108,11 @@ public: // VFALCO NOTE Why is this virtual? virtual void send (const Json::Value & jvObj, const std::string & sObj, bool broadcast); - uint64 getSeq (); + beast::uint64 getSeq (); void onSendEmpty (); - void insertSubAccountInfo (RippleAddress addr, uint32 uLedgerIndex); + void insertSubAccountInfo (RippleAddress addr, beast::uint32 uLedgerIndex); void clearPathRequest (); @@ -132,7 +132,7 @@ private: boost::unordered_set mSubAccountTransaction; boost::shared_ptr mPathRequest; - uint64 mSeq; + beast::uint64 mSeq; }; #endif diff --git a/src/ripple_net/rpc/RPCCall.cpp b/src/ripple_net/rpc/RPCCall.cpp index 70b45880fd..ec2822739d 100644 --- a/src/ripple_net/rpc/RPCCall.cpp +++ b/src/ripple_net/rpc/RPCCall.cpp @@ -47,7 +47,7 @@ private: } else { - jvRequest["ledger_index"] = lexicalCast (strLedger); + jvRequest["ledger_index"] = beast::lexicalCast (strLedger); } return true; @@ -171,8 +171,8 @@ private: } else { - int64 uLedgerMin = jvParams[1u].asInt (); - int64 uLedgerMax = jvParams[2u].asInt (); + beast::int64 uLedgerMin = jvParams[1u].asInt (); + beast::int64 uLedgerMax = jvParams[2u].asInt (); if (uLedgerMax != -1 && uLedgerMax < uLedgerMin) { @@ -240,8 +240,8 @@ private: } else { - int64 uLedgerMin = jvParams[1u].asInt (); - int64 uLedgerMax = jvParams[2u].asInt (); + beast::int64 uLedgerMin = jvParams[1u].asInt (); + beast::int64 uLedgerMax = jvParams[2u].asInt (); if (uLedgerMax != -1 && uLedgerMax < uLedgerMin) { @@ -380,7 +380,7 @@ private: jvRequest["feature"] = jvParams[0u].asString (); if (jvParams.size () > 1) - jvRequest["vote"] = lexicalCastThrow (jvParams[1u].asString ()); + jvRequest["vote"] = beast::lexicalCastThrow (jvParams[1u].asString ()); return jvRequest; } @@ -451,7 +451,7 @@ private: } else { - jvRequest["ledger_index"] = lexicalCast (strLedger); + jvRequest["ledger_index"] = beast::lexicalCast (strLedger); } return jvRequest; @@ -529,7 +529,7 @@ private: strPeer = jvParams[iCursor].asString (); int iIndex = 0; - // int iIndex = jvParams.size() >= 2 ? lexicalCast (jvParams[1u].asString()) : 0; + // int iIndex = jvParams.size() >= 2 ? beast::lexicalCast (jvParams[1u].asString()) : 0; RippleAddress raAddress; @@ -1096,7 +1096,7 @@ int RPCCall::fromCommandLine (const std::vector& vCmd) jvOutput["status"] = "error"; nRet = jvOutput.isMember ("error_code") - ? lexicalCast (jvOutput["error_code"].asString ()) + ? beast::lexicalCast (jvOutput["error_code"].asString ()) : 1; } diff --git a/src/ripple_net/rpc/RPCSub.cpp b/src/ripple_net/rpc/RPCSub.cpp index 0e0cbe7bb8..4cb2ad221b 100644 --- a/src/ripple_net/rpc/RPCSub.cpp +++ b/src/ripple_net/rpc/RPCSub.cpp @@ -22,7 +22,7 @@ SETUP_LOG (RPCSub) // Subscription object for JSON-RPC class RPCSubImp : public RPCSub - , public LeakChecked + , public beast::LeakChecked { public: RPCSubImp (InfoSub::Source& source, boost::asio::io_service& io_service, diff --git a/src/ripple_net/rpc/RPCUtil.cpp b/src/ripple_net/rpc/RPCUtil.cpp index a613cf623d..f037711336 100644 --- a/src/ripple_net/rpc/RPCUtil.cpp +++ b/src/ripple_net/rpc/RPCUtil.cpp @@ -79,7 +79,7 @@ std::string rfc1123Time () time_t now; time (&now); struct tm* now_gmt = gmtime (&now); - std::string locale (setlocale (LC_TIME, NULL)); + std::string locale (setlocale (LC_TIME, nullptr)); setlocale (LC_TIME, "C"); // we want posix (aka "C") weekday/month strings strftime (buffer, sizeof (buffer), "%a, %d %b %Y %H:%M:%S +0000", now_gmt); setlocale (LC_TIME, locale.c_str ()); diff --git a/src/ripple_overlay/api/Peer.h b/src/ripple_overlay/api/Peer.h index ac5dedb3c1..66730d6ccc 100644 --- a/src/ripple_overlay/api/Peer.h +++ b/src/ripple_overlay/api/Peer.h @@ -39,7 +39,7 @@ class Peers; /** Represents a peer connection in the overlay. */ -class Peer : private LeakChecked +class Peer : private beast::LeakChecked { public: typedef boost::shared_ptr Ptr; @@ -51,7 +51,7 @@ public: /** Uniquely identifies a particular connection of a peer This works upto a restart of rippled. */ - typedef uint32 ShortId; + typedef beast::uint32 ShortId; virtual void sendPacket (const PackedMessage::pointer& packet, bool onStrand) = 0; @@ -70,11 +70,11 @@ public: virtual uint256 const& getClosedLedgerHash () const = 0; - virtual bool hasLedger (uint256 const& hash, uint32 seq) const = 0; + virtual bool hasLedger (uint256 const& hash, beast::uint32 seq) const = 0; virtual void getLedger (protocol::TMGetLedger &) = 0; - virtual void ledgerRange (uint32& minSeq, uint32& maxSeq) const = 0; + virtual void ledgerRange (beast::uint32& minSeq, beast::uint32& maxSeq) const = 0; virtual bool hasTxSet (uint256 const& hash) const = 0; @@ -88,9 +88,9 @@ public: virtual bool supportsVersion (int version) = 0; - virtual bool hasRange (uint32 uMin, uint32 uMax) = 0; + virtual bool hasRange (beast::uint32 uMin, beast::uint32 uMax) = 0; - virtual IP::Endpoint getRemoteAddress() const = 0; + virtual beast::IP::Endpoint getRemoteAddress() const = 0; virtual NativeSocketType& getNativeSocket () = 0; }; diff --git a/src/ripple_overlay/api/Peers.h b/src/ripple_overlay/api/Peers.h index eda986b9a1..92f053e132 100644 --- a/src/ripple_overlay/api/Peers.h +++ b/src/ripple_overlay/api/Peers.h @@ -48,8 +48,8 @@ class Manager; /** Manages the set of connected peers. */ class Peers - : public Stoppable - , public PropertyStream::Source + : public beast::Stoppable + , public beast::PropertyStream::Source { protected: // VFALCO NOTE The requirement of this constructor is an @@ -58,7 +58,7 @@ protected: // Peers (Stoppable& parent) : Stoppable ("Peers", parent) - , PropertyStream::Source ("peers") + , beast::PropertyStream::Source ("peers") { } @@ -70,7 +70,7 @@ public: Stoppable& parent, Resource::Manager& resourceManager, SiteFiles::Manager& siteFiles, - File const& pathToDbFileOrDirectory, + beast::File const& pathToDbFileOrDirectory, Resolver& resolver, boost::asio::io_service& io_service, boost::asio::ssl::context& context); @@ -85,7 +85,7 @@ public: virtual void accept (bool proxyHandshake, boost::shared_ptr const& socket) = 0; - virtual void connect (IP::Endpoint const& address) = 0; + virtual void connect (beast::IP::Endpoint const& address) = 0; // Notification that a peer has connected. virtual void onPeerActivated (Peer::ref peer) = 0; diff --git a/src/ripple_overlay/impl/PeerDoor.cpp b/src/ripple_overlay/impl/PeerDoor.cpp index 9e4e8e98bd..656aad6b52 100644 --- a/src/ripple_overlay/impl/PeerDoor.cpp +++ b/src/ripple_overlay/impl/PeerDoor.cpp @@ -25,7 +25,7 @@ SETUP_LOG (PeerDoor) class PeerDoorImp : public PeerDoor - , public LeakChecked + , public beast::LeakChecked { public: PeerDoorImp (Kind kind, Peers& peers, @@ -40,7 +40,7 @@ public: { m_journal.info << "Listening on " << - IPAddressConversion::from_asio ( + beast::IPAddressConversion::from_asio ( m_acceptor.local_endpoint()) << ((m_kind == sslAndPROXYRequired) ? " (proxy)" : ""); @@ -134,7 +134,7 @@ public: private: Peers& m_peers; - Journal m_journal; + beast::Journal m_journal; Kind m_kind; boost::asio::ip::tcp::acceptor m_acceptor; boost::asio::deadline_timer m_acceptDelay; diff --git a/src/ripple_overlay/impl/PeerDoor.h b/src/ripple_overlay/impl/PeerDoor.h index 061f3a2666..a354f5d8aa 100644 --- a/src/ripple_overlay/impl/PeerDoor.h +++ b/src/ripple_overlay/impl/PeerDoor.h @@ -23,7 +23,7 @@ namespace ripple { /** Handles incoming connections from peers. */ -class PeerDoor : public Stoppable +class PeerDoor : public beast::Stoppable { protected: explicit PeerDoor (Stoppable& parent); diff --git a/src/ripple_overlay/impl/PeerImp.h b/src/ripple_overlay/impl/PeerImp.h index b1f9ffd50e..aa4ea7528d 100644 --- a/src/ripple_overlay/impl/PeerImp.h +++ b/src/ripple_overlay/impl/PeerImp.h @@ -76,7 +76,7 @@ private: static const boost::posix_time::seconds nodeVerifySeconds; /** The clock drift we allow a remote peer to have */ - static const uint32 clockToleranceDeltaSeconds = 20; + static const beast::uint32 clockToleranceDeltaSeconds = 20; /** The length of the smallest valid finished message */ static const size_t sslMinimumFinishedLength = 12; @@ -128,7 +128,7 @@ private: } getNativeSocket ().async_connect ( - IPAddressConversion::to_asio_endpoint (m_remoteAddress), + beast::IPAddressConversion::to_asio_endpoint (m_remoteAddress), m_strand.wrap (boost::bind (&PeerImp::onConnect, shared_from_this (), boost::asio::placeholders::error))); } @@ -157,7 +157,7 @@ public: boost::shared_ptr m_shared_socket; - Journal m_journal; + beast::Journal m_journal; // A unique identifier (up to a restart of rippled) for this particular // peer instance. A peer that disconnects will, upon reconnection, get a @@ -167,7 +167,7 @@ public: // Updated at each stage of the connection process to reflect // the current conditions as closely as possible. This includes // the case where we learn the true IP via a PROXY handshake. - IP::Endpoint m_remoteAddress; + beast::IP::Endpoint m_remoteAddress; // These is up here to prevent warnings about order of initializations // @@ -222,7 +222,7 @@ public: /** New incoming peer from the specified socket */ PeerImp ( boost::shared_ptr const& socket, - IP::Endpoint remoteAddress, + beast::IP::Endpoint remoteAddress, Peers& peers, Resource::Manager& resourceManager, PeerFinder::Manager& peerFinder, @@ -258,7 +258,7 @@ public: from inside constructors. */ PeerImp ( - IP::Endpoint remoteAddress, + beast::IP::Endpoint remoteAddress, boost::asio::io_service& io_service, Peers& peers, Resource::Manager& resourceManager, @@ -350,7 +350,7 @@ public: m_state = stateGracefulClose; - if (m_clusterNode && m_journal.active(Journal::Severity::kWarning)) + if (m_clusterNode && m_journal.active(beast::Journal::Severity::kWarning)) m_journal.warning << "Cluster peer " << m_nodeName << " detached: " << rsn; @@ -423,7 +423,7 @@ public: m_state = stateConnected; m_peerFinder.on_connected (m_slot, - IPAddressConversion::from_asio (local_endpoint)); + beast::IPAddressConversion::from_asio (local_endpoint)); m_socket->set_verify_mode (boost::asio::ssl::verify_none); m_socket->async_handshake ( @@ -529,7 +529,7 @@ public: ret["protocol"] = BuildInfo::Protocol (mHello.protoversion ()).toStdString (); } - uint32 minSeq, maxSeq; + beast::uint32 minSeq, maxSeq; ledgerRange(minSeq, maxSeq); if ((minSeq != 0) || (maxSeq != 0)) @@ -582,7 +582,7 @@ public: return m_closedLedgerHash; } - bool hasLedger (uint256 const& hash, uint32 seq) const + bool hasLedger (uint256 const& hash, beast::uint32 seq) const { boost::mutex::scoped_lock sl(m_recentLock); @@ -598,7 +598,7 @@ public: return false; } - void ledgerRange (uint32& minSeq, uint32& maxSeq) const + void ledgerRange (beast::uint32& minSeq, beast::uint32& maxSeq) const { boost::mutex::scoped_lock sl(m_recentLock); @@ -645,12 +645,12 @@ public: return mHello.has_protoversion () && (mHello.protoversion () >= version); } - bool hasRange (uint32 uMin, uint32 uMax) + bool hasRange (beast::uint32 uMin, beast::uint32 uMax) { return (uMin >= m_minLedger) && (uMax <= m_maxLedger); } - IP::Endpoint getRemoteAddress() const + beast::IP::Endpoint getRemoteAddress() const { return m_remoteAddress; } @@ -1352,14 +1352,14 @@ private: (void) m_timer.cancel (); - uint32 const ourTime (getApp().getOPs ().getNetworkTimeNC ()); - uint32 const minTime (ourTime - clockToleranceDeltaSeconds); - uint32 const maxTime (ourTime + clockToleranceDeltaSeconds); + beast::uint32 const ourTime (getApp().getOPs ().getNetworkTimeNC ()); + beast::uint32 const minTime (ourTime - clockToleranceDeltaSeconds); + beast::uint32 const maxTime (ourTime + clockToleranceDeltaSeconds); #ifdef BEAST_DEBUG if (packet.has_nettime ()) { - int64 to = ourTime; + beast::int64 to = ourTime; to -= packet.nettime (); m_journal.debug << "Connect: time offset " << to; } @@ -1409,7 +1409,7 @@ private: m_journal.info << "Hello: Connect: " << m_nodePublicKey.humanNodePublic (); if ((protocol != BuildInfo::getCurrentProtocol()) && - m_journal.active(Journal::Severity::kInfo)) + m_journal.active(beast::Journal::Severity::kInfo)) { m_journal.info << "Peer protocol: " << protocol.toStdString (); } @@ -1491,9 +1491,9 @@ private: { protocol::TMLoadSource const& node = packet.loadsources (i); Resource::Gossip::Item item; - item.address = IP::Endpoint::from_string (node.name()); + item.address = beast::IP::Endpoint::from_string (node.name()); item.balance = node.cost(); - if (item.address != IP::Endpoint()) + if (item.address != beast::IP::Endpoint()) gossip.items.push_back(item); } m_resourceManager.importConsumers (m_nodeName, gossip); @@ -1559,7 +1559,7 @@ private: void recvValidation (const boost::shared_ptr& packet) { - uint32 closeTime = getApp().getOPs().getCloseTimeNC(); + beast::uint32 closeTime = getApp().getOPs().getCloseTimeNC(); if (packet->validation ().size () < 50) { @@ -1646,7 +1646,7 @@ private: // TODO: filter out all the LAN peers void recvPeers (protocol::TMPeers& packet) { - std::vector list; + std::vector list; list.reserve (packet.nodes().size()); for (int i = 0; i < packet.nodes ().size (); ++i) { @@ -1655,8 +1655,8 @@ private: addr.s_addr = packet.nodes (i).ipv4 (); { - IP::AddressV4 v4 (ntohl (addr.s_addr)); - IP::Endpoint address (v4, packet.nodes (i).ipv4port ()); + beast::IP::AddressV4 v4 (ntohl (addr.s_addr)); + beast::IP::Endpoint address (v4, packet.nodes (i).ipv4port ()); list.push_back (address); } } @@ -1684,8 +1684,8 @@ private: { in_addr addr; addr.s_addr = tm.ipv4().ipv4(); - IP::AddressV4 v4 (ntohl (addr.s_addr)); - endpoint.address = IP::Endpoint (v4, tm.ipv4().ipv4port ()); + beast::IP::AddressV4 v4 (ntohl (addr.s_addr)); + endpoint.address = beast::IP::Endpoint (v4, tm.ipv4().ipv4port ()); } else { @@ -1767,7 +1767,7 @@ private: else { // this is a reply - uint32 pLSeq = 0; + beast::uint32 pLSeq = 0; bool pLDo = true; bool progress = false; @@ -1783,7 +1783,7 @@ private: if (obj.ledgerseq () != pLSeq) { if ((pLDo && (pLSeq != 0)) && - m_journal.active(Journal::Severity::kDebug)) + m_journal.active(beast::Journal::Severity::kDebug)) m_journal.debug << "Received full fetch pack for " << pLSeq; pLSeq = obj.ledgerseq (); @@ -1811,7 +1811,7 @@ private: } if ((pLDo && (pLSeq != 0)) && - m_journal.active(Journal::Severity::kDebug)) + m_journal.active(beast::Journal::Severity::kDebug)) m_journal.debug << "Received partial fetch pack for " << pLSeq; if (packet.type () == protocol::TMGetObjectByHash::otFETCH_PACK) @@ -2292,7 +2292,7 @@ private: if (!ledger && (packet.has_querytype () && !packet.has_requestcookie ())) { - uint32 seq = 0; + beast::uint32 seq = 0; if (packet.has_ledgerseq ()) seq = packet.ledgerseq (); diff --git a/src/ripple_overlay/impl/Peers.cpp b/src/ripple_overlay/impl/Peers.cpp index 9e4fe678bc..796706e1ce 100644 --- a/src/ripple_overlay/impl/Peers.cpp +++ b/src/ripple_overlay/impl/Peers.cpp @@ -83,12 +83,12 @@ struct get_peer_json class PeersImp : public Peers , public PeerFinder::Callback - , public LeakChecked + , public beast::LeakChecked { public: typedef std::unordered_map > PeersBySlot; - typedef std::unordered_map > PeersByIP; typedef boost::unordered_map < @@ -105,7 +105,7 @@ public: // Number of dependencies that must be destroyed before we can stop std::size_t m_child_count; - Journal m_journal; + beast::Journal m_journal; Resource::Manager& m_resourceManager; std::unique_ptr m_peerFinder; @@ -132,7 +132,7 @@ public: Resolver& m_resolver; /** Monotically increasing identifiers for peers */ - Atomic m_nextShortId; + beast::Atomic m_nextShortId; //-------------------------------------------------------------------------- // @@ -143,7 +143,7 @@ public: PeersImp (Stoppable& parent, Resource::Manager& resourceManager, SiteFiles::Manager& siteFiles, - File const& pathToDbFileOrDirectory, + beast::File const& pathToDbFileOrDirectory, Resolver& resolver, boost::asio::io_service& io_service, boost::asio::ssl::context& ssl_context) @@ -189,9 +189,9 @@ public: return; auto const local_endpoint ( - IPAddressConversion::from_asio (local_endpoint_native)); + beast::IPAddressConversion::from_asio (local_endpoint_native)); auto const remote_endpoint ( - IPAddressConversion::from_asio (remote_endpoint_native)); + beast::IPAddressConversion::from_asio (remote_endpoint_native)); PeerFinder::Slot::ptr const slot (m_peerFinder->new_inbound_slot ( local_endpoint, remote_endpoint)); @@ -224,7 +224,7 @@ public: } } - void connect (IP::Endpoint const& remote_endpoint) + void connect (beast::IP::Endpoint const& remote_endpoint) { if (isStopping()) { @@ -304,9 +304,9 @@ public: // //-------------------------------------------------------------------------- - void connect (std::vector const& list) + void connect (std::vector const& list) { - for (std::vector ::const_iterator iter (list.begin()); + for (std::vector ::const_iterator iter (list.begin()); iter != list.end(); ++iter) connect (*iter); } @@ -337,7 +337,7 @@ public: protocol::TMEndpoint& tme (*tm.add_endpoints()); if (ep.address.is_v4()) tme.mutable_ipv4()->set_ipv4( - toNetworkByteOrder (ep.address.to_v4().value)); + beast::toNetworkByteOrder (ep.address.to_v4().value)); else tme.mutable_ipv4()->set_ipv4(0); tme.mutable_ipv4()->set_ipv4port (ep.address.port()); @@ -423,7 +423,7 @@ public: m_resolver.resolve (bootstrapIps, [this]( std::string const& name, - std::vector const& addresses) + std::vector const& addresses) { std::vector ips; @@ -443,7 +443,7 @@ public: m_resolver.resolve (getConfig ().IPS_FIXED, [this]( std::string const& name, - std::vector const& addresses) + std::vector const& addresses) { if (!addresses.empty ()) m_peerFinder->addFixedPeer (name, addresses); @@ -512,7 +512,7 @@ public: // //-------------------------------------------------------------------------- - void onWrite (PropertyStream::Map& stream) + void onWrite (beast::PropertyStream::Map& stream) { } @@ -619,7 +619,7 @@ Peers* Peers::New ( Stoppable& parent, Resource::Manager& resourceManager, SiteFiles::Manager& siteFiles, - File const& pathToDbFileOrDirectory, + beast::File const& pathToDbFileOrDirectory, Resolver& resolver, boost::asio::io_service& io_service, boost::asio::ssl::context& ssl_context) diff --git a/src/ripple_overlay/ripple_overlay.h b/src/ripple_overlay/ripple_overlay.h index 5931aa86dc..0007941a30 100644 --- a/src/ripple_overlay/ripple_overlay.h +++ b/src/ripple_overlay/ripple_overlay.h @@ -24,10 +24,6 @@ #include "../ripple_data/ripple_data.h" -namespace ripple { -using namespace beast; -} - #include "api/PackedMessage.h" #include "api/Peer.h" #include "api/Peers.h" diff --git a/src/ripple_rpc/api/Manager.h b/src/ripple_rpc/api/Manager.h index 3e0121d8c1..1713e9a972 100644 --- a/src/ripple_rpc/api/Manager.h +++ b/src/ripple_rpc/api/Manager.h @@ -55,7 +55,7 @@ public: virtual bool dispatch (Request& req) = 0; }; -std::unique_ptr make_Manager (Journal journal); +std::unique_ptr make_Manager (beast::Journal journal); } } diff --git a/src/ripple_rpc/api/Request.h b/src/ripple_rpc/api/Request.h index 027d71dc6e..91cfa799fd 100644 --- a/src/ripple_rpc/api/Request.h +++ b/src/ripple_rpc/api/Request.h @@ -32,7 +32,7 @@ namespace RPC { struct Request { - explicit Request (Journal journal_, + explicit Request (beast::Journal journal_, std::string const& method_, Json::Value& params_, Application& app_) : journal (journal_) @@ -44,7 +44,7 @@ struct Request } // [in] The Journal for logging - Journal journal; + beast::Journal journal; // [in] The JSON-RPC method std::string method; diff --git a/src/ripple_rpc/impl/Manager.cpp b/src/ripple_rpc/impl/Manager.cpp index b5c3137b9f..e4fb2ee5ad 100644 --- a/src/ripple_rpc/impl/Manager.cpp +++ b/src/ripple_rpc/impl/Manager.cpp @@ -31,10 +31,10 @@ class ManagerImp : public Manager public: typedef std::unordered_map Map; - Journal m_journal; + beast::Journal m_journal; Map m_map; - ManagerImp (Journal journal) + ManagerImp (beast::Journal journal) : m_journal (journal) { } @@ -61,7 +61,7 @@ Manager::~Manager () { } -std::unique_ptr make_Manager (Journal journal) +std::unique_ptr make_Manager (beast::Journal journal) { std::unique_ptr m (std::make_unique (journal)); diff --git a/src/ripple_websocket/autosocket/LogWebsockets.cpp b/src/ripple_websocket/autosocket/LogWebsockets.cpp index ecf8754e50..d30193a2b2 100644 --- a/src/ripple_websocket/autosocket/LogWebsockets.cpp +++ b/src/ripple_websocket/autosocket/LogWebsockets.cpp @@ -25,9 +25,7 @@ namespace websocketpp namespace log { -using namespace ripple; - -LogPartition websocketPartition ("WebSocket"); +ripple::LogPartition websocketPartition ("WebSocket"); void websocketLog (websocketpp::log::alevel::value v, const std::string& entry) {