Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Josh Wilcox
crown-core
Commits
e2fe0b3c
Commit
e2fe0b3c
authored
7 years ago
by
Ashot
Browse files
Options
Download
Plain Diff
Resolved merge conflict
parents
394a2271
3360ee44
master
89-merge-0.11-1st-stage
89-merge-bitcoin-latest-changes-0.10
Current-dev
DNSSeeds
add-testnet-option-to-script
calculate-score-unit-tests
connect-to-docker-delivery-pipeline
fix-dash-copyright-violations
make-instant-send-default
setup-script-edits
test-other-gitlab-runner-branch-to-be-deleted-if-completes
translation-doc-updates
v0.12.4.1
v0.12.4.0
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/qt/bitcoingui.cpp
+1
-1
src/qt/bitcoingui.cpp
src/rpcupdate.cpp
+6
-6
src/rpcupdate.cpp
src/updater.cpp
+33
-19
src/updater.cpp
src/updater.h
+2
-1
src/updater.h
with
42 additions
and
27 deletions
+42
-27
src/qt/bitcoingui.cpp
View file @
e2fe0b3c
...
...
@@ -1307,7 +1307,7 @@ void BitcoinGUI::handleRestart(QStringList args)
void
BitcoinGUI
::
checkUpdate
()
{
UpdateDialog
::
GetInstance
()
->
setParent
(
this
,
Qt
::
Dialog
);
if
(
updater
.
Check
())
if
(
updater
.
GetStatus
()
!=
boost
::
none
&&
updater
.
GetStatus
())
{
UpdateDialog
::
GetInstance
()
->
setCurrentVersion
(
QString
::
fromStdString
(
FormatVersion
(
CLIENT_VERSION
)));
UpdateDialog
::
GetInstance
()
->
setUpdateVersion
(
QString
::
fromStdString
(
FormatVersion
(
updater
.
GetVersion
())));
...
...
This diff is collapsed.
Click to expand it.
src/rpcupdate.cpp
View file @
e2fe0b3c
...
...
@@ -180,11 +180,11 @@ Value update(const Array& params, bool fHelp)
throw
runtime_error
(
"Too many parameters
\n
"
);
}
if
(
updater
.
Check
()
==
boost
::
none
)
if
(
updater
.
GetStatus
()
==
boost
::
none
)
{
throw
runtime_error
(
"An error occurred while checking for an update.
\n
Check debug.log for more info.
\n
"
);
}
else
if
(
updater
.
Check
())
else
if
(
updater
.
GetStatus
())
{
// There is an update
Object
obj
;
...
...
@@ -200,11 +200,11 @@ Value update(const Array& params, bool fHelp)
if
(
strCommand
==
"download"
)
{
if
(
updater
.
Check
()
==
boost
::
none
)
if
(
updater
.
GetStatus
()
==
boost
::
none
)
{
throw
runtime_error
(
"An error occurred while checking for an update.
\n
Check debug.log for more info.
\n
"
);
}
else
if
(
!
updater
.
Check
())
else
if
(
!
updater
.
GetStatus
())
{
return
"You are running the latest version of Crown - "
+
FormatVersion
(
CLIENT_VERSION
);
}
...
...
@@ -239,11 +239,11 @@ Value update(const Array& params, bool fHelp)
throw
runtime_error
(
"The command 'unzip' could not be found. Please install it and try again."
);
}
if
(
updater
.
Check
()
==
boost
::
none
)
if
(
updater
.
GetStatus
()
==
boost
::
none
)
{
throw
runtime_error
(
"An error occurred while checking for an update.
\n
Check debug.log for more info.
\n
"
);
}
else
if
(
!
updater
.
Check
())
else
if
(
!
updater
.
GetStatus
())
{
return
"You are running the latest version of Crown - "
+
FormatVersion
(
CLIENT_VERSION
);
}
...
...
This diff is collapsed.
Click to expand it.
src/updater.cpp
View file @
e2fe0b3c
...
...
@@ -5,6 +5,7 @@
#include "clientversion.h"
#include "util.h"
#include "chainparams.h"
#include "rpcprotocol.h"
#include <stdio.h>
#include <curl/curl.h>
...
...
@@ -108,27 +109,27 @@ bool Updater::LoadUpdateInfo()
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
GetUpdateData
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
&
updateData
);
res
=
curl_easy_perform
(
curl
);
curl_easy_cleanup
(
curl
);
}
if
(
res
==
CURLE_OK
)
{
jsonData
=
ParseJson
(
updateData
);
version
=
GetVersionFromJson
();
LogPrintf
(
"Updater::GetUpdateInfo() - Got version from json: %d
\n
"
,
version
);
if
(
version
>
CLIENT_VERSION
&&
NeedToBeUpdated
())
if
(
res
==
CURLE_OK
)
{
LogPrintf
(
"Updater::GetUpdateInfo() - Version is old
\n
"
);
// There is an update
status
=
true
;
long
response_code
;
curl_easy_getinfo
(
curl
,
CURLINFO_RESPONSE_CODE
,
&
response_code
);
if
(
response_code
==
HTTP_OK
)
{
CheckAndUpdateStatus
(
updateData
);
result
=
true
;
}
else
{
LogPrintf
(
"Updater::GetUpdateInfo() - Error! Server response code - %d
\n
"
,
response_code
);
}
}
result
=
true
;
}
else
{
LogPrintf
(
"Updater::GetUpdateInfo() - Error! Couldn't get data json. Error code - %d
\n
"
,
res
);
result
=
false
;
else
{
LogPrintf
(
"Updater::GetUpdateInfo() - Error! Couldn't get data json. Error code - %d
\n
"
,
res
);
}
curl_easy_cleanup
(
curl
);
}
return
result
;
}
...
...
@@ -263,7 +264,20 @@ void Updater::StopDownload()
stopDownload
=
true
;
}
boost
::
optional
<
bool
>
Updater
::
Check
()
void
Updater
::
CheckAndUpdateStatus
(
const
std
::
string
&
updateData
)
{
jsonData
=
ParseJson
(
updateData
);
version
=
GetVersionFromJson
();
LogPrintf
(
"Updater::GetUpdateInfo() - Got version from json: %d
\n
"
,
version
);
if
(
version
>
CLIENT_VERSION
&&
NeedToBeUpdated
())
{
LogPrintf
(
"Updater::GetUpdateInfo() - Version is old
\n
"
);
// There is an update
status
=
true
;
}
}
boost
::
optional
<
bool
>
Updater
::
GetStatus
()
{
boost
::
optional
<
bool
>
result
=
boost
::
none
;
if
(
LoadUpdateInfo
())
...
...
This diff is collapsed.
Click to expand it.
src/updater.h
View file @
e2fe0b3c
...
...
@@ -31,7 +31,7 @@ public:
MAC_OS
,
};
Updater
();
boost
::
optional
<
bool
>
Check
();
boost
::
optional
<
bool
>
GetStatus
();
int
GetVersion
()
const
{
return
version
;
...
...
@@ -70,6 +70,7 @@ private:
std
::
string
GetUrl
(
const
Value
&
value
);
std
::
string
GetSha256sum
(
Value
value
);
void
SetCAPath
(
CURL
*
curl
);
void
CheckAndUpdateStatus
(
const
std
::
string
&
updateData
);
};
#endif
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help