block_chain.go 656 字节
package dto

import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"

type BlockChain struct {
	UpChainId int64  `json:"upChainId"`
	PrimaryId string `json:"primaryId"`
	// 数据块hash
	BlockHash string `json:"blockHash"`
}

type BlockChains []*BlockChain

func (b *BlockChain) LoadDto(upChain *domain.UpChain) {
	b.PrimaryId = upChain.PrimaryId
	b.BlockHash = upChain.Hash
	b.UpChainId = upChain.UpChainId
}

func NewBlockChains(upChains []*domain.UpChain) BlockChains {
	var rsp = make([]*BlockChain, 0)
	for i := range upChains {
		item := new(BlockChain)
		item.LoadDto(upChains[i])
		rsp = append(rsp, item)
	}
	return rsp
}