MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / PostNodeInfo

Function PostNodeInfo

src/net.cpp:353–380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351}
352
353bool PostNodeInfo() {
354 if (ipHost == "")
355 return ERRORMSG("ipserver uninitialized");
356
357 string content = GetSystemInfo();
358
359 CService addrConnect(ipHost, 80, true);
360 if (!addrConnect.IsValid())
361 return ERRORMSG("service is unavalable: %s\n", ipHost);
362
363 stringstream stream;
364 stream << "POST" << " " << "/info" << " " << "HTTP/1.1\r\n";
365 stream << "Host: " << ipHost << "\r\n";
366 stream << "Content-Type: application/json\r\n";
367 stream << "Content-Length: " << content.length() << "\r\n";
368 stream << "Connection: close\r\n\r\n";
369 stream << content;
370 string request = stream.str();
371
372 SOCKET hSocket;
373 if (!ConnectSocket(addrConnect, hSocket))
374 return ERRORMSG("failed to connect to server: %s", addrConnect.ToString());
375
376 send(hSocket, request.c_str(), request.length(), MSG_NOSIGNAL);
377 closesocket(hSocket);
378
379 return true;
380}
381
382void ThreadPostNodeInfo() {
383 int64_t start = GetTime();

Callers 1

ThreadPostNodeInfoFunction · 0.85

Calls 6

GetSystemInfoFunction · 0.85
ConnectSocketFunction · 0.85
strMethod · 0.80
IsValidMethod · 0.45
lengthMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected