Fetch the repository succeeded.
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
/*
Notice: This file has been modified for Hyperledger Fabric SDK Go usage.
Please review third_party pinning scripts and patches for more details.
*/
package platforms
import (
"archive/tar"
"fmt"
"gitee.com/bupt-zkjc/fabric-sdk-go/internal/github.com/hyperledger/fabric/core/chaincode/platforms/golang"
"gitee.com/bupt-zkjc/fabric-sdk-go/internal/github.com/hyperledger/fabric/core/chaincode/platforms/java"
"gitee.com/bupt-zkjc/fabric-sdk-go/internal/github.com/hyperledger/fabric/core/chaincode/platforms/node"
)
// SupportedPlatforms is the canonical list of platforms Fabric supports
var SupportedPlatforms = []Platform{
&java.Platform{},
&golang.Platform{},
&node.Platform{},
}
// Interface for validating the specification and writing the package for
// the given platform
type Platform interface {
Name() string
}
type PackageWriter interface {
Write(name string, payload []byte, tw *tar.Writer) error
}
type PackageWriterWrapper func(name string, payload []byte, tw *tar.Writer) error
func (pw PackageWriterWrapper) Write(name string, payload []byte, tw *tar.Writer) error {
return pw(name, payload, tw)
}
type Registry struct {
Platforms map[string]Platform
PackageWriter PackageWriter
}
func NewRegistry(platformTypes ...Platform) *Registry {
platforms := make(map[string]Platform)
for _, platform := range platformTypes {
if _, ok := platforms[platform.Name()]; ok {
panic(fmt.Sprintf("Multiple platforms of the same name specified: %s", platform.Name()))
}
platforms[platform.Name()] = platform
}
return &Registry{
Platforms: platforms,
PackageWriter: PackageWriterWrapper(writeBytesToPackage),
}
}
func writeBytesToPackage(name string, payload []byte, tw *tar.Writer) error {
err := tw.WriteHeader(&tar.Header{
Name: name,
Size: int64(len(payload)),
Mode: 0100644,
})
if err != nil {
return err
}
_, err = tw.Write(payload)
if err != nil {
return err
}
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。