on master help sign in
fix exception thrown due to bug in when the incoming, unverified tuples are hashed
commit46b450983e87ca4bd8d00c810558bd513dc9c43f authorAgentM <agentm@themactionfaction.com> dateMon 16 Nov 2015, 23:13 (11 years ago) parent78a58e0
2 files changed+12−6
ProjectM36/Base.hs+8−3 ProjectM36/TransactionGraph.hs+4−3
ProjectM36/Base.hs+8−3
@@ -155,9 +155,14 @@ instance NFData RelationTupleSet where rnf = genericRnf
155155
156156--the same hash must be generated for equal tuples so that the hashset equality works
157157instance Hashable RelationTuple where
158− hashWithSalt salt (RelationTuple attrs tupVec) = salt `hashWithSalt`
159− sortedAttrs `hashWithSalt`
160− (V.toList sortedTupVec)
158+ --sanity check the tuple for attribute and tuple counts
159+ --this bit me when tuples were being hashed before being verified
160+ hashWithSalt salt (RelationTuple attrs tupVec) = if V.length attrs /= V.length tupVec then
161+ error "invalid tuple: attributes and tuple count mismatch"
162+ else
163+ salt `hashWithSalt`
164+ sortedAttrs `hashWithSalt`
165+ (V.toList sortedTupVec)
161166 where
162167 sortedAttrsIndices = sortedAttributesIndices attrs
163168 sortedAttrs = map snd sortedAttrsIndices
ProjectM36/TransactionGraph.hs+4−3
@@ -221,9 +221,10 @@ graphAsRelation (DisconnectedTransaction parentUUID _) graph@(TransactionGraph _
221221 parentAttributes = A.attributesFromList [Attribute "id" stringAtomType]
222222 tupleGenerator transaction = case transactionParentsRelation transaction graph of
223223 Left err -> Left err
224− Right _ -> Right [Atom $ T.pack $ show (transactionUUID transaction),
225− Atom $ parentUUID == transactionUUID transaction,
226− Atom $ case headNameForTransaction transaction graph of
224+ Right parentTransRel -> Right [Atom $ T.pack $ show (transactionUUID transaction),
225+ Atom parentTransRel,
226+ Atom $ parentUUID == transactionUUID transaction,
227+ Atom $ case headNameForTransaction transaction graph of
227228 Just headName -> headName
228229 Nothing -> ""
229230 ]