1 Star 0 Fork 0

妥協/fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
marshalling.go 1.45 KB
一键复制 编辑 原始数据 按行查看 历史
Angelo De Caro 提交于 2018-09-24 15:44 . [FAB-12155] IssuerValidator Impl
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package transaction
import (
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/protos/common"
cb "github.com/hyperledger/fabric/protos/common"
"github.com/hyperledger/fabric/protos/token"
"github.com/hyperledger/fabric/protos/utils"
"github.com/hyperledger/fabric/token/identity"
"github.com/pkg/errors"
)
func UnmarshalTokenTransaction(raw []byte) (*cb.ChannelHeader, *token.TokenTransaction, identity.PublicInfo, error) {
// the payload...
payload := &common.Payload{}
err := proto.Unmarshal(raw, payload)
if err != nil {
return nil, nil, nil, errors.Wrap(err, "error unmarshaling Payload")
}
// the creator from the signature header
sh, err := utils.GetSignatureHeader(payload.Header.SignatureHeader)
if err != nil {
return nil, nil, nil, err
}
creatorInfo := &TxCreatorInfo{public: sh.Creator}
chdr, err := utils.UnmarshalChannelHeader(payload.Header.ChannelHeader)
if err != nil {
return nil, nil, nil, err
}
// validate the payload type
if common.HeaderType(chdr.Type) != common.HeaderType_TOKEN_TRANSACTION {
return nil, nil, nil, errors.Errorf("only token transactions are supported, provided type: %d", chdr.Type)
}
ttx := &token.TokenTransaction{}
err = proto.Unmarshal(payload.Data, ttx)
if err != nil {
return nil, nil, nil, errors.Errorf("failed getting token token transaction, %s", err)
}
return chdr, ttx, creatorInfo, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liurenhao/fabric.git
git@gitee.com:liurenhao/fabric.git
liurenhao
fabric
fabric
v1.4.4

搜索帮助