github.com/okex/exchain@v1.8.0/libs/tendermint/types/from.go (about) 1 package types 2 3 import ( 4 "github.com/okex/exchain/libs/tendermint/proto/version" 5 ) 6 7 func (e CM40EventDataNewBlock) From(block EventDataNewBlock) CM40EventDataNewBlock { 8 e.Block = &CM40Block{} 9 cm40Block := block.Block.To() 10 e.Block = &cm40Block 11 e.ResultEndBlock = block.ResultEndBlock 12 e.ResultBeginBlock = block.ResultBeginBlock 13 return e 14 } 15 16 func (b CM40Block) From(block Block) CM40Block { 17 b.Data = block.Data 18 b.Evidence = block.Evidence 19 cmt := block.LastCommit.To() 20 b.LastCommit = &cmt 21 b.IBCHeader = b.IBCHeader.From(block.Header) 22 return b 23 } 24 25 func (h IBCHeader) From(header Header) IBCHeader { 26 h.Version = version.Consensus{ 27 Block: uint64(header.Version.Block), 28 App: uint64(header.Version.App), 29 } 30 h.ChainID = header.ChainID 31 h.Height = header.Height 32 h.Time = header.Time 33 h.LastBlockID = h.LastBlockID.From(header.LastBlockID) 34 h.LastCommitHash = header.LastCommitHash 35 h.DataHash = header.DataHash 36 h.ValidatorsHash = header.ValidatorsHash 37 h.NextValidatorsHash = header.NextValidatorsHash 38 h.ConsensusHash = header.ConsensusHash 39 h.AppHash = header.AppHash 40 h.LastResultsHash = header.LastResultsHash 41 h.EvidenceHash = header.EvidenceHash 42 h.ProposerAddress = header.ProposerAddress 43 return h 44 } 45 46 func (p IBCPartSetHeader) From(header PartSetHeader) IBCPartSetHeader { 47 p.Total = uint32(header.Total) 48 p.Hash = header.Hash 49 return p 50 } 51 52 func (b IBCBlockID) From(bb BlockID) IBCBlockID { 53 b.PartSetHeader = b.PartSetHeader.From(bb.PartsHeader) 54 b.Hash = bb.Hash 55 return b 56 } 57 58 func (c IBCCommit) From(cc Commit) IBCCommit { 59 c.BlockID = c.BlockID.From(cc.BlockID) 60 c.Height = cc.Height 61 c.Round = int32(cc.Round) 62 c.Signatures = cc.Signatures 63 return c 64 }