maidsafe / sn_dbc

Safe Network DBCs
BSD 3-Clause "New" or "Revised" License
15 stars 16 forks source link

chore: impl Debug for Hash to display hex encoded #52

Closed dan-da closed 3 years ago

dan-da commented 3 years ago

This makes debug output a lot more readable. The sn_dbc_mint cli has a decode command for displaying various data structures using "{:#?}" formatting. There might be several hashes in a single data structure. Using default Debug formatting, each looks like:

       Hash(
            [
                141,
                146,
                235,
                200,
                252,
                24,
                79,
                186,
                2,
                53,
                69,
                190,
                237,
                247,
                68,
                201,
                27,
                75,
                211,
                232,
                22,
                39,
                167,
                33,
                77,
                84,
                92,
                118,
                173,
                113,
                225,
                99,
            ],
        )

Using the new formatting, each looks like:

        Hash(
            "8d92ebc8fc184fba023545beedf744c91b4bd3e81627a7214d545c76ad71e163",
        )

The hex encoded strings also match the display of DBC IDs in sn_dbc_mint output, so makes debug output easier to match up.