From 107896f4fdf7382aed2e3d9ba21ae7b3c461906c Mon Sep 17 00:00:00 2001 From: Calvin Kim Date: Thu, 2 May 2024 19:44:35 +0900 Subject: [PATCH] blockchain, wire: rename ToString() to String() Doing this allows pretty printing because for %v go will call String() instead of printing out a byte slice. --- blockchain/utreexoviewpoint.go | 2 +- wire/leaf.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/blockchain/utreexoviewpoint.go b/blockchain/utreexoviewpoint.go index dbaa9c7d..447b6c40 100644 --- a/blockchain/utreexoviewpoint.go +++ b/blockchain/utreexoviewpoint.go @@ -960,7 +960,7 @@ func (b *BlockChain) VerifyUData(ud *wire.UData, txIns []*wire.TxIn, remember bo for i, txIn := range txIns { leafHash := ud.LeafDatas[i].LeafHash() str += fmt.Sprintf("txIn: %s, leafdata: %s, hash %s\n", txIn.PreviousOutPoint.String(), - ud.LeafDatas[i].ToString(), hex.EncodeToString(leafHash[:])) + ud.LeafDatas[i].String(), hex.EncodeToString(leafHash[:])) } str += fmt.Sprintf("err: %s", err.Error()) return fmt.Errorf(str) diff --git a/wire/leaf.go b/wire/leaf.go index 5a2c9907..40587e9a 100644 --- a/wire/leaf.go +++ b/wire/leaf.go @@ -133,8 +133,8 @@ func (l *LeafData) LeafHash() [32]byte { return *(*[32]byte)(digest.Sum(nil)) } -// ToString turns a LeafData into a string for logging. -func (l *LeafData) ToString() (s string) { +// String turns a LeafData into a string for logging. +func (l *LeafData) String() (s string) { s += fmt.Sprintf("BlockHash:%s,", hex.EncodeToString(l.BlockHash[:])) s += fmt.Sprintf("OutPoint:%s,", l.OutPoint.String()) s += fmt.Sprintf("Amount:%d,", l.Amount)