github.com/mit-dci/lit@v0.0.0-20221102210550-8c3d3b49f2ce/litrpc/towercmds.go (about)

     1  package litrpc
     2  
     3  import "fmt"
     4  
     5  type WatchArgs struct {
     6  	ChanIdx, SendToPeer uint32
     7  }
     8  
     9  type WatchReply struct {
    10  	Msg string
    11  }
    12  
    13  func (r *LitRPC) Watch(args WatchArgs, reply *WatchReply) error {
    14  
    15  	// load the whole channel from disk (pretty inefficient)
    16  	qc, err := r.Node.GetQchanByIdx(args.ChanIdx)
    17  	if err != nil {
    18  		return err
    19  	}
    20  	// see if channel is closed and error early
    21  	if qc.CloseData.Closed {
    22  		return fmt.Errorf("Can't push; channel %d closed", args.ChanIdx)
    23  	}
    24  
    25  	err = r.Node.SyncWatch(qc, args.SendToPeer)
    26  	if err != nil {
    27  		return err
    28  	}
    29  
    30  	reply.Msg = "ok"
    31  	return nil
    32  }