From 54f75bb99906a43b7b62766a98dd0899bdba0301 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 1 Jun 2022 11:55:16 +0300 Subject: [PATCH] consensus: don't use WriteArray for PrepareRequests It's convenient, but it's not efficient due to reflection use. --- pkg/consensus/prepare_request.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/consensus/prepare_request.go b/pkg/consensus/prepare_request.go index 3f883c1fd..1c21348f3 100644 --- a/pkg/consensus/prepare_request.go +++ b/pkg/consensus/prepare_request.go @@ -26,7 +26,10 @@ func (p *prepareRequest) EncodeBinary(w *io.BinWriter) { w.WriteBytes(p.prevHash[:]) w.WriteU64LE(p.timestamp) w.WriteU64LE(p.nonce) - w.WriteArray(p.transactionHashes) + w.WriteVarUint(uint64(len(p.transactionHashes))) + for i := range p.transactionHashes { + w.WriteBytes(p.transactionHashes[i][:]) + } if p.stateRootEnabled { w.WriteBytes(p.stateRoot[:]) }