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

Method Deserialization

smartcontract/service/native/did/attribute.go:82–120  ·  view source on GitHub ↗
(source *common.ZeroCopySource)

Source from the content-addressed store, hash-verified

80}
81
82func (this *attribute) Deserialization(source *common.ZeroCopySource) error {
83 k, _, irregular, eof := source.NextVarBytes()
84 if irregular {
85 return common.ErrIrregularData
86 }
87 if eof {
88 return io.ErrUnexpectedEOF
89 }
90 if len(k) > MAX_KEY_SIZE {
91 return fmt.Errorf("key size %d is too large, max limit is %d", len(k), MAX_KEY_SIZE)
92 }
93
94 vt, _, irregular, eof := source.NextVarBytes()
95 if irregular {
96 return common.ErrIrregularData
97 }
98 if eof {
99 return io.ErrUnexpectedEOF
100 }
101 if len(vt) > MAX_TYPE_SIZE {
102 return fmt.Errorf("type size %d is too large, max limit is %d", len(vt), MAX_TYPE_SIZE)
103 }
104
105 v, _, irregular, eof := source.NextVarBytes()
106 if irregular {
107 return common.ErrIrregularData
108 }
109 if eof {
110 return io.ErrUnexpectedEOF
111 }
112 if len(v) > MAX_VALUE_SIZE {
113 return fmt.Errorf("value size %d is too large, max limit is %d", len(v), MAX_VALUE_SIZE)
114 }
115
116 this.key = k
117 this.value = v
118 this.valueType = vt
119 return nil
120}
121
122func insertOrUpdateAttr(srvc *native.NativeService, encID []byte, attr *attribute) error {
123 key := append(encID, FIELD_ATTR)

Callers 3

regIdWithAttributesFunction · 0.95
addAttributesFunction · 0.95

Calls 2

NextVarBytesMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected