From 4258567eb74fbc47b2091ee7cc434df0867e9bff Mon Sep 17 00:00:00 2001 From: Giulio rebuffo Date: Thu, 25 Nov 2021 06:18:17 +0100 Subject: [PATCH] added util to convert to H2048 interface (#188) * added util to convert to H2048 interface * plain bytes * lint --- gointerfaces/type_utils.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gointerfaces/type_utils.go b/gointerfaces/type_utils.go index 9450d2342..c9218611b 100644 --- a/gointerfaces/type_utils.go +++ b/gointerfaces/type_utils.go @@ -29,6 +29,19 @@ func ConvertH2048ToBloom(h2048 *types.H2048) [256]byte { return bloom } +func ConvertBytesToH2048(data []byte) *types.H2048 { + return &types.H2048{ + Lo: &types.H1024{ + Lo: ConvertBytesToH512(data), + Hi: ConvertBytesToH512(data[64:]), + }, + Hi: &types.H1024{ + Lo: ConvertBytesToH512(data[128:]), + Hi: ConvertBytesToH512(data[192:]), + }, + } +} + func ConvertH256ToHash(h256 *types.H256) [32]byte { var hash [32]byte binary.BigEndian.PutUint64(hash[0:], h256.Hi.Hi)