onResult is exclusively called by the main loop, and has thus direct access to the request bookkeeping state. This function verifies if the result is canonical, and either promotes the result or moves the result into quarantine.
(blobs []*BlobPayload)
| 1158 | // onResult is exclusively called by the main loop, and has thus direct access to the request bookkeeping state. |
| 1159 | // This function verifies if the result is canonical, and either promotes the result or moves the result into quarantine. |
| 1160 | func (s *SyncClient) onResult(blobs []*BlobPayload) (uint64, uint64, []uint64, error) { |
| 1161 | var ( |
| 1162 | synced uint64 |
| 1163 | syncedBytes uint64 |
| 1164 | inserted = make([]uint64, 0) |
| 1165 | indices = make([]uint64, 0) |
| 1166 | decodedBlobs = make([][]byte, 0) |
| 1167 | commits = make([]common.Hash, 0) |
| 1168 | ) |
| 1169 | for _, payload := range blobs { |
| 1170 | synced++ |
| 1171 | syncedBytes += uint64(len(payload.EncodedBlob)) |
| 1172 | |
| 1173 | decodedBlob, success := s.decodeKV(payload) |
| 1174 | if !success { |
| 1175 | continue |
| 1176 | } |
| 1177 | |
| 1178 | success = s.checkBlobCommit(decodedBlob, payload) |
| 1179 | if !success { |
| 1180 | continue |
| 1181 | } |
| 1182 | |
| 1183 | indices = append(indices, payload.BlobIndex) |
| 1184 | decodedBlobs = append(decodedBlobs, decodedBlob) |
| 1185 | commits = append(commits, payload.BlobCommit) |
| 1186 | } |
| 1187 | |
| 1188 | inserted, err := s.commitBlobs(indices, decodedBlobs, commits) |
| 1189 | return synced, syncedBytes, inserted, err |
| 1190 | } |
| 1191 | |
| 1192 | func (s *SyncClient) decodeKV(payload *BlobPayload) ([]byte, bool) { |
| 1193 | recordDur := s.metrics.ClientRecordTimeUsed("decodeKv") |
no test coverage detected