make it work

pull/1/head
Jeff Becker 6 years ago
parent 620b9616a6
commit fe7388bd69
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -18,22 +18,6 @@ namespace llarp
{
const size_t MAX_MSG_SIZE = 2048;
struct Node
{
llarp_rc* rc;
const byte_t*
ID() const;
Node() : rc(nullptr)
{
}
Node(llarp_rc* other) : rc(other)
{
}
};
struct Key_t : public llarp::AlignedBuffer< 32 >
{
Key_t(const byte_t* val) : llarp::AlignedBuffer< 32 >(val)
@ -48,8 +32,8 @@ namespace llarp
operator^(const Key_t& other) const
{
Key_t dist;
for(size_t idx = 0; idx < 8; ++idx)
dist.data_l()[idx] = data_l()[idx] ^ other.data_l()[idx];
for(size_t idx = 0; idx < 32; ++idx)
dist[idx] = (*this)[idx] ^ other[idx];
return dist;
}
@ -60,6 +44,23 @@ namespace llarp
}
};
struct Node
{
llarp_rc* rc;
Key_t ID;
Node() : rc(nullptr)
{
ID.Zero();
}
Node(llarp_rc* other) : rc(other)
{
ID = other->pubkey;
}
};
struct SearchJob
{
const static uint64_t JobTimeout = 30000;

@ -300,15 +300,6 @@ namespace llarp
return bencode_read_list(buf, &r);
}
const byte_t *
Node::ID() const
{
if(rc)
return rc->pubkey;
else
return nullptr;
}
SearchJob::SearchJob()
{
started = 0;
@ -349,7 +340,7 @@ namespace llarp
if(itr == nodes.end())
return false;
result = itr->second.ID();
result = itr->second.ID;
return true;
}
@ -360,11 +351,11 @@ namespace llarp
auto itr = nodes.lower_bound(target);
if(itr == nodes.end())
return false;
if(itr->second.ID() == exclude)
if(itr->second.ID == exclude)
++itr;
if(itr == nodes.end())
return false;
result = itr->second.ID();
result = itr->second.ID;
return true;
}
@ -472,6 +463,7 @@ namespace llarp
router = r;
ourKey = us;
nodes = new Bucket(ourKey);
llarp::Debug("intialize dht with key ", ourKey);
}
void
@ -541,7 +533,9 @@ void
llarp_dht_put_local_router(struct llarp_dht_context *ctx, struct llarp_rc *rc)
{
ctx->impl.nodes->nodes[rc->pubkey] = rc;
llarp::dht::Key_t k = rc->pubkey;
llarp::Debug("put router at ", k);
ctx->impl.nodes->nodes[k] = rc;
}
void

@ -364,6 +364,7 @@ llarp_router::Run()
llarp::pubkey ourPubkey = pubkey();
llarp::Info("our router has public key ", ourPubkey);
llarp_dht_context_start(dht, ourPubkey);
// start links
for(auto link : links)

Loading…
Cancel
Save