// Run is the main entry point for orbit drive p2p sync.
Run is the main entry point for orbit drive p2p sync.
// Run is the main entry point for orbit drive p2p sync .
func Run(c *config.Config) {
	sys.Notify("Starting file sync!")
	defer sys.Alert("Stopping file sync!")
	log.WithField("node-addr", c.NodeAddr).Info("Initializing ipfs shell...")
	ipfs.InitShell(c.NodeAddr)
	vt, err := initVTree(c)
	if err != nil {
		sys.Fatal(err.Error())
	}
	log.WithField("hash", vt.MerkleHash()).Info("VTree loaded merkle hash")
	watcher, err := initWatcher(c, vt)
	if err != nil {
		sys.Fatal(err.Error())
	}
	defer watcher.Stop()
	close := make(chan os.Signal, 2)
	signal.Notify(close, os.Interrupt, syscall.SIGTERM)
	for {
		select {
		case state := <-vt.StateChanges():
			log.WithFields(log.Fields{
				"path":      state.Path,
				"operation": state.Op,
			}).Info("vtree state change detected!")
			vtPb := vt.ToProto()
			parsedPb, err := proto.Marshal(vtPb)
			if err != nil {
				sys.Alert(err.Error())
			}
			log.WithField("byte-data", parsedPb).Info("vtree successfully parsed to pb!")
			p2p.GetMerkleHash()
		case <-close:
			return
		}
	}
}
func Run ( c * config . Config ) { sys . Notify ( " " ) defer sys . Alert ( " " ) log . WithField ( " " , c . NodeAddr ) . Info ( " " ) ipfs . InitShell ( c . NodeAddr ) vt , err := initVTree ( c ) if err != nil { sys . Fatal ( err . Error ( ) ) } log . WithField ( " " , vt . MerkleHash ( ) ) . Info ( " " ) watcher , err := initWatcher ( c , vt ) if err != nil { sys . Fatal ( err . Error ( ) ) } defer watcher . Stop ( ) close := make ( chan os . Signal , 2 ) signal . Notify ( close , os . Interrupt , syscall . SIGTERM ) for { select { case state := <- vt . StateChanges ( ) : log . WithFields ( log . Fields { " " : state . Path , " " : state . Op , } ) . Info ( " " ) vtPb := vt . ToProto ( ) parsedPb , err := proto . Marshal ( vtPb ) if err != nil { sys . Alert ( err . Error ( ) ) } log . WithField ( " " , parsedPb ) . Info ( " " ) p2p . GetMerkleHash ( ) case <- close : return } } }
Run is the main entry point for orbit drive p2p sync.
Run is the main entry point for orbit drive p2p sync .
// TODO: remove -> moving to web hub ??? // go initP2P(c)