std::string WebThreeStubServerBase::shh_newIdentity()
{
//	cnote << this << m_ids;
	KeyPair kp = KeyPair::create();
	m_ids[kp.pub()] = kp.secret();
	return toJS(kp.pub());
}
NodeTable::NodeTable(ba::io_service& _io, KeyPair _alias, uint16_t _udp):
	m_node(Node(_alias.pub(), bi::udp::endpoint())),
	m_secret(_alias.sec()),
	m_io(_io),
	m_socket(new NodeSocket(m_io, *this, _udp)),
	m_socketPointer(m_socket.get()),
	m_bucketRefreshTimer(m_io),
	m_evictionCheckTimer(m_io)
{
	for (unsigned i = 0; i < s_bins; i++)
	{
		m_state[i].distance = i;
		m_state[i].modified = chrono::steady_clock::now() - chrono::seconds(1);
	}
	
	m_socketPointer->connect();
	doRefreshBuckets(boost::system::error_code());
}
Esempio n. 3
0
NodeTable::NodeTable(ba::io_service& _io, KeyPair const& _alias, NodeIPEndpoint const& _endpoint, bool _enabled):
	m_node(Node(_alias.pub(), _endpoint)),
	m_secret(_alias.sec()),
	m_socket(new NodeSocket(_io, *this, (bi::udp::endpoint)m_node.endpoint)),
	m_socketPointer(m_socket.get()),
	m_timers(_io)
{
	for (unsigned i = 0; i < s_bins; i++)
		m_state[i].distance = i;
	
	if (!_enabled)
		return;
	
	try
	{
		m_socketPointer->connect();
		doDiscovery();
	}
	catch (std::exception const& _e)
	{
		clog(NetWarn) << "Exception connecting NodeTable socket: " << _e.what();
		clog(NetWarn) << "Discovery disabled.";
	}
}
string WebThreeStubServerBase::shh_newIdentity()
{
	KeyPair kp = KeyPair::create();
	m_shhIds[kp.pub()] = kp.secret();
	return toJS(kp.pub());
}