Example #1
0
func (t *Tube) superscribe(peerXID kinfolk.FolkXID) {
	// log.Printf("tube superscribing %s", yup.xid.String())
	// defer func() {
	// 	log.Printf("tube superscribed %s\n%s", yup.xid.String(), t.Dump())
	// }()

	t.Lock()
	defer t.Unlock()
	yup := YTube{kinfolk.FolkXID(t.downstream.Open(kinfolk.XID(peerXID)))}
	go t.BulkWrite(yup.Subscribe(t.permXID, t.bulkRead()))
}
Example #2
0
func (x XTube) Subscribe(downXID kinfolk.FolkXID, upsync []*Record) []*Record {
	// log.Printf("xtube subscribing")
	// defer func() {
	// 	log.Printf("xtube subscribed\n%s", x.t.Dump())
	// }()

	if downXID.ID == x.t.permXID.ID {
		panic("x")
	}
	//
	x.t.Lock()
	defer x.t.Unlock()

	x.t.downstream.Open(kinfolk.XID(downXID)) // Add peer to downstream list
	go x.t.BulkWrite(upsync)                  // Catch up to peer after we return (and peer unlocks itself)
	return x.t.bulkRead()
}