refactor service constructor into two parts

This commit is contained in:
vyzo 2018-04-23 14:44:14 +03:00
parent fbaf21c098
commit 4e3eaa7ba0

7
svc.go
View File

@ -36,9 +36,14 @@ func NewRendezvousService(ctx context.Context, host host.Host, dbpath string, rz
return nil, err
}
rz := NewRendezvousServiceWithDB(host, db, rzs...)
return rz, nil
}
func NewRendezvousServiceWithDB(host host.Host, db *DB, rzs ...RendezvousSync) *RendezvousService {
rz := &RendezvousService{DB: db, rzs: rzs}
host.SetStreamHandler(RendezvousProto, rz.handleStream)
return rz, nil
return rz
}
func (rz *RendezvousService) handleStream(s inet.Stream) {