Skip to content

Commit

Permalink
genesis/Hashes.String() for debug purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
rus-alex committed Oct 4, 2023
1 parent 0efe5b0 commit e157c8f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions opera/genesis/types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package genesis

import (
"fmt"
"sort"
"strings"

"github.com/Fantom-foundation/lachesis-base/hash"

"github.com/Fantom-foundation/go-opera/inter/ibr"
Expand Down Expand Up @@ -45,6 +49,19 @@ func (hh Hashes) Equal(hh2 Hashes) bool {
return hh.Includes(hh2) && hh2.Includes(hh)
}

func (hh Hashes) String() string {
bb := make([]string, 0, len(hh))
for n, h := range hh {
bb = append(bb, fmt.Sprintf("%s: %s", n, h.String()))
}
sort.Strings(bb)
return "{" + strings.Join(bb, ", ") + "}"
}

func (h Header) Equal(h2 Header) bool {
return h == h2
}

func (h Header) String() string {
return fmt.Sprintf("{%d, net:%s, id:%s}", h.NetworkID, h.NetworkName, h.GenesisID.String())
}

0 comments on commit e157c8f

Please sign in to comment.