mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
add a findNode() function to reduce copypasta
Signed-off-by: Grant Limberg <glimberg@gmail.com>
This commit is contained in:
parent
5df253fa69
commit
321b67c73c
1 changed files with 14 additions and 4 deletions
|
@ -154,6 +154,17 @@ namespace {
|
||||||
|
|
||||||
return resultObject;
|
return resultObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZT1_Node* findNode(uint64_t nodeId)
|
||||||
|
{
|
||||||
|
NodeMap::iterator found = nodeMap.find(nodeId);
|
||||||
|
if(found != nodeMap.end())
|
||||||
|
{
|
||||||
|
JniRef *ref = found->second;
|
||||||
|
return ref->node;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -309,8 +320,9 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processVirtualNetworkFra
|
||||||
jlongArray out_nextBackgroundTaskDeadline)
|
jlongArray out_nextBackgroundTaskDeadline)
|
||||||
{
|
{
|
||||||
uint64_t nodeId = (uint64_t) id;
|
uint64_t nodeId = (uint64_t) id;
|
||||||
NodeMap::iterator found = nodeMap.find(nodeId);
|
|
||||||
if(found == nodeMap.end())
|
ZT1_Node *node = findNode(nodeId);
|
||||||
|
if(node == NULL)
|
||||||
{
|
{
|
||||||
// cannot find valid node. We should never get here.
|
// cannot find valid node. We should never get here.
|
||||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||||
|
@ -323,8 +335,6 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processVirtualNetworkFra
|
||||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZT1_Node *node = found->second;
|
|
||||||
|
|
||||||
uint64_t now = (uint64_t)in_now;
|
uint64_t now = (uint64_t)in_now;
|
||||||
uint64_t nwid = (uint64_t)in_nwid;
|
uint64_t nwid = (uint64_t)in_nwid;
|
||||||
uint64_t sourceMac = (uint64_t)in_sourceMac;
|
uint64_t sourceMac = (uint64_t)in_sourceMac;
|
||||||
|
|
Loading…
Add table
Reference in a new issue