From 37dce98f96ca9de47c2a548764952419480fd559 Mon Sep 17 00:00:00 2001
From: Kirill Smelkov <kirr@nexedi.com>
Date: Fri, 29 Jan 2021 12:42:41 +0300
Subject: [PATCH] .

---
 go/neo/mastered.go | 40 ++++++++++++++++++----------------------
 1 file changed, 18 insertions(+), 22 deletions(-)

diff --git a/go/neo/mastered.go b/go/neo/mastered.go
index 818a0f39..915d88f8 100644
--- a/go/neo/mastered.go
+++ b/go/neo/mastered.go
@@ -39,15 +39,25 @@ import (
 	"lab.nexedi.com/kirr/neo/go/neo/xneo"
 )
 
-// _MasteredNode provides base functioanlity of a NEO node driven by master.
+// _MasteredNode provides base functionality of a NEO node driven by master.
 //
-// XXX requests/notifications from master go through filter that handles
-//     nodeTab/partTab/ClusterState changes ...
+// It connects to master, identifies to it, and handles master messages about
+// δNodeTab, δPartTab and δClusterState to update local replica of cluster
+// state. The other messages from master are passed through to RecvM1. In other
+// words _MasteredNode installs a kind of reception pipeline in between master
+// and _MasteredNode user:
 //
-// talkMaster persists connection to master node, and receives update from M
-// about δNodeTab, δPartTab, ClusterState.
 //
-// XXX how to use
+//	                       δNodeTab
+//	                       δPartTab
+//	                       δClusterState
+//	                     ↑
+//	        RecvM1   ---------------
+//	 user <-------- | _MasteredNode | <- M
+//	                 ---------------
+//
+// This pipeline is operated by TalkMaster.
+// The connection to master is persisted by redial as needed.
 type _MasteredNode struct {
 	myInfo      proto.NodeInfo // type, laddr, nid, state, idtime
 	ClusterName string
@@ -58,7 +68,7 @@ type _MasteredNode struct {
 	stateMu      sync.RWMutex
 	state        xneo.ClusterState
 
-	// operational state in node is maintained by talkMaster.
+	// operational state in node is maintained by TalkMaster.
 	// users retrieve it via withOperational().	XXX recheck
 	//
 	// NOTE being operational means:
@@ -73,19 +83,7 @@ type _MasteredNode struct {
 
 
 	flags _MasteredNodeFlags
-	rxm   chan _RxM      // talkMaster -> RecvM1
-
-/*
-	// TODO -> RecvM1 instead
-
-	// OnNotify, if !nil, is called when master notifies this node with a message.
-	// XXX not called for δstate
-	OnNotify    func(msg proto.Msg) error // XXX kill
-
-	// OnNotifyδPartTab, if !nil, is called when master notifies this node
-	// with a change to partition table.  (used by S to persist partTab)
-	OnNotifyδPartTab func(pt *xneo.PartitionTable) error // XXX kill
-*/
+	rxm   chan _RxM          // TalkMaster -> RecvM1
 }
 
 // _RxM represents a request or event received from master.
@@ -286,8 +284,6 @@ func (node *_MasteredNode) recvMaster1(ctx context.Context, req neonet.Request)
 	return nil
 }
 
-var eventMasterReconnect = errors.New("(re)connected to master")
-
 // RecvM1 receives request from master filtered through δstate handler.
 //
 // XXX link down ?
-- 
2.30.9