Function prettify
auto prettify(T)
(
auto const ref T input
) nothrow;
Returns
A formatting struct for a type, or the value if no such struct exists
Example
Hash key = Hash("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f" ~
"1b60a8ce26f000000000019d6689c085ae165831e934ff763ae46a2" ~
"a6c172b3f1b60a8ce26f");
Hash seed = Hash("0X4A5E1E4BAAB89F3A32518A88C31BC87F618F76673E2CC77AB212" ~
"7B7AFDEDA33B4A5E1E4BAAB89F3A32518A88C31BC87F618F76673E" ~
"2CC77AB2127B7AFDEDA33B");
Signature sig = Signature .fromString("0x000000000000000000016f605ea9638d7bff58d2c0c" ~
"c2467c18e38b36367be78000000000000000000016f60" ~
"5ea9638d7bff58d2c0cc2467c18e38b36367be78");
Enrollment enrollment =
{
utxo_key: key,
commitment: seed,
enroll_sig: sig,
};
static immutable Res1 = `{ utxo: 0x0000...e26f, seed: 0x4a5e...a33b, sig: 0x0000...be78 }`;
assert(Res1 == format("%s", prettify(enrollment)),
format("%s", prettify(enrollment)));
Example
import agora .common .Set;
import agora .crypto .Hash;
import agora .serialization .Serializer;
Hash key = Hash("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f" ~
"1b60a8ce26f000000000019d6689c085ae165831e934ff763ae46a2" ~
"a6c172b3f1b60a8ce26f");
Hash seed = Hash("0X4A5E1E4BAAB89F3A32518A88C31BC87F618F76673E2CC77AB212" ~
"7B7AFDEDA33B4A5E1E4BAAB89F3A32518A88C31BC87F618F76673E" ~
"2CC77AB2127B7AFDEDA33B");
Signature sig = Signature .fromString("0x000000000000000000016f605ea9638d7bff58d2c0c" ~
"c2467c18e38b36367be78000000000000000000016f60" ~
"5ea9638d7bff58d2c0cc2467c18e38b36367be78");
const Enrollment record =
{
utxo_key: key,
commitment: seed,
enroll_sig: sig,
};
const(ConsensusData) cd =
{
tx_set: hashFull(37),
enrolls: [ record, record, ],
missing_validators: [0, 2, 4],
};
static immutable Res1 = `{ tx_set: 0x992e...6694, enrolls: [{ utxo: 0x0000...e26f, seed: 0x4a5e...a33b, sig: 0x0000...be78 }, { utxo: 0x0000...e26f, seed: 0x4a5e...a33b, sig: 0x0000...be78 }], missing_validators: [0, 2, 4] }`;
assert(Res1 == format("%s", prettify(cd)),
format("%s", prettify(cd)));
Example
auto quorum = immutable(QuorumConfig)(2, [0, 1],
[immutable(QuorumConfig)(3, [0, 1],
[immutable(QuorumConfig)(4, [0, 1, 1])])]);
static immutable Res1 = `{ thresh: 2, nodes: [0, 1], subqs: [{ thresh: 3, nodes: [0, 1], subqs: [{ thresh: 4, nodes: [0, 1, 1], subqs: [] }] }] }`;
assert(Res1 == format("%s", prettify(quorum)),
format("%s", prettify(quorum)));