graphvent/db.go

39 lines
856 B
Go

2024-03-08 00:22:51 -07:00
package graphvent
import (
badger "github.com/dgraph-io/badger/v3"
)
func WriteNodeInit(ctx *Context, node *Node) error {
return ctx.DB.Update(func(db *badger.Txn) error {
// Write node private key
// Write node type
// Write Node buffer size
// Write node extension list
// For each extension:
// Write each extension's current value
return nil
})
}
func WriteNodeChanges(ctx *Context, node *Node, changes map[ExtType]Changes) error {
return ctx.DB.Update(func(db *badger.Txn) error {
// Write the signal queue if it needs to be written
// For each ext in changes
// Write each change
return nil
})
}
func LoadNode(ctx *Context, id NodeID) (*Node, error) {
err := ctx.DB.Update(func(db *badger.Txn) error {
return nil
})
if err != nil {
return nil, err
}
return nil, nil
}