mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-06 16:17:11 +00:00
libs/log: format []byte as hexidecimal string (uppercased) (#5960)
Closes: #5806 Co-authored-by: Lanie Hei <heixx011@umn.edu>
This commit is contained in:
co-authored by
Lanie Hei
parent
7e0436c6e6
commit
d76add65a6
+5
-2
@@ -8,7 +8,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// The main purpose of HexBytes is to enable HEX-encoding for json/encoding.
|
||||
// HexBytes enables HEX-encoding for json/encoding.
|
||||
type HexBytes []byte
|
||||
|
||||
var (
|
||||
@@ -58,7 +58,7 @@ func (bz *HexBytes) UnmarshalJSON(data []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Allow it to fulfill various interfaces in light-client, etc...
|
||||
// Bytes fulfils various interfaces in light-client, etc...
|
||||
func (bz HexBytes) Bytes() []byte {
|
||||
return bz
|
||||
}
|
||||
@@ -67,6 +67,9 @@ func (bz HexBytes) String() string {
|
||||
return strings.ToUpper(hex.EncodeToString(bz))
|
||||
}
|
||||
|
||||
// Format writes either address of 0th element in a slice in base 16 notation,
|
||||
// with leading 0x (%p), or casts HexBytes to bytes and writes as hexadecimal
|
||||
// string to s.
|
||||
func (bz HexBytes) Format(s fmt.State, verb rune) {
|
||||
switch verb {
|
||||
case 'p':
|
||||
|
||||
Reference in New Issue
Block a user