Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates from Pivx Upstream #174

Open
wants to merge 108 commits into
base: release-1.8.0
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
b81eb56
Miner: use std methods instead of boost for timing conditions
Fuzzbawls Oct 14, 2018
d36dbc8
Remove Boost dependency from the httpserver
Fuzzbawls Oct 14, 2018
cdf4e2a
Ust std threading in sync.{h,cpp}
Fuzzbawls Oct 14, 2018
44f8161
[RPC] Show BIP65 soft-fork progress in getblockchaininfo
Fuzzbawls Oct 20, 2018
bd068e5
WIN32 Seed Cleanup: Move nLastPerfmon behind win32 ifdef.
Feb 25, 2015
8d24bcb
nLastTry is only used for addrman entries
sipa Apr 19, 2015
d2cdaac
[Crypto] Switch from openssl to secp256k1 for consensus
Warrows Feb 19, 2018
002aef4
[Tests] Add new auto generated script tests
Warrows Feb 24, 2018
3bbebe8
[Crypto] Bring back function CKey.SetPrivKey for zPIV
Warrows May 9, 2018
7a63c62
[Crypto] Add ctx initialisation for bip38
Warrows Jun 10, 2018
8e304df
[Refactor] Remove begin/end_ptr functions
Warrows Jan 23, 2019
ffb4d90
Wipe zerocoin DB on reindex.
presstab Dec 8, 2017
a819103
[Bug] Fix CMasternodeConfig::read
Fuzzbawls May 2, 2018
670ae61
use c++11 for instead of boost for mnconf count
Fuzzbawls May 2, 2018
ad21d7b
[GUI] Fix wrongly displayed balance on Overview tab
Mrs-X May 6, 2018
1a9ae7c
[Build] Remove unnecessary BOOST dependency
Mrs-X May 10, 2018
fbf04f6
Check whether tx is in chain in ContextualCheckZerocoinMint().
presstab May 11, 2018
9b9ad39
[Build] Make sure Boost headers are included for libzerocoin
Fuzzbawls May 21, 2018
739e6e4
[Qt] Add Tor service icon to status bar
Fuzzbawls May 30, 2018
0d6514c
[UI] Remove useless help button from QT dialogs
Warrows Jun 5, 2018
538fab9
Move non-wallet RPC files to subdir
KolbyML Mar 13, 2020
c6ee535
Remove unnecessary namespace declarations
Fuzzbawls Jul 23, 2018
f5dcf5a
Remove boost dependency
Fuzzbawls Jul 23, 2018
f779b29
Clean up header includes
Fuzzbawls Jul 23, 2018
6821991
Add proper translation functions for user facing strings
Fuzzbawls Jul 23, 2018
7811144
Remove useless returns
Fuzzbawls Jul 23, 2018
134eacd
Comment/Whitespace/nullptr cleanup
Fuzzbawls Jul 23, 2018
61d6ac9
fix double locked coin when wallet and MN are on same machine
tofutim Jul 13, 2018
5f42959
GUI - sendcoins dialog: fee / SwiftX - intuitiveness
random-zebra Aug 1, 2018
fbfafdc
[Qt] Fix PIV balances on overview page
Fuzzbawls Jul 12, 2018
04130df
use c++11 for instead of boost for writeToMasternodeConf
KolbyML Mar 13, 2020
adee848
Fixes for tor
KolbyML Mar 13, 2020
50b68f7
Fixed bug in multisend
KolbyML Mar 13, 2020
7a730b1
Remove leveldb path in prep for subtree init
Fuzzbawls Jul 12, 2018
f4a667b
build: Build system changes to support only Qt5
laanwj Jun 13, 2018
b6a6c58
gui: Remove QT_VERSION fallbacks for Qt < 5
laanwj Jun 13, 2018
824dfc2
[Docu] Add missing automake dependency
Mrs-X Aug 26, 2018
ce74323
[UI] Add address to the payment request history
Warrows Aug 15, 2018
3825283
[Wallet] Avoid autocombine getting stuck
Warrows Aug 22, 2018
ebc70d7
[Build] Remove stale m4 file
Fuzzbawls Aug 17, 2018
5b38882
[RPC]: Don't allow backupwallet to overwrite the wallet-in-use
Fuzzbawls Sep 10, 2018
85b685a
GCC-7 and glibc-2.27 compat code
ken2812221 May 5, 2018
d475dc3
Use IN6ADDR_ANY_INIT instead of in6addr_any
Fuzzbawls Aug 27, 2018
6c87548
[Refactor] Remove GetCoinAge
Fuzzbawls Sep 20, 2018
d7b5832
[RPC] Fix verifychain
Fuzzbawls Sep 17, 2018
0f71c50
[RPC] Sanitize walletpassphrase timeout argument
Fuzzbawls Sep 17, 2018
4593d89
[RPC] Fix movecmd's help description to include amount
Fuzzbawls Sep 24, 2018
244c0d8
[RPC] Error when calling getreceivedbyaddress with non-wallet address
Fuzzbawls Sep 9, 2018
fde8f9a
fix bug with fWalletUnlockAnonymizeOnly flag setting
random-zebra Oct 2, 2018
e84827e
Stop using dummy strings in clientversion
Fuzzbawls Jul 13, 2018
a2a25be
[GUI] Add option to hide orphans in overview and txlist
random-zebra Oct 7, 2018
0c0a89b
[Utils] Update linters for python3
Fuzzbawls Sep 2, 2018
8f22d1c
[RPC]: Fix RPCTimerInterface ordering issue (https://github.com/bitco…
random-zebra Oct 3, 2018
2942f52
Replace 'boost::lexical_cast<std::string>' with 'std::to_string'
random-zebra Oct 7, 2018
a6d34fa
Replace 'const boost::bad_lexical_cast' with 'std::invalid_argument'
random-zebra Oct 7, 2018
250506d
Replace 'boost::lexical_cast<std::int>' with 'std::stoi'
random-zebra Oct 7, 2018
9601f0d
[Net] Pull uacomment in from upstream
Fuzzbawls Sep 19, 2018
f11afb9
Add masternode's pubkey to listmasternodes RPC
presstab Oct 10, 2018
5b38ec4
[RPC] Add mediantime to getblock/getblockheader output
Fuzzbawls Sep 19, 2018
a478538
[RPC] Show the configured/set txfee in getwalletinfo
Fuzzbawls Sep 19, 2018
e0cb565
[Build] Update genbuild.sh script
Fuzzbawls Sep 2, 2018
50493da
[Main] Unify shutdown proceedure in init rather than per-app
Fuzzbawls Nov 14, 2018
2c4e3ea
[GUI] Add action to hide orphans in overview and txlist
random-zebra Oct 8, 2018
49eee10
Remove Boost dependency from sync.cpp
Fuzzbawls Nov 15, 2018
5fe6a8f
Initialize lockstack to prevent null pointer deref
Fuzzbawls Nov 15, 2018
fb9cb1b
Remove unused fTry from push_lock
Fuzzbawls Nov 15, 2018
73d2fb8
Use c++11 nullptr instead of macros or void(0) in sync.cpp/h
Fuzzbawls Nov 15, 2018
2fe725f
Finalize cleanup of sync.cpp/h
Fuzzbawls Nov 15, 2018
8c81703
[Qt] Don't show staking/automint status icons without a wallet
Fuzzbawls Dec 14, 2018
ed4012a
fixed case nAnonymizePhoreAmount:
KolbyML Mar 14, 2020
7204399
ionRecord::StakeZPIV
KolbyML Mar 14, 2020
475c9b8
Depends: Update to most recent version
Fuzzbawls Aug 17, 2018
af123af
Update README.md
KolbyML Mar 14, 2020
0c1a764
Build: Add automated man page generation
Fuzzbawls Aug 18, 2018
9be21de
Build: Update coverage build target(s)
Fuzzbawls Aug 18, 2018
8d88d67
Build: Add bash completion support to the build system
Fuzzbawls Oct 17, 2018
e9007c3
Build: Introduce endian and byteswap
Fuzzbawls Jul 13, 2018
13a9e24
Build: Show PIC/PIE flags in configure summary
Fuzzbawls Aug 17, 2018
3e4248b
Build: Update build system to upstream master
Fuzzbawls Aug 18, 2018
ae2ae12
Update configure.ac
KolbyML Mar 14, 2020
4ac5150
Build: Introduce Symbol and Security check scripts to the build system.
Fuzzbawls Oct 17, 2018
ef75157
Build: utility test updates
Fuzzbawls Jul 14, 2018
1fb9d15
Gitian: remove reference datetime
Fuzzbawls Aug 17, 2018
db850e5
Gitian: update descriptors for bionic
Fuzzbawls Jul 21, 2018
8b36eb1
Contrib: Update macdeployqtplus subdir
Fuzzbawls Sep 4, 2018
4e55e6a
Update packages.mk
KolbyML Mar 14, 2020
386a52b
Update protobuf.mk
KolbyML Mar 14, 2020
f78dada
fixes for changes
KolbyML Mar 14, 2020
c72627f
Merge #783: [Depends] Update QT to 5.9.7
Fuzzbawls Jan 9, 2019
75f2c3b
Fix Missing Explorer Icon
sicXnull Jan 5, 2019
e61f804
Merge #795: [Build] Add support for RISC-V and build it with gitian
Mrs-X Jan 20, 2019
f84aadd
Update qt.mk
KolbyML Mar 14, 2020
61be3a4
Improve addrman Select() performance when buckets are nearly empty
sipa Aug 6, 2015
3a09580
Update zmq to 4.3.1
rex4539 Jan 17, 2019
7922e3c
cleanup, remove trading dialog form
furszy Mar 20, 2019
5663208
fix to display missing clock5.png tx image
joeuhren Mar 25, 2019
4bb73fe
[macOS] Remove DS_Store WindowBounds bytes object
jonasschnelli Oct 18, 2018
e5d8cb7
Fixed some names in a few files
KolbyML Mar 14, 2020
6f3249d
[Travis] Add separate job to check doc/logprint/subtree
Fuzzbawls Jun 19, 2018
ffc0a86
travis: run subtree checks for leveldb
Fuzzbawls Jul 12, 2018
02bbc02
Travis: Update to use docker with Bionic target
Fuzzbawls Aug 17, 2018
07eb90f
Travis: Introduce .travis subdir and better job folding
Fuzzbawls Sep 2, 2018
f93e697
Update .travis.yml
KolbyML Mar 14, 2020
ae8b73b
[Refactor] Delete secp256k1 folder for subtreefication
Warrows May 9, 2018
f8de61b
Merge commit '8a901f93d505af3516353837600fd71a0c53a692' as 'src/secp2…
Warrows May 9, 2018
e55c1df
Merge commit 'c6634ef065ceb295522f0d61a3d45d8d53abe51c' into libsecp_…
Warrows Oct 23, 2018
da72b62
Merge commit '4f5b53da1af363a5c41acc8e1d82f37dd7f393d9' as 'src/leveldb'
Fuzzbawls Jul 12, 2018
043e609
fixes for leveldb and travis
KolbyML Mar 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove Boost dependency from the httpserver
Fuzzbawls authored and KolbyML committed Mar 7, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit d36dbc8ba65d434f896c16ea06a10cd1c42ad4b9
62 changes: 31 additions & 31 deletions src/httpserver.cpp
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <future>

#include <event2/event.h>
#include <event2/http.h>
@@ -34,10 +35,6 @@
#endif
#endif

#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
#include <boost/foreach.hpp>
#include <boost/scoped_ptr.hpp>

/** Maximum size of http request (request line + headers) */
static const size_t MAX_HEADERS_SIZE = 8192;

@@ -54,7 +51,7 @@ class HTTPWorkItem : public HTTPClosure
func(req.get(), path);
}

