void RemoteMinerClient::SendMetaHash(const int64 blockid, const unsigned int startnonce, const std::vector<unsigned char> &digest, const uint256 &besthash, const unsigned int besthashnonce)
{
	std::string digeststr("");

	EncodeBase64(digest,digeststr);
	json_spirit::Object obj;
	obj.push_back(json_spirit::Pair("type",static_cast<int>(RemoteMinerMessage::MESSAGE_TYPE_CLIENTMETAHASH)));
	obj.push_back(json_spirit::Pair("blockid",static_cast<boost::int64_t>(blockid)));
	obj.push_back(json_spirit::Pair("nonce",static_cast<boost::int64_t>(startnonce)));
	obj.push_back(json_spirit::Pair("digest",digeststr));
	obj.push_back(json_spirit::Pair("besthash",besthash.ToString()));
	obj.push_back(json_spirit::Pair("besthashnonce",static_cast<boost::int64_t>(besthashnonce)));

	SendMessage(RemoteMinerMessage(obj));
}
Ejemplo n.º 2
0
int
check_http_digest(struct ctl_tcp_event *cte)
{
	char		*head;
	u_char		*b;
	char		 digest[SHA1_DIGEST_STRING_LENGTH];
	struct host	*host;

	/*
	 * ensure string is nul-terminated.
	 */
	b = ibuf_reserve(cte->buf, 1);
	if (b == NULL)
		fatal("out of memory");
	*b = '\0';

	head = cte->buf->buf;
	host = cte->host;
	host->he = HCE_HTTP_DIGEST_ERROR;

	if ((head = strstr(head, "\r\n\r\n")) == NULL) {
		log_debug("%s: %s failed (no end of headers)",
		    __func__, host->conf.name);
		host->up = HOST_DOWN;
		return (1);
	}
	head += strlen("\r\n\r\n");

	digeststr(cte->table->conf.digest_type, head, strlen(head), digest);

	if (strcmp(cte->table->conf.digest, digest)) {
		log_warnx("%s: %s failed (wrong digest)",
		    __func__, host->conf.name);
		host->he = HCE_HTTP_DIGEST_FAIL;
		host->up = HOST_DOWN;
	} else {
		host->he = HCE_HTTP_DIGEST_OK;
		host->up = HOST_UP;
	}
	return (!(host->up == HOST_UP));
}