MCPcopy Create free account
hub / github.com/NextDotID/proof_server / ProofChainCreateFromValidator

Function ProofChainCreateFromValidator

model/proof_chain.go:239–278  ·  view source on GitHub ↗
(validator *validator.Base)

Source from the content-addressed store, hash-verified

237}
238
239func ProofChainCreateFromValidator(validator *validator.Base) (pc *ProofChain, err error) {
240 pc = &ProofChain{
241 Action: validator.Action,
242 Persona: MarshalPersona(validator.Pubkey),
243 Identity: validator.Identity, // TODO: exception may occur
244 AltID: validator.AltID,
245 Platform: validator.Platform,
246 Location: validator.ProofLocation,
247 Signature: MarshalSignature(validator.Signature),
248 SignaturePayload: validator.SignaturePayload,
249 CreatedAt: validator.CreatedAt,
250 Uuid: validator.Uuid.String(),
251 Previous: nil,
252 ArweaveID: "",
253 }
254
255 if validator.Previous != "" {
256 previous, err := ProofChainFindBySignature(validator.Previous)
257 if err != nil {
258 return nil, xerrors.Errorf("%w", err)
259 }
260
261 pc.Previous = previous
262 }
263
264 if len(validator.Extra) != 0 {
265 extra_json, err := json.Marshal(validator.Extra)
266 if err != nil {
267 return nil, xerrors.Errorf("%w", err)
268 }
269 pc.Extra = datatypes.JSON(extra_json)
270 }
271
272 tx := DB.Create(pc)
273 if tx.Error != nil {
274 return nil, xerrors.Errorf("%w", err)
275 }
276
277 return pc, nil
278}
279
280func ProofChainFindByPersona(persona string, all_data bool, from int, limit int) (total int64, rs []ProofChainItem, err error) {
281 rs = make([]ProofChainItem, 0, 0)

Callers 5

applyUploadFunction · 0.92
insert_proofFunction · 0.92
insert_proof_exactFunction · 0.92
insert_eth_proofFunction · 0.92

Calls 3

MarshalPersonaFunction · 0.85
MarshalSignatureFunction · 0.85

Tested by 4

insert_proofFunction · 0.74
insert_proof_exactFunction · 0.74
insert_eth_proofFunction · 0.74