common: improve variable names for ExtractAddressFromBytes(), close XFN-27 (#1726)

This commit is contained in:
Daniel Liu 2025-11-15 19:18:01 +08:00 committed by GitHub
parent 4716dc11af
commit 07e2609c25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -408,15 +408,15 @@ func ExtractAddressToBytes(penalties []Address) []byte {
return data
}
func ExtractAddressFromBytes(bytePenalties []byte) []Address {
if len(bytePenalties) < AddressLength {
func ExtractAddressFromBytes(rawBytes []byte) []Address {
if len(rawBytes) < AddressLength {
return []Address{}
}
penalties := make([]Address, len(bytePenalties)/AddressLength)
for i := 0; i < len(penalties); i++ {
copy(penalties[i][:], bytePenalties[i*AddressLength:])
addresses := make([]Address, len(rawBytes)/AddressLength)
for i := 0; i < len(addresses); i++ {
copy(addresses[i][:], rawBytes[i*AddressLength:])
}
return penalties
return addresses
}
// AddressEIP55 is an alias of Address with a customized json marshaller