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

Method GetAllNodeInfo

cmd/cqld/adapter.go:187–227  ·  view source on GitHub ↗

GetAllNodeInfo implements consistent.Persistence.

()

Source from the content-addressed store, hash-verified

185
186// GetAllNodeInfo implements consistent.Persistence.
187func (s *KVServer) GetAllNodeInfo() (nodes []proto.Node, err error) {
188 var result [][]interface{}
189 query := "SELECT `node` FROM `dht`;"
190 _, _, result, err = s.storage.Query(context.Background(), []storage.Query{
191 {
192 Pattern: query,
193 },
194 })
195 if err != nil {
196 log.WithField("query", query).WithError(err).Error("query failed")
197 return
198 }
199 log.Debugf("SQL: %#v\nResults: %#v", query, result)
200
201 nodes = make([]proto.Node, 0, len(result))
202
203 for _, r := range result {
204 if len(r) == 0 {
205 continue
206 }
207 nodeBytes, ok := r[0].([]byte)
208 log.Debugf("nodeBytes: %#v, %#v", nodeBytes, ok)
209 if !ok {
210 continue
211 }
212
213 nodeDec := proto.NewNode()
214 err = utils.DecodeMsgPack(nodeBytes, nodeDec)
215 if err != nil {
216 log.WithError(err).Error("unmarshal node info failed")
217 continue
218 }
219 nodes = append(nodes, *nodeDec)
220 }
221
222 if len(nodes) > 0 {
223 err = nil
224 }
225
226 return
227}
228
229// Stop stops the dht node server and wait for inflight gossip requests.
230func (s *KVServer) Stop() {

Callers

nothing calls this directly

Calls 8

WithFieldFunction · 0.92
DebugfFunction · 0.92
NewNodeFunction · 0.92
DecodeMsgPackFunction · 0.92
WithErrorFunction · 0.92
ErrorMethod · 0.80
WithErrorMethod · 0.80
QueryMethod · 0.65

Tested by

no test coverage detected