@@ -384,21 +384,48 @@ func accountHistoryIndexKey(addressHash common.Hash) []byte {
384
384
385
385
// storageHistoryIndexKey = StateHistoryStorageMetadataPrefix + addressHash + storageHash
386
386
func storageHistoryIndexKey (addressHash common.Hash , storageHash common.Hash ) []byte {
387
- return append (append (StateHistoryStorageMetadataPrefix , addressHash .Bytes ()... ), storageHash .Bytes ()... )
387
+ totalLen := len (StateHistoryStorageMetadataPrefix ) + 2 * common .HashLength
388
+ out := make ([]byte , totalLen )
389
+
390
+ off := 0
391
+ off += copy (out [off :], StateHistoryStorageMetadataPrefix )
392
+ off += copy (out [off :], addressHash .Bytes ())
393
+ copy (out [off :], storageHash .Bytes ())
394
+
395
+ return out
388
396
}
389
397
390
398
// accountHistoryIndexBlockKey = StateHistoryAccountBlockPrefix + addressHash + blockID
391
399
func accountHistoryIndexBlockKey (addressHash common.Hash , blockID uint32 ) []byte {
392
- var buf [4 ]byte
393
- binary .BigEndian .PutUint32 (buf [:], blockID )
394
- return append (append (StateHistoryAccountBlockPrefix , addressHash .Bytes ()... ), buf [:]... )
400
+ var buf4 [4 ]byte
401
+ binary .BigEndian .PutUint32 (buf4 [:], blockID )
402
+
403
+ totalLen := len (StateHistoryAccountBlockPrefix ) + common .HashLength + 4
404
+ out := make ([]byte , totalLen )
405
+
406
+ off := 0
407
+ off += copy (out [off :], StateHistoryAccountBlockPrefix )
408
+ off += copy (out [off :], addressHash .Bytes ())
409
+ copy (out [off :], buf4 [:])
410
+
411
+ return out
395
412
}
396
413
397
414
// storageHistoryIndexBlockKey = StateHistoryStorageBlockPrefix + addressHash + storageHash + blockID
398
415
func storageHistoryIndexBlockKey (addressHash common.Hash , storageHash common.Hash , blockID uint32 ) []byte {
399
- var buf [4 ]byte
400
- binary .BigEndian .PutUint32 (buf [:], blockID )
401
- return append (append (append (StateHistoryStorageBlockPrefix , addressHash .Bytes ()... ), storageHash .Bytes ()... ), buf [:]... )
416
+ var buf4 [4 ]byte
417
+ binary .BigEndian .PutUint32 (buf4 [:], blockID )
418
+
419
+ totalLen := len (StateHistoryStorageBlockPrefix ) + 2 * common .HashLength + 4
420
+ out := make ([]byte , totalLen )
421
+
422
+ off := 0
423
+ off += copy (out [off :], StateHistoryStorageBlockPrefix )
424
+ off += copy (out [off :], addressHash .Bytes ())
425
+ off += copy (out [off :], storageHash .Bytes ())
426
+ copy (out [off :], buf4 [:])
427
+
428
+ return out
402
429
}
403
430
404
431
// transitionStateKey = transitionStatusKey + hash
0 commit comments