github.com/unicornultrafoundation/go-u2u@v1.0.0-rc1.0.20240205080301-e74a83d3fadc/native/block.go (about) 1 package native 2 3 import ( 4 "github.com/unicornultrafoundation/go-helios/hash" 5 "github.com/unicornultrafoundation/go-u2u/common" 6 "github.com/unicornultrafoundation/go-u2u/core/types" 7 ) 8 9 type Block struct { 10 Time Timestamp 11 Atropos hash.Event 12 Events hash.Events 13 Txs []common.Hash // non event txs (received via genesis or LLR) 14 InternalTxs []common.Hash // DEPRECATED in favor of using only Txs fields and method internal.IsInternal 15 SkippedTxs []uint32 // indexes of skipped txs, starting from first tx of first event, ending with last tx of last event 16 GasUsed uint64 17 Root hash.Hash 18 } 19 20 func (b *Block) EstimateSize() int { 21 return (len(b.Events)+len(b.InternalTxs)+len(b.Txs)+1+1)*32 + len(b.SkippedTxs)*4 + 8 + 8 22 } 23 24 func FilterSkippedTxs(txs types.Transactions, skippedTxs []uint32) types.Transactions { 25 if len(skippedTxs) == 0 { 26 // short circuit if nothing to skip 27 return txs 28 } 29 skipCount := 0 30 filteredTxs := make(types.Transactions, 0, len(txs)) 31 for i, tx := range txs { 32 if skipCount < len(skippedTxs) && skippedTxs[skipCount] == uint32(i) { 33 skipCount++ 34 } else { 35 filteredTxs = append(filteredTxs, tx) 36 } 37 } 38 39 return filteredTxs 40 }