ref/runtime/internal/flow/conn: Propery pass discharges.
I'm waiting to write tests until my prevoius change is in.
MultiPart: 1/2
Change-Id: I5adea06ea7c2ca41845b5a227f037b7b12d1de6c
diff --git a/runtime/internal/flow/conn/flow.go b/runtime/internal/flow/conn/flow.go
index fd301bc..8b46b53 100644
--- a/runtime/internal/flow/conn/flow.go
+++ b/runtime/internal/flow/conn/flow.go
@@ -206,14 +206,17 @@
//
// Discharges are organized in a map keyed by the discharge-identifier.
func (f *flw) LocalDischarges() map[string]security.Discharge {
+ var discharges map[string]security.Discharge
+ var err error
if f.dialed {
- _, discharges, err := f.conn.blessingsFlow.get(f.ctx, f.bkey, f.dkey)
- if err != nil {
- f.conn.Close(f.ctx, err)
- }
- return discharges
+ _, discharges, err = f.conn.blessingsFlow.get(f.ctx, f.bkey, f.dkey)
+ } else {
+ discharges, err = f.conn.blessingsFlow.getLatestDischarges(f.ctx, f.conn.lBlessings)
}
- return f.conn.lDischarges
+ if err != nil {
+ f.conn.Close(f.ctx, err)
+ }
+ return discharges
}
// RemoteDischarges returns the discharges presented by the remote end of the
@@ -221,14 +224,17 @@
//
// Discharges are organized in a map keyed by the discharge-identifier.
func (f *flw) RemoteDischarges() map[string]security.Discharge {
+ var discharges map[string]security.Discharge
+ var err error
if !f.dialed {
- _, discharges, err := f.conn.blessingsFlow.get(f.ctx, f.bkey, f.dkey)
- if err != nil {
- f.conn.Close(f.ctx, err)
- }
- return discharges
+ _, discharges, err = f.conn.blessingsFlow.get(f.ctx, f.bkey, f.dkey)
+ } else {
+ discharges, err = f.conn.blessingsFlow.getLatestDischarges(f.ctx, f.conn.rBlessings)
}
- return f.conn.rDischarges
+ if err != nil {
+ f.conn.Close(f.ctx, err)
+ }
+ return discharges
}
// Conn returns the connection the flow is multiplexed on.