github.com/unicornultrafoundation/go-u2u@v1.0.0-rc1.0.20240205080301-e74a83d3fadc/native/ibr/native_block_records.go (about) 1 package ibr 2 3 import ( 4 "github.com/unicornultrafoundation/go-helios/common/bigendian" 5 "github.com/unicornultrafoundation/go-helios/hash" 6 "github.com/unicornultrafoundation/go-helios/native/idx" 7 "github.com/unicornultrafoundation/go-u2u/core/types" 8 9 "github.com/unicornultrafoundation/go-u2u/native" 10 ) 11 12 type LlrBlockVote struct { 13 Atropos hash.Event 14 Root hash.Hash 15 TxHash hash.Hash 16 ReceiptsHash hash.Hash 17 Time native.Timestamp 18 GasUsed uint64 19 } 20 21 type LlrFullBlockRecord struct { 22 Atropos hash.Event 23 Root hash.Hash 24 Txs types.Transactions 25 Receipts []*types.ReceiptForStorage 26 Time native.Timestamp 27 GasUsed uint64 28 } 29 30 type LlrIdxFullBlockRecord struct { 31 LlrFullBlockRecord 32 Idx idx.Block 33 } 34 35 func (bv LlrBlockVote) Hash() hash.Hash { 36 return hash.Of(bv.Atropos.Bytes(), bv.Root.Bytes(), bv.TxHash.Bytes(), bv.ReceiptsHash.Bytes(), bv.Time.Bytes(), bigendian.Uint64ToBytes(bv.GasUsed)) 37 } 38 39 func (br LlrFullBlockRecord) Hash() hash.Hash { 40 return LlrBlockVote{ 41 Atropos: br.Atropos, 42 Root: br.Root, 43 TxHash: native.CalcTxHash(br.Txs), 44 ReceiptsHash: native.CalcReceiptsHash(br.Receipts), 45 Time: br.Time, 46 GasUsed: br.GasUsed, 47 }.Hash() 48 }