retry IRC if name in use,

resize to fit ubuntu's giant default font, 
scroll debug.log, 
pause gen during initial block download

git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@44 1a98c847-1fd6-4fd8-948a-caf3550aa51b
This commit is contained in:
s_nakamoto 2009-12-11 16:49:21 +00:00
parent b075bbf986
commit 4ea3f3da1a
13 changed files with 187 additions and 89 deletions

View File

@ -9,7 +9,7 @@ cryptographic software written by Eric Young (eay@cryptsoft.com).
WINDOWS BUILD NOTES WINDOWS BUILD NOTES
===================
Compilers Supported Compilers Supported
------------------- -------------------
@ -19,7 +19,7 @@ Microsoft Visual C++ 6.0 SP6
Dependencies Dependencies
------------ ------------
Libraries you need to obtain separately to build: Libraries you need to download separately and build:
default path download default path download
wxWidgets \wxwidgets http://www.wxwidgets.org/downloads/ wxWidgets \wxwidgets http://www.wxwidgets.org/downloads/
@ -44,7 +44,7 @@ Boost 1.34.1
Notes Notes
----- -----
The UI layout is edited with wxFormBuilder. Open the project file The UI layout is edited with wxFormBuilder. The project file is
uiproject.fbp. It generates uibase.cpp and uibase.h, which define base uiproject.fbp. It generates uibase.cpp and uibase.h, which define base
classes that do the rote work of constructing all the UI elements. classes that do the rote work of constructing all the UI elements.

View File

@ -9,7 +9,7 @@ cryptographic software written by Eric Young (eay@cryptsoft.com).
UNIX BUILD NOTES UNIX BUILD NOTES
================
Dependencies Dependencies
------------ ------------
@ -20,11 +20,10 @@ apt-get install libdb4.7-dev
apt-get install libdb4.7++-dev apt-get install libdb4.7++-dev
apt-get install libboost-dev apt-get install libboost-dev
Libraries you need to obtain separately and build: You need to download wxWidgets from http://www.wxwidgets.org/downloads/
default path download and build it yourself.
wxWidgets \wxwidgets http://www.wxwidgets.org/downloads/
Licenses: Licenses of statically linked libraries:
wxWidgets LGPL 2.1 with very liberal exceptions wxWidgets LGPL 2.1 with very liberal exceptions
Berkeley DB New BSD license with additional requirement that linked software must be free open source Berkeley DB New BSD license with additional requirement that linked software must be free open source
Boost MIT-like license Boost MIT-like license
@ -39,7 +38,7 @@ Boost 1.40.0
Notes Notes
----- -----
The UI layout is edited with wxFormBuilder. Open the project file The UI layout is edited with wxFormBuilder. The project file is
uiproject.fbp. It generates uibase.cpp and uibase.h, which define base uiproject.fbp. It generates uibase.cpp and uibase.h, which define base
classes that do the rote work of constructing all the UI elements. classes that do the rote work of constructing all the UI elements.
@ -61,7 +60,7 @@ ldconfig
Boost Boost
----- -----
If you download and build Boost yourself If you want to build Boost yourself,
cd /usr/local/boost_1_40_0 cd /usr/local/boost_1_40_0
su su
./bootstrap.sh ./bootstrap.sh

21
db.cpp
View File

