MCPcopy Create free account
hub / github.com/DNAProject/DNA / removeController

Function removeController

smartcontract/service/native/did/controller.go:137–161  ·  view source on GitHub ↗
(srvc *native.NativeService)

Source from the content-addressed store, hash-verified

135}
136
137func removeController(srvc *native.NativeService) ([]byte, error) {
138 source := common.NewZeroCopySource(srvc.Input)
139 // arg0: id
140 arg0, err := utils.DecodeVarBytes(source)
141 if err != nil {
142 return utils.BYTE_FALSE, fmt.Errorf("argument 0 error")
143 }
144 // arg1: public key index
145 arg1, err := utils.DecodeVarUint(source)
146 if err != nil {
147 return utils.BYTE_FALSE, fmt.Errorf("argument 1 error")
148 }
149 encId, err := encodeID(arg0)
150 if err != nil {
151 return utils.BYTE_FALSE, err
152 }
153 if err := checkWitnessByIndex(srvc, encId, uint32(arg1)); err != nil {
154 return utils.BYTE_FALSE, fmt.Errorf("checkWitness failed, %s", err)
155 }
156 key := append(encId, FIELD_CONTROLLER)
157 srvc.CacheDB.Delete(key)
158
159 newEvent(srvc, []interface{}{"RemoveController", string(arg0)})
160 return utils.BYTE_TRUE, nil
161}
162
163func addKeyByController(srvc *native.NativeService) ([]byte, error) {
164 source := common.NewZeroCopySource(srvc.Input)

Callers 1

rmCtrlFunction · 0.85

Calls 8

NewZeroCopySourceFunction · 0.92
DecodeVarBytesFunction · 0.92
DecodeVarUintFunction · 0.92
encodeIDFunction · 0.85
checkWitnessByIndexFunction · 0.85
newEventFunction · 0.85
ErrorfMethod · 0.80
DeleteMethod · 0.65

Tested by 1

rmCtrlFunction · 0.68