CommitBlob This function will be called when p2p sync received a blob. Return err if the passed commit and the one queried from contract are not matched.
(kvIndex uint64, blob []byte, commit common.Hash)
| 303 | // CommitBlob This function will be called when p2p sync received a blob. |
| 304 | // Return err if the passed commit and the one queried from contract are not matched. |
| 305 | func (s *StorageManager) CommitBlob(kvIndex uint64, blob []byte, commit common.Hash) error { |
| 306 | encodedBlob, success, err := s.shardManager.TryEncodeKV(kvIndex, blob, commit) |
| 307 | if !success || err != nil { |
| 308 | return errors.New("blob encode failed") |
| 309 | } |
| 310 | |
| 311 | s.mu.Lock() |
| 312 | defer s.mu.Unlock() |
| 313 | |
| 314 | metas, err := s.getKvMetas([]uint64{kvIndex}) |
| 315 | if err != nil { |
| 316 | return err |
| 317 | } |
| 318 | |
| 319 | if len(metas) != 1 { |
| 320 | return errors.New("invalid params lens") |
| 321 | } |
| 322 | |
| 323 | contractMeta := metas[0] |
| 324 | return s.commitEncodedBlob(kvIndex, encodedBlob, commit, contractMeta) |
| 325 | } |
| 326 | |
| 327 | func (s *StorageManager) commitEncodedBlob(kvIndex uint64, encodedBlob []byte, commit common.Hash, contractMeta [32]byte) error { |
| 328 | // the commit is different with what we got from the contract, so should not commit |
nothing calls this directly
no test coverage detected