Skip to content

Commit 4074d59

Browse files
committed
minor changes
1 parent a4dc3f0 commit 4074d59

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

protocol_doc/monet-explorer/Client.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace MonetExplorer {
3737
* @param isSent True = sent to the server, False = received from it.
3838
* @param output Most probably std::cout.
3939
*/
40-
void PrintFormatted(std::string &msg, bool isSent, std::ostream &output) {
40+
void PrintFormatted(const std::string &msg, bool isSent, std::ostream &output) {
4141
int mb_remain = 0; // Bytes remaining from a multi-byte character
4242
const char *pos = msg.c_str();
4343
const char *endPos = pos + msg.length();
@@ -151,17 +151,22 @@ namespace MonetExplorer {
151151
Connect to the server
152152
*/
153153
if (args.IsOptionSet("unix-domain-socket")) {
154+
std::cout << "\033[32mConnecting through Unix domain socket.\033[0m\n";
155+
154156
this->connection.ConnectUnix(
155157
args.GetIntValue("port")
156158
);
157159
} else {
160+
std::cout << "\033[32mConnecting through TCP/IP to: " << args.GetStringValue("host") << ':'
161+
<< args.GetIntValue("port") << "\033[0m\n";
162+
158163
this->connection.ConnectTCP(
159164
args.GetStringValue("host"),
160165
args.GetIntValue("port")
161166
);
162167
}
163168

164-
std::cout << "\033[32mConnected.\033[0m\n";
169+
std::cout << "\033[32mConnected.\033[0m\n";
165170
std::string msg;
166171

167172
/*
@@ -198,6 +203,8 @@ namespace MonetExplorer {
198203
this->connection.SendMessage(msg);
199204
}
200205

206+
std::cout << "\033[32mAuthenticated.\033[0m\n";
207+
201208
/*
202209
Communication
203210
*/

protocol_doc/monet-explorer/Connection.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,6 @@ namespace MonetExplorer {
168168
/*
169169
Connect through TCP/IP.
170170
*/
171-
std::cout << "\033[32mConnecting through TCP/IP to: " << host << ':'
172-
<< port << "\033[0m\n";
173-
174171
this->clientSocket = socket(AF_INET, SOCK_STREAM, 0);
175172
if (this->clientSocket == -1) {
176173
throw std::runtime_error("Failed to create socket. Error: '" + std::string(strerror(errno))
@@ -206,8 +203,6 @@ namespace MonetExplorer {
206203
"(Method is called twice.)");
207204
}
208205

209-
std::cout << "\033[32mConnecting through Unix domain socket.\033[0m\n";
210-
211206
this->clientSocket = socket(AF_UNIX, SOCK_STREAM, 0);
212207
if (this->clientSocket == -1) {
213208
throw std::runtime_error("Failed to create socket. Error: '" + std::string(strerror(errno))
@@ -303,7 +298,7 @@ namespace MonetExplorer {
303298
*
304299
* @param message
305300
*/
306-
void SendMessage(std::string &message) {
301+
void SendMessage(const std::string &message) {
307302
const char *pos = message.c_str();
308303
int remaining = message.length();
309304
int packetSize;

protocol_doc/monet-explorer/ServerChallenge.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace MonetExplorer {
6161
* @param data Input
6262
* @return std::string Output
6363
*/
64-
std::string Sha512(std::string &data) {
64+
std::string Sha512(const std::string &data) {
6565
SHA512((unsigned char*)data.c_str(), data.length(), (unsigned char*)this->bufferBin);
6666
this->BinToHex(this->bufferBin, 64, this->bufferHex);
6767

@@ -74,7 +74,7 @@ namespace MonetExplorer {
7474
* @param data Input
7575
* @return std::string Output
7676
*/
77-
std::string Sha256(std::string &data) {
77+
std::string Sha256(const std::string &data) {
7878
SHA256((unsigned char*)data.c_str(), data.length(), (unsigned char*)this->bufferBin);
7979
this->BinToHex(this->bufferBin, 32, this->bufferHex);
8080

@@ -87,7 +87,7 @@ namespace MonetExplorer {
8787
* @param data Input
8888
* @return std::string Output
8989
*/
90-
std::string Sha1(std::string &data) {
90+
std::string Sha1(const std::string &data) {
9191
SHA1((unsigned char*)data.c_str(), data.length(), (unsigned char*)this->bufferBin);
9292
this->BinToHex(this->bufferBin, 20, this->bufferHex);
9393

@@ -100,7 +100,7 @@ namespace MonetExplorer {
100100
* @param data Input
101101
* @return std::string Output
102102
*/
103-
std::string Sha384(std::string &data) {
103+
std::string Sha384(const std::string &data) {
104104
SHA384((unsigned char*)data.c_str(), data.length(), (unsigned char*)this->bufferBin);
105105
this->BinToHex(this->bufferBin, 48, this->bufferHex);
106106

@@ -113,7 +113,7 @@ namespace MonetExplorer {
113113
* @param data Input
114114
* @return std::string Output
115115
*/
116-
std::string Sha224(std::string &data) {
116+
std::string Sha224(const std::string &data) {
117117
SHA224((unsigned char*)data.c_str(), data.length(), (unsigned char*)this->bufferBin);
118118
this->BinToHex(this->bufferBin, 28, this->bufferHex);
119119

@@ -126,7 +126,7 @@ namespace MonetExplorer {
126126
* @param data Input
127127
* @return std::string Output
128128
*/
129-
std::string RipeMd160(std::string &data) {
129+
std::string RipeMd160(const std::string &data) {
130130
RIPEMD160((unsigned char*)data.c_str(), data.length(), (unsigned char*)this->bufferBin);
131131
this->BinToHex(this->bufferBin, 20, this->bufferHex);
132132

@@ -139,7 +139,7 @@ namespace MonetExplorer {
139139
*
140140
* @param msg The message received from the server.
141141
*/
142-
ServerChallenge(std::string &msg) : salt(), backend(), version(0), protocols(),
142+
ServerChallenge(const std::string &msg) : salt(), backend(), version(0), protocols(),
143143
endianness(), passwordHashAlgo() {
144144

145145
if (msg.length() < 1) {

0 commit comments

Comments
 (0)