1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-12 05:20:26 +00:00
mycorrhiza/hyphae/hypha.go

34 lines
877 B
Go
Raw Normal View History

package hyphae
2021-01-02 20:52:23 +00:00
import (
"github.com/bouncepaw/mycorrhiza/storage"
2021-01-02 20:52:23 +00:00
)
type Hypha struct {
Name string
Exists bool
TextPath string
BinaryPath string
OutLinks []string
BackLinks []string
}
2021-01-03 21:10:33 +00:00
// AddHypha adds a hypha named `name` with such `textPath` and `binaryPath`. Both paths can be empty. Does //not// check for hypha's existence beforehand. Count is handled.
func AddHypha(name, textPath, binaryPath string) {
txn := storage.DB.Txn(true)
2021-01-03 21:10:33 +00:00
txn.Insert("hyphae",
&Hypha{
Name: name,
TextPath: textPath,
BinaryPath: binaryPath,
OutLinks: make([]string, 0),
BackLinks: make([]string, 0),
})
txn.Commit()
IncrementCount()
}
// DeleteHypha clears both paths and all out-links from the named hypha and marks it as non-existent. It does not actually delete it from the memdb. Count is handled.
func DeleteHypha(name string) {
2021-01-02 20:52:23 +00:00
}