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

Function setNode

crypto/kms/pubkeystore.go:281–301  ·  view source on GitHub ↗

setNode sets id and its publicKey.

(nodeInfo *proto.Node)

Source from the content-addressed store, hash-verified

279
280// setNode sets id and its publicKey.
281func setNode(nodeInfo *proto.Node) (err error) {
282 pksLock.Lock()
283 defer pksLock.Unlock()
284 if pks == nil || pks.db == nil {
285 return ErrPKSNotInitialized
286 }
287
288 nodeBuf, err := utils.EncodeMsgPack(nodeInfo)
289 if err != nil {
290 err = errors.Wrap(err, "marshal node info failed")
291 return
292 }
293 log.Debugf("set node: %#v", nodeInfo)
294
295 _, err = pks.db.Writer().Exec(setRecordSQL, string(nodeInfo.ID), nodeBuf.Bytes())
296 if err != nil {
297 err = errors.Wrap(err, "set node info failed")
298 }
299
300 return
301}
302
303// DelNode removes PublicKey to the id.
304func DelNode(id proto.NodeID) (err error) {

Callers 4

InitPublicKeyStoreFunction · 0.85
SetNodeFunction · 0.85
TestDBFunction · 0.85

Calls 5

EncodeMsgPackFunction · 0.92
DebugfFunction · 0.92
ExecMethod · 0.65
WriterMethod · 0.65
BytesMethod · 0.45

Tested by 2

TestDBFunction · 0.68