arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
hermez-node/common/utils.go
common/utils.goRaw
 1package common
 2
 3import (
 4	"math/big"
 5
 6	ethCommon "github.com/ethereum/go-ethereum/common"
 7)
 8
 9// SwapEndianness swaps the order of the bytes in the slice.
10func SwapEndianness(b []byte) []byte {
11	o := make([]byte, len(b))
12	for i := range b {
13		o[len(b)-1-i] = b[i]
14	}
15	return o
16}
17
18// EthAddrToBigInt returns a *big.Int from a given ethereum common.Address.
19func EthAddrToBigInt(a ethCommon.Address) *big.Int {
20	return new(big.Int).SetBytes(a.Bytes())
21}