boost::scoped_ptr<HTTPRequest> req;
std::unique_ptr<HTTPRequest> req;

private:
std::string path;
@@ -69,8 +66,8 @@ class WorkQueue
{
private:
/** Mutex protects entire object */
CWaitableCriticalSection cs;
CConditionVariable cond;
std::mutex cs;
std::condition_variable cond;
/* XXX in C++11 we can use std::unique_ptr here and avoid manual cleanup */
std::deque<WorkItem*> queue;
bool running;
@@ -84,12 +81,12 @@ class WorkQueue
WorkQueue &wq;
ThreadCounter(WorkQueue &w): wq(w)
{
boost::lock_guard<boost::mutex> lock(wq.cs);
std::lock_guard<std::mutex> lock(wq.cs);
wq.numThreads += 1;
}
~ThreadCounter()
{
boost::lock_guard<boost::mutex> lock(wq.cs);
std::lock_guard<std::mutex> lock(wq.cs);
wq.numThreads -= 1;
wq.cond.notify_all();
}
@@ -114,7 +111,7 @@ class WorkQueue
/** Enqueue a work item */
bool Enqueue(WorkItem* item)
{
boost::unique_lock<boost::mutex> lock(cs);
std::unique_lock<std::mutex> lock(cs);
if (queue.size() >= maxDepth) {
return false;
}
@@ -129,7 +126,7 @@ class WorkQueue
while (running) {
WorkItem* i = 0;
{
boost::unique_lock<boost::mutex> lock(cs);
std::unique_lock<std::mutex> lock(cs);
while (running && queue.empty())
cond.wait(lock);
if (!running)
@@ -144,22 +141,22 @@ class WorkQueue
/** Interrupt and exit loops */
void Interrupt()
{
boost::unique_lock<boost::mutex> lock(cs);
std::unique_lock<std::mutex> lock(cs);
running = false;
cond.notify_all();
}
/** Wait for worker threads to exit */
void WaitExit()
{
boost::unique_lock<boost::mutex> lock(cs);
std::unique_lock<std::mutex> lock(cs);
while (numThreads > 0)
cond.wait(lock);
}

/** Return current depth of queue */
size_t Depth()
{
boost::unique_lock<boost::mutex> lock(cs);
std::unique_lock<std::mutex> lock(cs);
return queue.size();
}
};
@@ -195,7 +192,7 @@ static bool ClientAllowed(const CNetAddr& netaddr)
{
if (!netaddr.IsValid())
return false;
BOOST_FOREACH (const CSubNet& subnet, rpc_allow_subnets)
for (const CSubNet& subnet : rpc_allow_subnets)
if (subnet.Match(netaddr))
return true;
return false;
@@ -209,7 +206,7 @@ static bool InitHTTPAllowList()
rpc_allow_subnets.push_back(CSubNet("::1")); // always allow IPv6 localhost
if (mapMultiArgs.count("-rpcallowip")) {
const std::vector<std::string>& vAllow = mapMultiArgs["-rpcallowip"];
BOOST_FOREACH (std::string strAllow, vAllow) {
for (std::string strAllow : vAllow) {
CSubNet subnet(strAllow);
if (!subnet.IsValid()) {
uiInterface.ThreadSafeMessageBox(
@@ -221,7 +218,7 @@ static bool InitHTTPAllowList()
}
}
std::string strAllowed;
BOOST_FOREACH (const CSubNet& subnet, rpc_allow_subnets)
for (const CSubNet& subnet : rpc_allow_subnets)
strAllowed += subnet.ToString() + " ";
LogPrint("http", "Allowing HTTP connections from: %s\n", strAllowed);
return true;
@@ -305,13 +302,14 @@ static void http_reject_request_cb(struct evhttp_request* req, void*)
evhttp_send_error(req, HTTP_SERVUNAVAIL, NULL);
}
/** Event dispatcher thread */
static void ThreadHTTP(struct event_base* base, struct evhttp* http)
static bool ThreadHTTP(struct event_base* base, struct evhttp* http)
{
RenameThread("bitcoin-http");
LogPrint("http", "Entering http event loop\n");
event_base_dispatch(base);
// Event loop will be interrupted by InterruptHTTPServer()
LogPrint("http", "Exited http event loop\n");
return event_base_got_break(base) == 0;
}

/** Bind HTTP server to specified addresses */
@@ -440,25 +438,30 @@ bool InitHTTPServer()
return true;
}

boost::thread threadHTTP;
std::thread threadHTTP;
std::future<bool> threadResult;

bool StartHTTPServer()
{
LogPrint("http", "Starting HTTP server\n");
int rpcThreads = std::max((long)GetArg("-rpcthreads", DEFAULT_HTTP_THREADS), 1L);
LogPrintf("HTTP: starting %d worker threads\n", rpcThreads);
threadHTTP = boost::thread(boost::bind(&ThreadHTTP, eventBase, eventHTTP));
std::packaged_task<bool(event_base*, evhttp*)> task(ThreadHTTP);
threadResult = task.get_future();
threadHTTP = std::thread(std::move(task), eventBase, eventHTTP);

for (int i = 0; i < rpcThreads; i++)
boost::thread(boost::bind(&HTTPWorkQueueRun, workQueue));
for (int i = 0; i < rpcThreads; i++) {
std::thread rpc_worker(HTTPWorkQueueRun, workQueue);
rpc_worker.detach();
}
return true;
}

void InterruptHTTPServer()
{
LogPrint("http", "Interrupting HTTP server\n");
if (eventHTTP) {
BOOST_FOREACH (evhttp_bound_socket *socket, boundSockets) {
for (evhttp_bound_socket *socket : boundSockets) {
evhttp_del_accept_socket(eventHTTP, socket);
}
evhttp_set_gencb(eventHTTP, http_reject_request_cb, NULL);
@@ -484,15 +487,12 @@ void StopHTTPServer()
// master that appears to be solved, so in the future that solution
// could be used again (if desirable).
// (see discussion in https://github.com/bitcoin/bitcoin/pull/6990)
#if BOOST_VERSION >= 105000
if (!threadHTTP.try_join_for(boost::chrono::milliseconds(2000))) {
#else
if (!threadHTTP.timed_join(boost::posix_time::milliseconds(2000))) {
#endif
if (threadResult.valid() && threadResult.wait_for(std::chrono::milliseconds(2000)) == std::future_status::timeout) {
LogPrintf("HTTP event loop did not exit within allotted time, sending loopbreak\n");
event_base_loopbreak(eventBase);
threadHTTP.join();

}
threadHTTP.join();
}
if (eventHTTP) {
evhttp_free(eventHTTP);
@@ -519,7 +519,7 @@ static void httpevent_callback_fn(evutil_socket_t, short, void* data)
delete self;
}

HTTPEvent::HTTPEvent(struct event_base* base, bool deleteWhenTriggered, const boost::function<void(void)>& handler):
HTTPEvent::HTTPEvent(struct event_base* base, bool deleteWhenTriggered, const std::function<void(void)>& handler):
deleteWhenTriggered(deleteWhenTriggered), handler(handler)
{
ev = event_new(base, -1, 0, httpevent_callback_fn, this);
@@ -601,7 +601,7 @@ void HTTPRequest::WriteReply(int nStatus, const std::string& strReply)
assert(evb);
evbuffer_add(evb, strReply.data(), strReply.size());
HTTPEvent* ev = new HTTPEvent(eventBase, true,
boost::bind(evhttp_send_reply, req, nStatus, (const char*)NULL, (struct evbuffer *)NULL));
std::bind(evhttp_send_reply, req, nStatus, (const char*)NULL, (struct evbuffer *)NULL));
ev->trigger(0);
replySent = true;
req = 0; // transferred back to main thread
10 changes: 4 additions & 6 deletions src/httpserver.h
Original file line number Diff line number Diff line change
@@ -7,9 +7,7 @@

#include <string>
#include <stdint.h>
#include <boost/thread.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/function.hpp>
#include <functional>

static const int DEFAULT_RPC_SERIALIZE_VERSION = 1;
static const int DEFAULT_HTTP_THREADS=4;
@@ -36,7 +34,7 @@ void InterruptHTTPServer();
void StopHTTPServer();

/** Handler for requests to a certain HTTP path */
typedef boost::function<void(HTTPRequest* req, const std::string &)> HTTPRequestHandler;
typedef std::function<void(HTTPRequest* req, const std::string &)> HTTPRequestHandler;
/** Register handler for prefix.
* If multiple handlers match a prefix, the first-registered one will
* be invoked.
@@ -133,7 +131,7 @@ class HTTPEvent
* deleteWhenTriggered deletes this event object after the event is triggered (and the handler called)
* handler is the handler to call when the event is triggered.
*/
HTTPEvent(struct event_base* base, bool deleteWhenTriggered, const boost::function<void(void)>& handler);
HTTPEvent(struct event_base* base, bool deleteWhenTriggered, const std::function<void(void)>& handler);
~HTTPEvent();

/** Trigger the event. If tv is 0, trigger it immediately. Otherwise trigger it after
@@ -142,7 +140,7 @@ class HTTPEvent
void trigger(struct timeval* tv);

bool deleteWhenTriggered;
boost::function<void(void)> handler;
std::function<void(void)> handler;
private:
struct event* ev;
};