@ -445,7 +445,7 @@ bool CAddrDB::LoadAddresses()
CRITICAL_BLOCK(cs_mapAddresses) CRITICAL_BLOCK(cs_mapAddresses)
{ {
// Load user provided addresses // Load user provided addresses
CAutoFile filein = fopen("addr.txt", "rt"); CAutoFile filein = fopen((GetDataDir() + "/addr.txt").c_str(), "rt");
if (filein) if (filein)
{ {
try try
@ -536,10 +536,11 @@ bool CReviewDB::WriteReviews(uint256 hash, const vector<CReview>& vReviews)
bool CWalletDB::LoadWallet(vector<unsigned char>& vchDefaultKeyRet) bool CWalletDB::LoadWallet(vector<unsigned char>& vchDefaultKeyRet)
{ {
vchDefaultKeyRet.clear(); vchDefaultKeyRet.clear();
int nFileVersion = 0;
// Modify defaults // Modify defaults
#ifndef __WXMSW__ #ifndef __WXMSW__
// Reports that tray icon can disappear on gnome, leaving no way to access the program // Tray icon sometimes disappears on 9.10 karmic koala 64-bit, leaving no way to access the program
fMinimizeToTray = false; fMinimizeToTray = false;
fMinimizeOnClose = false; fMinimizeOnClose = false;
#endif #endif
@ -607,6 +608,10 @@ bool CWalletDB::LoadWallet(vector<unsigned char>& vchDefaultKeyRet)
{ {
ssValue >> vchDefaultKeyRet; ssValue >> vchDefaultKeyRet;
} }
else if (strType == "version")
{
ssValue >> nFileVersion;
}
else if (strType == "setting") else if (strType == "setting")
{ {
string strKey; string strKey;
@ -649,6 +654,16 @@ bool CWalletDB::LoadWallet(vector<unsigned char>& vchDefaultKeyRet)
WriteSetting("nTransactionFee", nTransactionFee); WriteSetting("nTransactionFee", nTransactionFee);
} }
// Upgrade
if (nFileVersion < VERSION)
{
// Get rid of old debug.log file in current directory
if (nFileVersion <= 105 && !pszSetDataDir[0])
unlink("debug.log");
WriteVersion(VERSION);
}
return true; return true;
} }
@ -656,7 +671,7 @@ bool LoadWallet(bool& fFirstRunRet)
{ {
fFirstRunRet = false; fFirstRunRet = false;
vector<unsigned char> vchDefaultKey; vector<unsigned char> vchDefaultKey;
if (!CWalletDB("cr").LoadWallet(vchDefaultKey)) if (!CWalletDB("cr+").LoadWallet(vchDefaultKey))
return false; return false;
fFirstRunRet = vchDefaultKey.empty(); fFirstRunRet = vchDefaultKey.empty();

23
irc.cpp
View File

@ -121,20 +121,20 @@ bool RecvLineIRC(SOCKET hSocket, string& strLine)
} }
} }
bool RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const char* psz3=NULL) int RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const char* psz3=NULL)
{ {
loop loop
{ {
string strLine; string strLine;
if (!RecvLineIRC(hSocket, strLine)) if (!RecvLineIRC(hSocket, strLine))
return false; return 0;
printf("IRC %s\n", strLine.c_str()); printf("IRC %s\n", strLine.c_str());
if (psz1 && strLine.find(psz1) != -1) if (psz1 && strLine.find(psz1) != -1)
return true; return 1;
if (psz2 && strLine.find(psz2) != -1) if (psz2 && strLine.find(psz2) != -1)
return true; return 2;
if (psz3 && strLine.find(psz3) != -1) if (psz3 && strLine.find(psz3) != -1)
return true; return 3;
} }
} }
@ -159,6 +159,7 @@ void ThreadIRCSeed(void* parg)
SetThreadPriority(THREAD_PRIORITY_NORMAL); SetThreadPriority(THREAD_PRIORITY_NORMAL);
int nErrorWait = 10; int nErrorWait = 10;
int nRetryWait = 10; int nRetryWait = 10;
bool fNameInUse = false;
bool fTOR = (fUseProxy && addrProxy.port == htons(9050)); bool fTOR = (fUseProxy && addrProxy.port == htons(9050));
while (!fShutdown) while (!fShutdown)
@ -194,7 +195,7 @@ void ThreadIRCSeed(void* parg)
} }
string strMyName; string strMyName;
if (addrLocalHost.IsRoutable() && !fUseProxy) if (addrLocalHost.IsRoutable() && !fUseProxy && !fNameInUse)
strMyName = EncodeAddress(addrLocalHost); strMyName = EncodeAddress(addrLocalHost);
else else
strMyName = strprintf("x%u", GetRand(1000000000)); strMyName = strprintf("x%u", GetRand(1000000000));
@ -203,10 +204,18 @@ void ThreadIRCSeed(void* parg)
Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str()); Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str());
Send(hSocket, strprintf("USER %s 8 * : %s\r", strMyName.c_str(), strMyName.c_str()).c_str()); Send(hSocket, strprintf("USER %s 8 * : %s\r", strMyName.c_str(), strMyName.c_str()).c_str());
if (!RecvUntil(hSocket, " 004 ")) int nRet = RecvUntil(hSocket, " 004 ", " 433 ");
if (nRet != 1)
{ {
closesocket(hSocket); closesocket(hSocket);
hSocket = INVALID_SOCKET; hSocket = INVALID_SOCKET;
if (nRet == 2)
{
printf("IRC name already in use\n");
fNameInUse = true;
Wait(10);
continue;
}
nErrorWait = nErrorWait * 11 / 10; nErrorWait = nErrorWait * 11 / 10;
if (Wait(nErrorWait += 60)) if (Wait(nErrorWait += 60))
continue; continue;

View File

@ -2530,7 +2530,7 @@ void BitcoinMiner()
// //
// Search // Search
// //
unsigned int nStart = GetTime(); int64 nStart = GetTime();
uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
uint256 hash; uint256 hash;
loop loop
@ -2582,14 +2582,27 @@ void BitcoinMiner()
return; return;
if (fLimitProcessors && vnThreadsRunning[3] > nLimitProcessors) if (fLimitProcessors && vnThreadsRunning[3] > nLimitProcessors)
return; return;
if (tmp.block.nNonce == 0) if (vNodes.empty())
break; break;
if (pindexPrev != pindexBest) if (tmp.block.nNonce == 0)
break; break;
if (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60) if (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60)
break; break;
if (vNodes.empty()) if (pindexPrev != pindexBest)
{
// Pause generating during initial download
if (GetTime() - nStart < 20)
{
CBlockIndex* pindexTmp;
do
{
pindexTmp = pindexBest;
Sleep(10000);
}
while (pindexTmp != pindexBest);
}
break; break;
}
tmp.block.nTime = pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); tmp.block.nTime = pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
} }
} }

