Skip to content

Commit 366ca07

Browse files
committed
INDY-1148 - It's possible to create several nodes with the same alias - change validation in pool_req_handler.
Signed-off-by: toktar <[email protected]>
1 parent 859ba15 commit 366ca07

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

plenum/server/pool_req_handler.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ def authErrorWhileAddingNode(self, request):
8080
origin)
8181
if self.stewardHasNode(origin):
8282
return "{} already has a node".format(origin)
83-
if self.isNodeDataConflicting(
84-
operation.get(DATA, request.operation.get(TARGET_NYM))):
83+
if self.isNodeDataConflicting(data):
8584
return "existing data has conflicts with " \
8685
"request data {}".format(operation.get(DATA))
8786

@@ -157,14 +156,14 @@ def isNodeDataSame(self, nodeNym, newData, isCommitted=True):
157156
nodeInfo.pop(f.IDENTIFIER.nm, None)
158157
return nodeInfo == newData
159158

160-
def isNodeDataConflicting(self, data, nodeNym=None):
159+
def isNodeDataConflicting(self, data, updatingNym=None):
161160
# Check if node's ALIAS or IPs or ports conflicts with other nodes,
162161
# also, the node is not allowed to change its alias.
163162

164163
# Check ALIAS change
165164
nodeData = {}
166-
if nodeNym:
167-
nodeData = self.getNodeData(nodeNym, isCommitted=False)
165+
if updatingNym:
166+
nodeData = self.getNodeData(updatingNym, isCommitted=False)
168167
if nodeData.get(ALIAS) != data.get(ALIAS):
169168
return True
170169
else:
@@ -178,7 +177,7 @@ def isNodeDataConflicting(self, data, nodeNym=None):
178177
otherNodeData = self.stateSerializer.deserialize(otherNodeData)
179178
otherNodeData.pop(f.IDENTIFIER.nm, None)
180179
otherNodeData.pop(SERVICES, None)
181-
if not nodeNym or otherNode != nodeNym:
180+
if not updatingNym or otherNode != updatingNym:
182181
# The node's ip, port and alias shuuld be unique
183182
bag = set()
184183
for d in (nodeData, otherNodeData):
@@ -192,8 +191,8 @@ def isNodeDataConflicting(self, data, nodeNym=None):
192191
if (not nodeData and len(bag) != 3) or (
193192
nodeData and len(bag) != 6):
194193
return True
195-
if nodeData.get(ALIAS) == otherNodeData.get(
196-
ALIAS) and not nodeNym or otherNode != nodeNym:
194+
if data.get(ALIAS) == otherNodeData.get(
195+
ALIAS) and not updatingNym:
197196
return True
198197

199198
def dataErrorWhileValidatingUpdate(self, data, nodeNym):

0 commit comments

Comments
 (0)