Add method to obtain agreement URIs in chonological order
@@ -293,6 +293,18 @@ public class AgreementProtocolState {
.sorted((x1,x2) -> x2.getOrder() - x1.getOrder());
}
+ /**
+ * Returns a list of all agreement URIs in the order they were made. The oldestFirst parameter controls ascending or descending order.
+ */
+ public List<URI> getAgreementsInChronologicalOrder(boolean oldestFirst) {
+ return deliveryChains.stream()
+ .map(m -> m.getHead())
+ .filter(x -> isAgreement(x.getMessageURI()))
+ .sorted((x1,x2) -> (oldestFirst ? -1 : 1 ) * x2.getOrder() - x1.getOrder())
+ .map(x -> x.getMessageURI())
+ .collect(Collectors.toList());
+ }
+
/**
* Returns the n latest message uris filtered by the specified predicate, sorted descending by order (latest first).
* @param filterPredicate