View File

@ -10,8 +10,6 @@ endif
endif endif
ifeq "$(BUILD)" "debug" ifeq "$(BUILD)" "debug"
D=d D=d
# note: gcc 3.x profile doesn't work
#DEBUGFLAGS=-O0 -g -pg -D__WXDEBUG__
DEBUGFLAGS=-g -D__WXDEBUG__ DEBUGFLAGS=-g -D__WXDEBUG__
endif endif
@ -36,34 +34,34 @@ all: bitcoin.exe
headers.h.gch: headers.h $(HEADERS) net.h irc.h market.h uibase.h ui.h headers.h.gch: headers.h $(HEADERS) net.h irc.h market.h uibase.h ui.h
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/util.o: util.cpp $(HEADERS) obj/util.o: util.cpp $(HEADERS)
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/script.o: script.cpp $(HEADERS) obj/script.o: script.cpp $(HEADERS)
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/db.o: db.cpp $(HEADERS) market.h obj/db.o: db.cpp $(HEADERS) market.h
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/net.o: net.cpp $(HEADERS) net.h obj/net.o: net.cpp $(HEADERS) net.h
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/main.o: main.cpp $(HEADERS) net.h market.h sha.h obj/main.o: main.cpp $(HEADERS) net.h market.h sha.h
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/market.o: market.cpp $(HEADERS) market.h obj/market.o: market.cpp $(HEADERS) market.h
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/ui.o: ui.cpp $(HEADERS) net.h uibase.h ui.h market.h obj/ui.o: ui.cpp $(HEADERS) net.h uibase.h ui.h market.h
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/uibase.o: uibase.cpp uibase.h obj/uibase.o: uibase.cpp uibase.h
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/sha.o: sha.cpp sha.h obj/sha.o: sha.cpp sha.h
g++ -c $(CFLAGS) -O3 -o $@ $< g++ -c $(CFLAGS) -O3 -o $@ $<
obj/irc.o: irc.cpp $(HEADERS) obj/irc.o: irc.cpp $(HEADERS)
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/ui_res.o: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp obj/ui_res.o: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp
@ -71,8 +69,8 @@ obj/ui_res.o: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp
OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \ OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \
obj/ui.o obj/uibase.o obj/sha.o obj/irc.o obj/ui_res.o obj/ui.o obj/uibase.o obj/sha.o obj/irc.o obj/ui_res.o
bitcoin.exe: headers.h.gch $(OBJS) bitcoin.exe: headers.h.gch $(OBJS)
-kill /f bitcoin.exe -kill /f bitcoin.exe

View File

