MCPcopy Create free account
hub / github.com/ethstorage/es-node / onResult

Method onResult

ethstorage/p2p/protocol/syncclient.go:1160–1190  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
1160func (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
1192func (s *SyncClient) decodeKV(payload *BlobPayload) ([]byte, bool) {
1193 recordDur := s.metrics.ClientRecordTimeUsed("decodeKv")

Callers 4

RequestL2RangeMethod · 0.95
RequestL2ListMethod · 0.95
OnBlobsByRangeMethod · 0.95
OnBlobsByListMethod · 0.95

Calls 3

decodeKVMethod · 0.95
checkBlobCommitMethod · 0.95
commitBlobsMethod · 0.95

Tested by

no test coverage detected