-
Notifications
You must be signed in to change notification settings - Fork 162
manually unpack txid in txin #2501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b7bd41c
to
2198430
Compare
a14262f
to
f5101c6
Compare
f5101c6
to
d1bcb50
Compare
TxInCompact32 :: | ||
HS.SizeHash (CC.HASH crypto) ~ 32 => | ||
{-# UNPACK #-} !Word64 -> -- Hash part 1/4 | ||
{-# UNPACK #-} !Word64 -> -- Hash part 2/4 | ||
{-# UNPACK #-} !Word64 -> -- Hash part 3/4 | ||
{-# UNPACK #-} !Word64 -> -- Hash part 4/4 | ||
{-# UNPACK #-} !Word64 -> -- Index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is clearly 6 words, so it's a win.
@@ -431,7 +440,10 @@ deriving newtype instance CC.Crypto crypto => FromCBOR (TxId crypto) | |||
deriving newtype instance CC.Crypto crypto => NFData (TxId crypto) | |||
|
|||
instance HeapWords (TxIn crypto) where | |||
heapWords (TxInCompact txid ix) = 3 + HW.heapWordsUnpacked txid + HW.heapWordsUnpacked ix | |||
heapWords (TxInCompact32 a _ _ _ ix) = | |||
6 + (4 * HW.heapWordsUnpacked a) + HW.heapWordsUnpacked ix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure that heapWordsUnpacked (a :: Word64)
is zero? The answer here must be 6, so it must amount to 6 + 4 * 0 + 0. Can someone verify that the answer here does indeed come out to be simply 6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have
instance HeapWords Word64 where
heapWords _ = 2
and
heapWordsUnpacked :: HeapWords a => a -> Int
heapWordsUnpacked x = heapWords x - 2
case HS.viewHash32 (extractHash sh) of | ||
HS.ViewHashNot32 -> TxInCompactOther txid (fromIntegral index) | ||
HS.ViewHash32 a b c d -> TxInCompact32 a b c d (fromIntegral index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noice.
Co-authored-by: Jared Corduan <jared.corduan@iohk.io>
No description provided.