[BTC-dev] some notes after reading the source

pub at extemporized.com pub at extemporized.com
Sun Aug 16 05:18:36 UTC 2015


URL: <http://therealbitcoin.org/ml/btc-dev/attachments/20150816/attachment_534a1658dc7a6d0de0f7d5a76a29f35981addaf6.txt>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

I was taking some notes while reading the source and thought I'd post them here.

## AbandonRequests

Leftover from the GUI days, missed it on the first pass. It's not used anywhere 
in the current codebase.

CRequestTracker and mapRequests also seem associated with this, which in turn 
lead to the following blocks in ProcessMessage:

- -- else if (strCommand == "reply") { ... }
- -- else if (strCommand == "checkorder") { ... }

"checkorder" and "reply" seems to have been used for legacy functionality of 
"send bitcoin to IP address". 

I think all these barnacles can be safely removed.


## SetThreadPriority / AffinityBugWorkaround

Something about thread priorites on Windows, to give higher priority to mining 
threads. In the bin it goes.


## IMPLEMENT_RANDOMIZE_STACK

"Randomize the stack to help protect against buffer overrun exploits"

This is stupid right?

## CreateThread

Like the comment says: "// Note: It turns out we might have been able to use 
boost::thread"


## GetWarnings

More leftovers from the GUI days, however it's still used in ThreadRPCServer2.

GetWarnings reads the global variable strMiscWarning to check for certain 
errors. It also checks for "Longer invalid proof-of-work chain" every time it's 
called.

strMiscWarning can contain messages about:
- -- low disk space, set by CheckDiskSpace
- -- exceptions, set by PrintException and PrintExceptionContinue
- -- clock problems, set by  AddTimeData

If the return value of GetWarnings is not empty, ThreadRPCServer2 throws a 
JSONRPCError exception.


## Various unused functions

- -- inline std::string i64tostr(int64 n)
- -- inline int roundint(double d)
- -- void PrintHex(const T pbegin, const T pend, const char* pszFormat="%s", bool 
fSpaces=true)
- -- inline void PrintHex(const std::vector<unsigned char>& vch, const char* 
pszFormat="%s", bool fSpaces=true)
- -- void skipspaces(T& it)
- -- inline void heapchk()
- -- #define CATCH_PRINT_EXCEPTION(pszFn) 
- -- Value getblocknumber(const Array& params, bool fHelp)

## Functions used exactly once

Might be nice to transplant these small things inside the functions that call 
them.

- -- inline std::string itostr(int n) 
- -- inline int64 roundint64(double d) 
- -- inline int64 abs64(int64 n)  
- -- inline int64 GetPerformanceCounter()
- -- inline bool IsSwitchChar(char c)


- ----------------

## Project ideas for aspiring patchers

### json_spirit

Replace that json_spirit crap with a saner json library. Doesn't boost have one?

Prompted by this comment:
// MinGW 3.4.5 gets "fatal error: had to relocate PCH" if the json headers are
// precompiled in headers.h.  The problem might be when the pch file goes over
// a certain size around 145MB.  If we need access to json_spirit outside this
// file, we could use the compiled json_spirit option.

### getinfo

Add some useful data/metrics to getinfo.

### GetDefaultDataDir, GetDataDir, GetConfigFile, ReadConfigFile, help()

These look like they could be improved/simplified. 







-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)

iQIcBAEBCgAGBQJV0By9AAoJEDNYi+CLIysT5C8P/iVJSOzFQk/2hmfsUpS7qDaa
Ws6pvunRObllG36LK3JJtG3E6/D+KgOX+rn3VaFPo2jCwBZxp04ZN/0KZZJeWYcU
e7fSJUYYhkjy6LkB3u4xb08sdqZiGSaDRO/eV3U+hDpA+p3T9JFZGQpVTs73DEzZ
jBNSLa23J2KZwGb0ZM1wJVkHJU2HG/mIx/rMZ+Lt95DOP73oZX3fp3gVN2WlRNr4
2cLtVzkbzBOm3ICEsBhn7RmikieLZPEJ2BC8GPbrh1HQSHt4o8AstNAigk5D7mrA
jrXMW4gKnjMEc3jc6FU1gB4z51LbgquwXEGS4wPL9XFCVFFn4K/FK8KxhO2BS++t
QVae1wZSGnOFoiNEqKjz6XWk/ZbvnDJXX2EbntZdFmsNrVbE1KX7VmlQg8Om2et/
TrXqXKBtd2xAfwKD3OKHHkT2QLQ2RryfRya8etKfjhZ0JZ1C6TXuJWeCyov4R613
nHzRhLTokafreSGyY5uomFhFbTOqA9eM8yV8xK/BsX3Du7eHz1X7IIcitF1usCGA
Za93AJiVj9nTrAPp54SfVYiuOgJTRwkCfOxYUhBA76y8eFPtwrWZaFzsxcsEvh79
/MGKdZLd8bq7At0mUHFgk4ObP77tk9pddbvGisgstT3s1+JeJ6g4bZRbw6aV9rvD
xwOkm//Pei/6DWMdneMA
=QuvA
-----END PGP SIGNATURE-----




More information about the BTC-dev mailing list