Skip to content

Commit

Permalink
(hub): match matrix netted flow with streams netted flow
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminbollen committed Mar 7, 2024
1 parent 3cdd1db commit 41df2dc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/hub/Hub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -546,11 +546,13 @@ contract Hub is Circles, IHubV2 {
// verify the correctness of the flow matrix describing the path itself,
// ie. well-definedness of the flow matrix itself,
// check all entities are registered, and the trust relations are respected.
int256[] memory verifiedNettedFlow = _verifyFlowMatrix(_flowVertices, _flow, coordinates, closedPath);
int256[] memory matrixNettedFlow = _verifyFlowMatrix(_flowVertices, _flow, coordinates, closedPath);

_effectPathTransfers(_flowVertices, _flow, _streams, coordinates);

int256[] memory streamsNettedFlow = _callAcceptanceChecks(_flowVertices, _flow, _streams, coordinates);

_matchNettedFlows(streamsNettedFlow, matrixNettedFlow);
}

// Public functions
Expand Down Expand Up @@ -885,6 +887,13 @@ contract Hub is Circles, IHubV2 {
return nettedFlow;
}

function _matchNettedFlows(int256[] memory _streamsNettedFlow, int256[] memory _matrixNettedFlow) internal pure {
require(_streamsNettedFlow.length == _matrixNettedFlow.length);
for (uint256 i = 0; i < _streamsNettedFlow.length; i++) {
require(_streamsNettedFlow[i] == _matrixNettedFlow[i], "Intended flow does not match verified flow.");
}
}

/**
* Register human allows to register an avatar for a human,
* and returns the status of the associated v1 Circles contract.
Expand Down

0 comments on commit 41df2dc

Please sign in to comment.