mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-22 11:31:02 +00:00
common: fixed byte padding functions
Byte padding function should return the given slice if the length is smaller or equal rather than *only* smaller than. This fix improves almost all EVM push operations.
This commit is contained in:
parent
10582a97ca
commit
e1e87d8b1a
@ -89,18 +89,18 @@ func Hex2BytesFixed(str string, flen int) []byte {
|
||||
}
|
||||
|
||||
func RightPadBytes(slice []byte, l int) []byte {
|
||||
if l < len(slice) {
|
||||
if l <= len(slice) {
|
||||
return slice
|
||||
}
|
||||
|
||||
padded := make([]byte, l)
|
||||
copy(padded[0:len(slice)], slice)
|
||||
copy(padded, slice)
|
||||
|
||||
return padded
|
||||
}
|
||||
|
||||
func LeftPadBytes(slice []byte, l int) []byte {
|
||||
if l < len(slice) {
|
||||
if l <= len(slice) {
|
||||
return slice
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user