Skip to content

Commit e6c3e26

Browse files
committed
use protobuf getters in hasher
1 parent 9fe61b5 commit e6c3e26

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

api/hashing/node_hashing.go

+19-19
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,46 @@ import (
1515
func HashStoreChunksRequest(request *grpc.StoreChunksRequest) []byte {
1616
hasher := sha3.NewLegacyKeccak256()
1717

18-
hashBatchHeader(hasher, request.Batch.Header)
19-
for _, blobCertificate := range request.Batch.BlobCertificates {
18+
hashBatchHeader(hasher, request.GetBatch().GetHeader())
19+
for _, blobCertificate := range request.GetBatch().GetBlobCertificates() {
2020
hashBlobCertificate(hasher, blobCertificate)
2121
}
22-
hashUint32(hasher, request.DisperserID)
22+
hashUint32(hasher, request.GetDisperserID())
2323

2424
return hasher.Sum(nil)
2525
}
2626

2727
func hashBlobCertificate(hasher hash.Hash, blobCertificate *common.BlobCertificate) {
28-
hashBlobHeader(hasher, blobCertificate.BlobHeader)
29-
hasher.Write(blobCertificate.Signature)
30-
for _, relayKey := range blobCertificate.RelayKeys {
28+
hashBlobHeader(hasher, blobCertificate.GetBlobHeader())
29+
hasher.Write(blobCertificate.GetSignature())
30+
for _, relayKey := range blobCertificate.GetRelayKeys() {
3131
hashUint32(hasher, relayKey)
3232
}
3333
}
3434

3535
func hashBlobHeader(hasher hash.Hash, header *common.BlobHeader) {
36-
hashUint32(hasher, header.Version)
37-
for _, quorum := range header.QuorumNumbers {
36+
hashUint32(hasher, header.GetVersion())
37+
for _, quorum := range header.GetQuorumNumbers() {
3838
hashUint32(hasher, quorum)
3939
}
40-
hashBlobCommitment(hasher, header.Commitment)
41-
hashPaymentHeader(hasher, header.PaymentHeader)
40+
hashBlobCommitment(hasher, header.GetCommitment())
41+
hashPaymentHeader(hasher, header.GetPaymentHeader())
4242
}
4343

4444
func hashBatchHeader(hasher hash.Hash, header *common.BatchHeader) {
45-
hasher.Write(header.BatchRoot)
46-
hashUint64(hasher, header.ReferenceBlockNumber)
45+
hasher.Write(header.GetBatchRoot())
46+
hashUint64(hasher, header.GetReferenceBlockNumber())
4747
}
4848

4949
func hashBlobCommitment(hasher hash.Hash, commitment *commonv1.BlobCommitment) {
50-
hasher.Write(commitment.Commitment)
51-
hasher.Write(commitment.LengthCommitment)
52-
hasher.Write(commitment.LengthProof)
53-
hashUint32(hasher, commitment.Length)
50+
hasher.Write(commitment.GetCommitment())
51+
hasher.Write(commitment.GetLengthCommitment())
52+
hasher.Write(commitment.GetLengthProof())
53+
hashUint32(hasher, commitment.GetLength())
5454
}
5555

5656
func hashPaymentHeader(hasher hash.Hash, header *common.PaymentHeader) {
57-
hasher.Write([]byte(header.AccountId))
58-
hashInt64(hasher, header.Timestamp)
59-
hasher.Write(header.CumulativePayment)
57+
hasher.Write([]byte(header.GetAccountId()))
58+
hashInt64(hasher, header.GetTimestamp())
59+
hasher.Write(header.GetCumulativePayment())
6060
}

0 commit comments

Comments
 (0)