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 {
|
2024-03-08 14:35:23 -07:00
|
|
|
return ctx.DB.Update(func(tx *badger.Txn) error {
|
|
|
|
_, err := node.ID.MarshalBinary()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2024-03-08 00:22:51 -07:00
|
|
|
// 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 {
|
2024-03-08 14:35:23 -07:00
|
|
|
return ctx.DB.Update(func(tx *badger.Txn) error {
|
2024-03-08 00:22:51 -07:00
|
|
|
// Write the signal queue if it needs to be written
|
2024-03-08 14:35:23 -07:00
|
|
|
if node.writeSignalQueue {
|
|
|
|
node.writeSignalQueue = false
|
|
|
|
}
|
|
|
|
|
2024-03-08 00:22:51 -07:00
|
|
|
// For each ext in changes
|
|
|
|
// Write each change
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func LoadNode(ctx *Context, id NodeID) (*Node, error) {
|
2024-03-08 14:35:23 -07:00
|
|
|
err := ctx.DB.Update(func(tx *badger.Txn) error {
|
2024-03-08 00:22:51 -07:00
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil, nil
|
|
|
|
}
|