Beispiel #1
0
shh::Envelope toSealed(Json::Value const& _json, shh::Message const& _m, Secret _from)
{
    unsigned ttl = 50;
    unsigned workToProve = 50;
    shh::BuildTopic bt;

    if (!_json["ttl"].empty())
        ttl = jsToInt(_json["ttl"].asString());

    if (!_json["workToProve"].empty())
        workToProve = jsToInt(_json["workToProve"].asString());

    if (!_json["topics"].empty())
        for (auto i: _json["topics"])
        {
            if (i.isArray())
            {
                for (auto j: i)
                    if (!j.isNull())
                        bt.shift(jsToBytes(j.asString()));
            }
            else if (!i.isNull()) // if it is anything else then string, it should and will fail
                bt.shift(jsToBytes(i.asString()));
        }

    return _m.seal(_from, bt, ttl, workToProve);
}
static shh::Envelope toSealed(Json::Value const& _json, shh::Message const& _m, Secret _from)
{
	unsigned ttl = 50;
	unsigned workToProve = 50;
	shh::BuildTopic bt;

	if (_json["ttl"].isInt())
		ttl = _json["ttl"].asInt();
	if (_json["workToProve"].isInt())
		workToProve = _json["workToProve"].asInt();
	if (!_json["topic"].empty())
	{
		if (_json["topic"].isString())
			bt.shift(jsToBytes(_json["topic"].asString()));
		else if (_json["topic"].isArray())
			for (auto i: _json["topic"])
				if (i.isString())
					bt.shift(jsToBytes(i.asString()));
	}
	return _m.seal(_from, bt, ttl, workToProve);
}