@ -22,13 +22,16 @@ INCLUDEPATHS= \
LIBPATHS= \ LIBPATHS= \
-L"/usr/lib" \ -L"/usr/lib" \
-L"/usr/local/lib" \ -L"/usr/local/lib"
LIBS= \ LIBS= \
-Wl,-Bstatic -l boost_system -l boost_filesystem -Wl,-Bdynamic \ -Wl,-Bstatic \
-Wl,-Bstatic -l db_cxx -l wx_gtk2$(D)-2.8 -Wl,-Bdynamic \ -l boost_system -l boost_filesystem \
-l crypto \ -l db_cxx \
-l gtk-x11-2.0 -l gthread-2.0 -l SM -l wx_gtk2$(D)-2.8 \
-Wl,-Bdynamic \
-l crypto \
-l gtk-x11-2.0 -l gthread-2.0 -l SM
WXDEFS=-D__WXGTK__ -DNOPCH WXDEFS=-D__WXGTK__ -DNOPCH
CFLAGS=-O0 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS) CFLAGS=-O0 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)
@ -42,41 +45,41 @@ all: bitcoin
headers.h.gch: headers.h $(HEADERS) net.h irc.h market.h uibase.h ui.h headers.h.gch: headers.h $(HEADERS) net.h irc.h market.h uibase.h ui.h
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/util.o: util.cpp $(HEADERS) obj/util.o: util.cpp $(HEADERS)
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/script.o: script.cpp $(HEADERS) obj/script.o: script.cpp $(HEADERS)
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/db.o: db.cpp $(HEADERS) market.h obj/db.o: db.cpp $(HEADERS) market.h
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/net.o: net.cpp $(HEADERS) net.h obj/net.o: net.cpp $(HEADERS) net.h
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/main.o: main.cpp $(HEADERS) net.h market.h sha.h obj/main.o: main.cpp $(HEADERS) net.h market.h sha.h
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/market.o: market.cpp $(HEADERS) market.h obj/market.o: market.cpp $(HEADERS) market.h
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/ui.o: ui.cpp $(HEADERS) net.h uibase.h ui.h market.h obj/ui.o: ui.cpp $(HEADERS) net.h uibase.h ui.h market.h
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/uibase.o: uibase.cpp uibase.h obj/uibase.o: uibase.cpp uibase.h
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
obj/sha.o: sha.cpp sha.h obj/sha.o: sha.cpp sha.h
g++ -c $(CFLAGS) -O3 -o $@ $< g++ -c $(CFLAGS) -O3 -o $@ $<
obj/irc.o: irc.cpp $(HEADERS) obj/irc.o: irc.cpp $(HEADERS)
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \ OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \
obj/ui.o obj/uibase.o obj/sha.o obj/irc.o obj/ui.o obj/uibase.o obj/sha.o obj/irc.o
bitcoin: headers.h.gch $(OBJS) bitcoin: headers.h.gch $(OBJS)
g++ $(CFLAGS) -o $@ $(LIBPATHS) $(OBJS) $(LIBS) g++ $(CFLAGS) -o $@ $(LIBPATHS) $(OBJS) $(LIBS)

25
net.cpp
View File

@ -21,7 +21,6 @@ uint64 nLocalServices = (fClient ? 0 : NODE_NETWORK);
CAddress addrLocalHost(0, DEFAULT_PORT, nLocalServices); CAddress addrLocalHost(0, DEFAULT_PORT, nLocalServices);
CNode* pnodeLocalHost = NULL; CNode* pnodeLocalHost = NULL;
uint64 nLocalHostNonce = 0; uint64 nLocalHostNonce = 0;
bool fShutdown = false;
array<int, 10> vnThreadsRunning; array<int, 10> vnThreadsRunning;
SOCKET hListenSocket = INVALID_SOCKET; SOCKET hListenSocket = INVALID_SOCKET;
int64 nThreadSocketHandlerHeartbeat = INT64_MAX; int64 nThreadSocketHandlerHeartbeat = INT64_MAX;
@ -1324,3 +1323,27 @@ bool StopNode()
return true; return true;
} }
class CNetCleanup
{
public:
CNetCleanup()
{
}
~CNetCleanup()
{
// Close sockets
foreach(CNode* pnode, vNodes)
if (pnode->hSocket != INVALID_SOCKET)
closesocket(pnode->hSocket);
if (hListenSocket != INVALID_SOCKET)
if (closesocket(hListenSocket) == SOCKET_ERROR)
printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError());
#ifdef __WXMSW__
// Shutdown Windows Sockets
WSACleanup();
#endif
}
}
instance_of_cnetcleanup;

1
net.h
View File

