MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / initStorage

Function initStorage

cmd/cqld/adapter.go:44–66  ·  view source on GitHub ↗
(dbFile string)

Source from the content-addressed store, hash-verified

42}
43
44func initStorage(dbFile string) (stor *LocalStorage, err error) {
45 var st *storage.Storage
46 if st, err = storage.New(dbFile); err != nil {
47 return
48 }
49 //TODO(auxten): try BLOB for `id`, to performance test
50 _, err = st.Exec(context.Background(), []storage.Query{
51 {
52 Pattern: "CREATE TABLE IF NOT EXISTS `dht` (`id` TEXT NOT NULL PRIMARY KEY, `node` BLOB);",
53 },
54 })
55 if err != nil {
56 wd, _ := os.Getwd()
57 log.WithField("file", utils.FJ(wd, dbFile)).WithError(err).Error("create dht table failed")
58 return
59 }
60
61 stor = &LocalStorage{
62 Storage: st,
63 }
64
65 return
66}
67
68// SetNode handles dht storage node update.
69func (s *LocalStorage) SetNode(node *proto.Node) (err error) {

Callers 1

runNodeFunction · 0.85

Calls 5

ExecMethod · 0.95
NewFunction · 0.92
WithFieldFunction · 0.92
ErrorMethod · 0.80
WithErrorMethod · 0.80

Tested by

no test coverage detected