|
33 | 33 | import java.util.Collection; |
34 | 34 | import java.util.HashMap; |
35 | 35 | import java.util.HashSet; |
| 36 | +import java.util.Iterator; |
36 | 37 | import java.util.List; |
37 | 38 | import java.util.Map; |
38 | 39 | import java.util.Set; |
@@ -145,16 +146,35 @@ public void afterExecution( |
145 | 146 | } |
146 | 147 | } |
147 | 148 |
|
| 149 | + Map<Statement, Set<Statement>> results = new HashMap<>(); |
148 | 150 | for( Pair<Statement, Statement> cchs : multipleCrossChannelInvocations) { |
149 | | - tool.warnOn(cchs.getLeft(), |
150 | | - "Detected cross-channel invocations on different channels. The other invocation: " |
151 | | - + cchs.getRight().getLocation() + ". They may lead to a lack of transparency because no new transactions are created during the invocation."); |
152 | | - if(intraChaincode) |
153 | | - tool.warnOn(cchs.getLeft(), |
154 | | - "Detected cross-channel invocations on different channels. The other invocation: " |
155 | | - + cchs.getRight().getLocation() + ". They may lead to uncommited write operations during the execution of callee chaincode."); |
| 151 | + if(!results.containsKey(cchs.getLeft())) |
| 152 | + results.put(cchs.getLeft(), new HashSet<>()); |
| 153 | + results.get(cchs.getLeft()).add(cchs.getRight()); |
| 154 | + } |
| 155 | + |
| 156 | + for(Statement target : results.keySet()) { |
| 157 | + Set<Statement> others = results.get(target); |
| 158 | + tool.warnOn(target, |
| 159 | + "Detected cross-channel invocations on different channels. The other invocations: " |
| 160 | + + printOtherLocations(others) + ". They may lead to a lack of transparency because no new transactions are created during the invocation."); |
| 161 | + if(intraChaincode) |
| 162 | + tool.warnOn(target, |
| 163 | + "Detected cross-channel invocations on different channels. The other invocations: " |
| 164 | + + printOtherLocations(others) + ". They may lead to uncommited write operations during the execution of callee chaincode."); |
156 | 165 | } |
| 166 | + } |
157 | 167 |
|
| 168 | + private String printOtherLocations(Set<Statement> others) { |
| 169 | + String result = ""; |
| 170 | + Iterator<Statement> iter = others.iterator(); |
| 171 | + while(iter.hasNext()) { |
| 172 | + Statement cchi = iter.next(); |
| 173 | + result += cchi.getLocation(); |
| 174 | + if(iter.hasNext()) |
| 175 | + result += ", "; |
| 176 | + } |
| 177 | + return result; |
158 | 178 | } |
159 | 179 |
|
160 | 180 | @Override |
|
0 commit comments