@ -454,7 +454,6 @@ extern uint64 nLocalServices;
extern CAddress addrLocalHost; extern CAddress addrLocalHost;
extern CNode* pnodeLocalHost; extern CNode* pnodeLocalHost;
extern uint64 nLocalHostNonce; extern uint64 nLocalHostNonce;
extern bool fShutdown;
extern array<int, 10> vnThreadsRunning; extern array<int, 10> vnThreadsRunning;
extern SOCKET hListenSocket; extern SOCKET hListenSocket;
extern int64 nThreadSocketHandlerHeartbeat; extern int64 nThreadSocketHandlerHeartbeat;

View File

@ -20,7 +20,7 @@ class CDataStream;
class CAutoFile; class CAutoFile;
static const int VERSION = 106; static const int VERSION = 106;
static const char* pszSubVer = " test10"; static const char* pszSubVer = " test11";

46
ui.cpp
View File

@ -317,6 +317,7 @@ CMainFrame::CMainFrame(wxWindow* parent) : CMainFrameBase(parent)
fOnSetFocusAddress = false; fOnSetFocusAddress = false;
fRefresh = false; fRefresh = false;
m_choiceFilter->SetSelection(0); m_choiceFilter->SetSelection(0);
double dResize = 1.0;
#ifdef __WXMSW__ #ifdef __WXMSW__
SetIcon(wxICON(bitcoin)); SetIcon(wxICON(bitcoin));
#else #else
@ -330,6 +331,10 @@ CMainFrame::CMainFrame(wxWindow* parent) : CMainFrameBase(parent)
m_toolBar->AddTool(wxID_BUTTONSEND, "Send Coins", wxBitmap(send20_xpm), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString); m_toolBar->AddTool(wxID_BUTTONSEND, "Send Coins", wxBitmap(send20_xpm), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString);
m_toolBar->AddTool(wxID_BUTTONRECEIVE, "Address Book", wxBitmap(addressbook20_xpm), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString); m_toolBar->AddTool(wxID_BUTTONRECEIVE, "Address Book", wxBitmap(addressbook20_xpm), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString);
m_toolBar->Realize(); m_toolBar->Realize();
// resize to fit ubuntu's huge default font
dResize = 1.19;
SetSize(dResize * GetSize().GetWidth(), 1.1 * GetSize().GetHeight());
dResize = 1.20;
#endif #endif
m_staticTextBalance->SetLabel(FormatMoney(GetBalance()) + " "); m_staticTextBalance->SetLabel(FormatMoney(GetBalance()) + " ");
m_listCtrl->SetFocus(); m_listCtrl->SetFocus();
@ -339,13 +344,13 @@ CMainFrame::CMainFrame(wxWindow* parent) : CMainFrameBase(parent)
int nDateWidth = DateTimeStr(1229413914).size() * 6 + 8; int nDateWidth = DateTimeStr(1229413914).size() * 6 + 8;
if (!strstr(DateTimeStr(1229413914).c_str(), "2008")) if (!strstr(DateTimeStr(1229413914).c_str(), "2008"))
nDateWidth += 12; nDateWidth += 12;
m_listCtrl->InsertColumn(0, "", wxLIST_FORMAT_LEFT, 0); m_listCtrl->InsertColumn(0, "", wxLIST_FORMAT_LEFT, dResize * 0);
m_listCtrl->InsertColumn(1, "", wxLIST_FORMAT_LEFT, 0); m_listCtrl->InsertColumn(1, "", wxLIST_FORMAT_LEFT, dResize * 0);
m_listCtrl->InsertColumn(2, "Status", wxLIST_FORMAT_LEFT, 90); m_listCtrl->InsertColumn(2, "Status", wxLIST_FORMAT_LEFT, dResize * 90);
m_listCtrl->InsertColumn(3, "Date", wxLIST_FORMAT_LEFT, nDateWidth); m_listCtrl->InsertColumn(3, "Date", wxLIST_FORMAT_LEFT, dResize * nDateWidth);
m_listCtrl->InsertColumn(4, "Description", wxLIST_FORMAT_LEFT, 409 - nDateWidth); m_listCtrl->InsertColumn(4, "Description", wxLIST_FORMAT_LEFT, dResize * 409 - nDateWidth);
m_listCtrl->InsertColumn(5, "Debit", wxLIST_FORMAT_RIGHT, 79); m_listCtrl->InsertColumn(5, "Debit", wxLIST_FORMAT_RIGHT, dResize * 79);
m_listCtrl->InsertColumn(6, "Credit", wxLIST_FORMAT_RIGHT, 79); m_listCtrl->InsertColumn(6, "Credit", wxLIST_FORMAT_RIGHT, dResize * 79);
//m_listCtrlProductsSent->InsertColumn(0, "Category", wxLIST_FORMAT_LEFT, 100); //m_listCtrlProductsSent->InsertColumn(0, "Category", wxLIST_FORMAT_LEFT, 100);
//m_listCtrlProductsSent->InsertColumn(1, "Title", wxLIST_FORMAT_LEFT, 100); //m_listCtrlProductsSent->InsertColumn(1, "Title", wxLIST_FORMAT_LEFT, 100);
@ -367,6 +372,10 @@ CMainFrame::CMainFrame(wxWindow* parent) : CMainFrameBase(parent)
// Init status bar // Init status bar
int pnWidths[3] = { -100, 88, 290 }; int pnWidths[3] = { -100, 88, 290 };
#ifndef __WXMSW__
pnWidths[1] = pnWidths[1] * 1.1 * dResize;
pnWidths[2] = pnWidths[2] * 1.1 * dResize;
#endif
m_statusBar->SetFieldsCount(3, pnWidths); m_statusBar->SetFieldsCount(3, pnWidths);
// Fill your address text box // Fill your address text box
@ -1514,6 +1523,7 @@ COptionsDialog::COptionsDialog(wxWindow* parent) : COptionsDialogBase(parent)
SelectPage(0); SelectPage(0);
#ifndef __WXMSW__ #ifndef __WXMSW__
m_checkBoxMinimizeOnClose->SetLabel("&Minimize on close"); m_checkBoxMinimizeOnClose->SetLabel("&Minimize on close");
m_checkBoxStartOnSystemStartup->Enable(false); // not implemented yet
#endif #endif
// Init values // Init values
@ -1876,6 +1886,9 @@ CSendingDialog::CSendingDialog(wxWindow* parent, const CAddress& addrIn, int64 n
fSuccess = false; fSuccess = false;
fUIDone = false; fUIDone = false;
fWorkDone = false; fWorkDone = false;
#ifndef __WXMSW__
SetSize(1.2 * GetSize().GetWidth(), 1.05 * GetSize().GetHeight());
#endif
SetTitle(strprintf("Sending %s to %s", FormatMoney(nPrice).c_str(), wtx.mapValue["to"].c_str())); SetTitle(strprintf("Sending %s to %s", FormatMoney(nPrice).c_str(), wtx.mapValue["to"].c_str()));
m_textCtrlStatus->SetValue(""); m_textCtrlStatus->SetValue("");
@ -3475,6 +3488,7 @@ bool CMyApp::OnInit2()
ParseParameters(argc, argv); ParseParameters(argc, argv);
if (mapArgs.count("-?") || mapArgs.count("--help")) if (mapArgs.count("-?") || mapArgs.count("--help"))
{ {
#ifdef __WXMSW__
string strUsage = string strUsage =
"Usage: bitcoin [options]\t\t\t\t\t\t\n" "Usage: bitcoin [options]\t\t\t\t\t\t\n"
"Options:\n" "Options:\n"
@ -3487,6 +3501,20 @@ bool CMyApp::OnInit2()
" -connect=<ip>\t Connect only to the specified node\n" " -connect=<ip>\t Connect only to the specified node\n"
" -?\t\t This help message\n"; " -?\t\t This help message\n";
wxMessageBox(strUsage, "Bitcoin", wxOK); wxMessageBox(strUsage, "Bitcoin", wxOK);
#else
string strUsage =
"Usage: bitcoin [options]\n"
"Options:\n"
" -gen Generate coins\n"
" -gen=0 Don't generate coins\n"
" -min Start minimized\n"
" -datadir=<dir> Specify data directory\n"
" -proxy=<ip:port> Connect through socks4 proxy\n"
" -addnode=<ip> Add a node to connect to\n"
" -connect=<ip> Connect only to the specified node\n"
" -? This help message\n";
fprintf(stderr, "%s", strUsage.c_str());
#endif
return false; return false;
} }
@ -3495,12 +3523,12 @@ bool CMyApp::OnInit2()
if (mapArgs.count("-debug")) if (mapArgs.count("-debug"))
fDebug = true; fDebug = true;
if (strstr(pszSubVer, "test"))
fDebug = true;
if (mapArgs.count("-printtodebugger")) if (mapArgs.count("-printtodebugger"))
fPrintToDebugger = true; fPrintToDebugger = true;
if (!fDebug && !pszSetDataDir[0])
ShrinkDebugFile();
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
printf("Bitcoin version %d%s, OS version %s\n", VERSION, pszSubVer, wxGetOsDescription().mb_str()); printf("Bitcoin version %d%s, OS version %s\n", VERSION, pszSubVer, wxGetOsDescription().mb_str());

View File

@ -11,6 +11,7 @@ bool fDebug = false;
bool fPrintToDebugger = false; bool fPrintToDebugger = false;
bool fPrintToConsole = false; bool fPrintToConsole = false;
char pszSetDataDir[MAX_PATH] = ""; char pszSetDataDir[MAX_PATH] = "";
bool fShutdown = false;
@ -53,19 +54,6 @@ public:
for (int i = 0; i < CRYPTO_num_locks(); i++) for (int i = 0; i < CRYPTO_num_locks(); i++)
delete ppmutexOpenSSL[i]; delete ppmutexOpenSSL[i];
OPENSSL_free(ppmutexOpenSSL); OPENSSL_free(ppmutexOpenSSL);
// Close sockets
foreach(CNode* pnode, vNodes)
if (pnode->hSocket != INVALID_SOCKET)
closesocket(pnode->hSocket);
if (hListenSocket != INVALID_SOCKET)
if (closesocket(hListenSocket) == SOCKET_ERROR)
printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError());
#ifdef __WXMSW__
// Shutdown Windows Sockets
WSACleanup();
#endif
} }
} }
instance_of_cinit; instance_of_cinit;
@ -416,16 +404,6 @@ void PrintException(std::exception* pex, const char* pszThread)
int GetFilesize(FILE* file)
{
int nSavePos = ftell(file);
int nFilesize = -1;
if (fseek(file, 0, SEEK_END) == 0)
nFilesize = ftell(file);
fseek(file, nSavePos, SEEK_SET);
return nFilesize;
}
void GetDataDir(char* pszDir) void GetDataDir(char* pszDir)
{ {
// pszDir must be at least MAX_PATH length. // pszDir must be at least MAX_PATH length.
@ -465,6 +443,37 @@ string GetDataDir()
return pszDir; return pszDir;
} }
int GetFilesize(FILE* file)
{
int nSavePos = ftell(file);
int nFilesize = -1;
if (fseek(file, 0, SEEK_END) == 0)
nFilesize = ftell(file);
fseek(file, nSavePos, SEEK_SET);
return nFilesize;
}
void ShrinkDebugFile()
{
// Scroll debug.log if it's getting too big
string strFile = GetDataDir() + "/debug.log";
FILE* file = fopen(strFile.c_str(), "r");
if (file && GetFilesize(file) > 10 * 1000000)
{
// Restart the file with some of the end
char pch[200000];
fseek(file, -sizeof(pch), SEEK_END);
int nBytes = fread(pch, 1, sizeof(pch), file);
fclose(file);
if (file = fopen(strFile.c_str(), "w"))
{
fwrite(pch, 1, nBytes, file);
fclose(file);
}
}
}

2
util.h
View File

@ -111,6 +111,7 @@ extern bool fDebug;
extern bool fPrintToDebugger; extern bool fPrintToDebugger;
extern bool fPrintToConsole; extern bool fPrintToConsole;
extern char pszSetDataDir[MAX_PATH]; extern char pszSetDataDir[MAX_PATH];
extern bool fShutdown;
void RandAddSeed(); void RandAddSeed();
void RandAddSeedPerfmon(); void RandAddSeedPerfmon();
@ -128,6 +129,7 @@ void ParseParameters(int argc, char* argv[]);
int GetFilesize(FILE* file); int GetFilesize(FILE* file);
void GetDataDir(char* pszDirRet); void GetDataDir(char* pszDirRet);
string GetDataDir(); string GetDataDir();
void ShrinkDebugFile();
uint64 GetRand(uint64 nMax); uint64 GetRand(uint64 nMax);
int64 GetTime(); int64 GetTime();
int64 GetAdjustedTime(); int64 GetAdjustedTime();