mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-07 19:24:13 +00: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
@ -154,6 +154,17 @@ namespace {
|
||||
|
||||
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)
|
||||
{
|
||||
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.
|
||||
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);
|
||||
}
|
||||
|
||||
ZT1_Node *node = found->second;
|
||||
|
||||
uint64_t now = (uint64_t)in_now;
|
||||
uint64_t nwid = (uint64_t)in_nwid;
|
||||
uint64_t sourceMac = (uint64_t)in_sourceMac;
|
||||
|
Loading…
x
Reference in New Issue
Block a user