<!--

      Copyright 2018, Cordite Foundation.

       Licensed under the Apache License, Version 2.0 (the "License");
       you may not use this file except in compliance with the License.
       You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

       Unless required by applicable law or agreed to in writing, software
       distributed under the License is distributed on an "AS IS" BASIS,
       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       See the License for the specific language governing permissions and
       limitations under the License.

-->

@startuml
Title: Notarise and Create Metering Invoice with Metering State Synced in Notary flow

NodeA -> MeteringNotaryClusterClient: Notarise my Tx
MeteringNotaryClusterClient -> MeteringNotary1 : Notarise Tx
MeteringNotaryClusterClient -> MeteringNotary2 : Notarise Tx
MeteringNotaryClusterClient -> MeteringNotary3 : Notarise Tx
MeteringNotary1 -> MeteringNotaryClusterClient : Accepted and Notarised
MeteringNotary2 -> MeteringNotaryClusterClient : Accepted and Notarised
MeteringNotary3 -> MeteringNotaryClusterClient : Rejected or Timed out
MeteringNotaryClusterClient -> MeteringNotaryClusterClient : Create Metering Invoice
MeteringNotaryClusterClient -> MeteringNotaryClusterClient : Add Identities of cluster members who 'accepted' + Node A
group Distributed Metering Invoice
MeteringNotaryClusterClient -> MeteringNotaryClusterClient : Store Metering Invoice as ISSUED
MeteringNotaryClusterClient -> NodeA : Finality Flow DistributesInvoice
MeteringNotaryClusterClient -> MeteringNotary1 : Finality Flow DistributesInvoice
MeteringNotaryClusterClient -> MeteringNotary2 : Finality Flow DistributesInvoice
end group
@enduml