Exemple #1
0
func (app *NodeApp) LoadNodeIndex() {
	logger.Info("Loading node index")
	var err error

	if app.entities.node == nil {
		checkAppFatal("Node not found in app: %s", err)
	}

	nodeConfig, err := app.config.node.GetNode(app.entities.node.Data.Body.Name)
	checkAppFatal("Could not get id for node: %s", err)

	indexJson, err := app.fs.api.GetPrivate(app.entities.node.Data.Body.Id, nodeConfig.Index)
	checkAppFatal("Could not get index container: %s", err)

	indexContainer, err := document.NewContainer(indexJson)
	checkAppFatal("Could not load index container: %s", err)

	err = app.entities.node.Verify(indexContainer)
	checkAppFatal("Could not verify index: %s", err)

	decryptedIndexJson, err := app.entities.node.Decrypt(indexContainer)
	checkAppFatal("Could not decrypt container: %s", err)

	app.index.node, err = index.NewNode(decryptedIndexJson)
	checkAppFatal("Could not create index: %s", err)
}
Exemple #2
0
func (app *NodeApp) CreateNodeIndex() {
	var err error
	logger.Info("Creating node index")
	app.index.node, err = index.NewNode(nil)
	checkAppFatal("Could not create index: %s", err)
	app.index.node.Data.Body.Id = NewID()
}
Exemple #3
0
func (cont *NodeController) CreateIndex() (*index.NodeIndex, error) {
	logger.Debug("creating node index")

	index, err := index.NewNode(nil)
	if err != nil {
		return nil, err
	}

	index.Data.Body.Id = x509.NewID()
	logger.Debugf("created index with id '%s'", index.Id())

	logger.Trace("returning index")
	return index, nil
}