主頁 > 區塊鏈 > 【Hyperledger Fabric入門】(一) 快速運行一個簡單的Fabric網路2

【Hyperledger Fabric入門】(一) 快速運行一個簡單的Fabric網路2

2021-02-13 13:11:27 區塊鏈

本文在Ubuntu18.04運行,fabric版本為2.3.0,本文篇幅較長,因此分為兩篇,快速運行一個簡單的Fabric網路1詳見:link

目錄

      • 3. Orderer節點的啟動
      • 4. Peer節點的啟動
      • 5. 創建通道
      • 6. Chaincode的部署和呼叫

3. Orderer節點的啟動

Orderer節點負責交易的打包和區塊的生成,Orderer節點的配置資訊通常放在環境變數或者組態檔中,本例中的配置資訊統一放在組態檔中,fabric原始碼提供了Orderer啟動所用到的組態檔的實體,將實力組態檔復制到Orderer的檔案夾下面稍加修改即可使用,
復制fabric-samples里面的模板組態檔orderer.yaml到Orderer檔案夾下面,
修改模板組態檔,修改后的組態檔中發生變化的內容如下:

# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

---
################################################################################
#
#   Orderer Configuration
#
#   - This controls the type and configuration of the orderer.
#
################################################################################
General:
    # Listen address: The IP on which to bind to listen.
    ListenAddress: 192.168.178.128

    # Listen port: The port on which to bind to listen.
    ListenPort: 7050

    # TLS: TLS settings for the GRPC server.
    TLS:
        # Require server-side TLS
        Enabled: false
        # PrivateKey governs the file location of the private key of the TLS certificate.
        PrivateKey: ../fabricconfig/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.key
        # Certificate governs the file location of the server TLS certificate.
        Certificate: ../fabricconfig/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
        # RootCAs contains a list of additional root certificates used for verifying certificates
        # of other orderer nodes during outbound connections.
        # It is not required to be set, but can be used to augment the set of TLS CA certificates
        # available from the MSPs of each channel’s configuration.
        RootCAs:
          - ../fabricconfig/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt
        # Require client certificates / mutual TLS for inbound connections.
    # LogLevel: debug
    # LogFormat: '%{color}%{time:2021-02-09 16:52:00.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}'
    BootstrapMethod: file
    #BootstrapProfile: TestOrgsOrdererGenesis
    BootstrapFile: /home/yulin/blockchain/fabric/Hyperledger/order/orderer.genesis.block

    # LocalMSPDir is where to find the private crypto material needed by the
    # orderer. It is set relative here as a default for dev environments but
    # should be changed to the real location in production.
    LocalMSPDir: ../fabricconfig/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp

    # LocalMSPID is the identity to register the local MSP material with the MSP
    # manager. IMPORTANT: The local MSP ID of an orderer needs to match the MSP
    # ID of one of the organizations defined in the orderer system channel's
    # /Channel/Orderer configuration. The sample organization defined in the
    # sample configuration provided has an MSP ID of "SampleOrg".
    LocalMSPID: OrdererMSP

    # Enable an HTTP service for Go "pprof" profiling as documented at:
    # https://golang.org/pkg/net/http/pprof
    Profile:
        Enabled: false
        Address: 0.0.0.0:6060

    # BCCSP configures the blockchain crypto service providers.
    BCCSP:
        # Default specifies the preferred blockchain crypto service provider
        # to use. If the preferred provider is not available, the software
        # based provider ("SW") will be used.
        # Valid providers are:
        #  - SW: a software based crypto provider
        #  - PKCS11: a CA hardware security module crypto provider.
        Default: SW

        # SW configures the software based blockchain crypto provider.
        SW:
            # TODO: The default Hash and Security level needs refactoring to be
            # fully configurable. Changing these defaults requires coordination
            # SHA2 is hardcoded in several places, not only BCCSP
            Hash: SHA2
            Security: 256
            # Location of key store. If this is unset, a location will be
            # chosen using: 'LocalMSPDir'/keystore
            FileKeyStore:
                KeyStore:

################################################################################
#
#   SECTION: File Ledger
#
#   - This section applies to the configuration of the file ledger.
#
################################################################################
FileLedger:

    # Location: The directory to store the blocks in.
    Location: /home/yulin/blockchain/fabric/Hyperledger/order/production/orderer

#RAMLedger:
    #HistorySize: 1000
################################################################################
#
#   Debug Configuration
#
#   - This controls the debugging options for the orderer
#
################################################################################
Debug:

    # BroadcastTraceDir when set will cause each request to the Broadcast service
    # for this orderer to be written to a file in this directory
    BroadcastTraceDir:

    # DeliverTraceDir when set will cause each request to the Deliver service
    # for this orderer to be written to a file in this directory
    DeliverTraceDir:

################################################################################
#
#   Metrics Configuration
#
#   - This configures metrics collection for the orderer
#
################################################################################
Metrics:
    # The metrics provider is one of statsd, prometheus, or disabled
    Provider: disabled

    # The statsd configuration
    Statsd:
      # network type: tcp or udp
      Network: udp

      # the statsd server address
      Address: 127.0.0.1:8125

      # The interval at which locally cached counters and gauges are pushed
      # to statsd; timings are pushed immediately
      WriteInterval: 30s

      # The prefix is prepended to all emitted statsd metrics
      Prefix:

要注意組態檔中的相關路徑的設定,
在組態檔orderer.yaml所在的目錄執行如下命令啟動orderer:

$ orderer start
2021-02-09 17:14:14.942 CST [localconfig] completeInitialization -> INFO 001 General.Authentication.TimeWindow unset, setting to 15m0s
2021-02-09 17:14:14.943 CST [localconfig] completeInitialization -> INFO 002 Kafka.Retry.ShortInterval unset, setting to 1m0s
2021-02-09 17:14:14.943 CST [localconfig] completeInitialization -> INFO 003 Kafka.Retry.ShortTotal unset, setting to 10m0s
2021-02-09 17:14:14.943 CST [localconfig] completeInitialization -> INFO 004 Kafka.Retry.LongInterval unset, setting to 10m0s
2021-02-09 17:14:14.943 CST [localconfig] completeInitialization -> INFO 005 Kafka.Retry.LongTotal unset, setting to 12h0m0s
2021-02-09 17:14:14.943 CST [localconfig] completeInitialization -> INFO 006 Kafka.Retry.NetworkTimeouts.DialTimeout unset, setting to 30s
2021-02-09 17:14:14.943 CST [localconfig] completeInitialization -> INFO 007 Kafka.Retry.NetworkTimeouts.ReadTimeout unset, setting to 30s
2021-02-09 17:14:14.943 CST [localconfig] completeInitialization -> INFO 008 Kafka.Retry.NetworkTimeouts.WriteTimeout unset, setting to 30s
2021-02-09 17:14:14.943 CST [localconfig] completeInitialization -> INFO 009 Kafka.Retry.Metadata.RetryBackoff unset, setting to 250ms
2021-02-09 17:14:14.943 CST [localconfig] completeInitialization -> INFO 00a Kafka.Retry.Metadata.RetryMax unset, setting to 3
2021-02-09 17:14:14.943 CST [localconfig] completeInitialization -> INFO 00b Kafka.Retry.Producer.RetryBackoff unset, setting to 100ms
2021-02-09 17:14:14.943 CST [localconfig] completeInitialization -> INFO 00c Kafka.Retry.Producer.RetryMax unset, setting to 3
2021-02-09 17:14:14.943 CST [localconfig] completeInitialization -> INFO 00d Kafka.Retry.Consumer.RetryBackoff unset, setting to 2s
2021-02-09 17:14:14.943 CST [localconfig] completeInitialization -> INFO 00e Kafka.Version unset, setting to 0.10.2.0
2021-02-09 17:14:14.943 CST [orderer.common.server] prettyPrintStruct -> INFO 00f Orderer config values:
	General.ListenAddress = "127.0.0.1"
	General.ListenPort = 7050
	General.TLS.Enabled = false
	General.TLS.PrivateKey = "/home/yulin/blockchain/fabric/Hyperledger/fabricconfig/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.key"
	General.TLS.Certificate = "/home/yulin/blockchain/fabric/Hyperledger/fabricconfig/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt"
	General.TLS.RootCAs = [/home/yulin/blockchain/fabric/Hyperledger/fabricconfig/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt]
	General.TLS.ClientAuthRequired = false
	General.TLS.ClientRootCAs = []
	General.TLS.TLSHandshakeTimeShift = 0s
	General.Cluster.ListenAddress = ""
	General.Cluster.ListenPort = 0
	General.Cluster.ServerCertificate = ""
	General.Cluster.ServerPrivateKey = ""
	General.Cluster.ClientCertificate = ""
	General.Cluster.ClientPrivateKey = ""
	General.Cluster.RootCAs = []
	General.Cluster.DialTimeout = 5s
	General.Cluster.RPCTimeout = 7s
	General.Cluster.ReplicationBufferSize = 20971520
	General.Cluster.ReplicationPullTimeout = 5s
	General.Cluster.ReplicationRetryTimeout = 5s
	General.Cluster.ReplicationBackgroundRefreshInterval = 5m0s
	General.Cluster.ReplicationMaxRetries = 12
	General.Cluster.SendBufferSize = 10
	General.Cluster.CertExpirationWarningThreshold = 168h0m0s
	General.Cluster.TLSHandshakeTimeShift = 0s
	General.Keepalive.ServerMinInterval = 0s
	General.Keepalive.ServerInterval = 0s
	General.Keepalive.ServerTimeout = 0s
	General.ConnectionTimeout = 0s
	General.GenesisMethod = ""
	General.GenesisFile = ""
	General.BootstrapMethod = "file"
	General.BootstrapFile = "/home/yulin/blockchain/fabric/Hyperledger/order/orderer.genesis.block"
	General.Profile.Enabled = false
	General.Profile.Address = "0.0.0.0:6060"
	General.LocalMSPDir = "/home/yulin/blockchain/fabric/Hyperledger/fabricconfig/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp"
	General.LocalMSPID = "OrdererMSP"
	General.BCCSP.Default = "SW"
	General.BCCSP.SW.Security = 256
	General.BCCSP.SW.Hash = "SHA2"
	General.BCCSP.SW.FileKeystore.KeyStorePath = ""
	General.Authentication.TimeWindow = 15m0s
	General.Authentication.NoExpirationChecks = false
	FileLedger.Location = "/home/yulin/blockchain/fabric/Hyperledger/order/production/orderer"
	FileLedger.Prefix = ""
	Kafka.Retry.ShortInterval = 1m0s
	Kafka.Retry.ShortTotal = 10m0s
	Kafka.Retry.LongInterval = 10m0s
	Kafka.Retry.LongTotal = 12h0m0s
	Kafka.Retry.NetworkTimeouts.DialTimeout = 30s
	Kafka.Retry.NetworkTimeouts.ReadTimeout = 30s
	Kafka.Retry.NetworkTimeouts.WriteTimeout = 30s
	Kafka.Retry.Metadata.RetryMax = 3
	Kafka.Retry.Metadata.RetryBackoff = 250ms
	Kafka.Retry.Producer.RetryMax = 3
	Kafka.Retry.Producer.RetryBackoff = 100ms
	Kafka.Retry.Consumer.RetryBackoff = 2s
	Kafka.Verbose = false
	Kafka.Version = 0.10.2.0
	Kafka.TLS.Enabled = false
	Kafka.TLS.PrivateKey = ""
	Kafka.TLS.Certificate = ""
	Kafka.TLS.RootCAs = []
	Kafka.TLS.ClientAuthRequired = false
	Kafka.TLS.ClientRootCAs = []
	Kafka.TLS.TLSHandshakeTimeShift = 0s
	Kafka.SASLPlain.Enabled = false
	Kafka.SASLPlain.User = ""
	Kafka.SASLPlain.Password = ""
	Kafka.Topic.ReplicationFactor = 0
	Debug.BroadcastTraceDir = ""
	Debug.DeliverTraceDir = ""
	Consensus = <nil>
	Operations.ListenAddress = ""
	Operations.TLS.Enabled = false
	Operations.TLS.PrivateKey = ""
	Operations.TLS.Certificate = ""
	Operations.TLS.RootCAs = []
	Operations.TLS.ClientAuthRequired = false
	Operations.TLS.ClientRootCAs = []
	Operations.TLS.TLSHandshakeTimeShift = 0s
	Metrics.Provider = "disabled"
	Metrics.Statsd.Network = "udp"
	Metrics.Statsd.Address = "127.0.0.1:8125"
	Metrics.Statsd.WriteInterval = 30s
	Metrics.Statsd.Prefix = ""
	ChannelParticipation.Enabled = false
	ChannelParticipation.MaxRequestBodySize = 0
	Admin.ListenAddress = ""
	Admin.TLS.Enabled = false
	Admin.TLS.PrivateKey = ""
	Admin.TLS.Certificate = ""
	Admin.TLS.RootCAs = []
	Admin.TLS.ClientAuthRequired = false
	Admin.TLS.ClientRootCAs = []
	Admin.TLS.TLSHandshakeTimeShift = 0s
2021-02-09 17:14:14.999 CST [blkstorage] NewProvider -> INFO 010 Creating new file ledger directory at /home/yulin/blockchain/fabric/Hyperledger/order/production/orderer/chains
2021-02-09 17:14:15.019 CST [orderer.common.server] Main -> INFO 011 Bootstrapping the system channel
2021-02-09 17:14:15.022 CST [blkstorage] newBlockfileMgr -> INFO 012 Getting block information from block storage
2021-02-09 17:14:15.041 CST [orderer.common.server] initializeBootstrapChannel -> INFO 013 Initialized the system channel 'mychannel' from bootstrap block
2021-02-09 17:14:15.045 CST [orderer.common.server] extractSystemChannel -> INFO 014 Found system channel config block, number: 0
2021-02-09 17:14:15.047 CST [orderer.common.server] selectClusterBootBlock -> INFO 015 Cluster boot block is bootstrap (genesis) block; Blocks Header.Number system-channel=0, bootstrap=0
2021-02-09 17:14:15.050 CST [orderer.common.server] Main -> INFO 016 Starting with system channel: mychannel, consensus type: solo
2021-02-09 17:14:15.050 CST [certmonitor] trackCertExpiration -> INFO 017 The enrollment certificate will expire on 2031-02-04 12:08:00 +0000 UTC
2021-02-09 17:14:15.058 CST [orderer.consensus.solo] HandleChain -> WARN 018 Use of the Solo orderer is deprecated and remains only for use in test environments but may be removed in the future.
2021-02-09 17:14:15.059 CST [orderer.commmon.multichannel] initSystemChannel -> INFO 019 Starting system channel 'mychannel' with genesis block hash f6355426e46d155a023ed5f077afe82f1b4d267b667df52e18409c753e209f91 and orderer type solo
2021-02-09 17:14:15.060 CST [orderer.common.server] Main -> INFO 01a Starting orderer:
 Version: 2.3.0
 Commit SHA: ec81f3e74
 Go version: go1.14.12
 OS/Arch: linux/amd64
2021-02-09 17:14:15.060 CST [orderer.common.server] Main -> INFO 01b Beginning to serve requests

4. Peer節點的啟動

Peer模塊是Fabric的核心節點,所有的交易資料經過Orderer排序打包之后由Peer模塊存盤在區塊鏈中,所有的Chaincode也是由Peer模塊打包并且激活的,Peer模塊的配置資訊同意由環境變數和組態檔組成,本例中采用組態檔的方式來配置peer節點的引數,先創建一個Peer檔案夾,將fabric-samples里面的模板組態檔core.yaml到Peer檔案夾下面,對其稍作修改即可使用,
修改后Peer模塊組態檔中變化的內容如下所示:

# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

###############################################################################
#
#    Peer section
#
###############################################################################
peer:

    # The peer id provides a name for this peer instance and is used when
    # naming docker resources.
    id: peer0.org1.emanple.com

    # The networkId allows for logical separation of networks and is used when
    # naming docker resources.
    networkId: dev

    # The Address at local network interface this Peer will listen on.
    # By default, it will listen on all network interfaces
    listenAddress: 0.0.0.0:7051

    # The endpoint this peer uses to listen for inbound chaincode connections.
    # If this is commented-out, the listen address is selected to be
    # the peer's address (see below) with port 7052
    chaincodeListenAddress: 0.0.0.0:7052

    # The endpoint the chaincode for this peer uses to connect to the peer.
    # If this is not specified, the chaincodeListenAddress address is selected.
    # And if chaincodeListenAddress is not specified, address is selected from
    # peer address (see below). If specified peer address is invalid then it
    # will fallback to the auto detected IP (local IP) regardless of the peer
    # addressAutoDetect value.
    # chaincodeAddress: 0.0.0.0:7052

    # When used as peer config, this represents the endpoint to other peers
    # in the same organization. For peers in other organization, see
    # gossip.externalEndpoint for more info.
    # When used as CLI config, this means the peer's endpoint to interact with
    address: peer0.org1.example.com:7051

    # Whether the Peer should programmatically determine its address
    # This case is useful for docker containers.
    # When set to true, will override peer address.
    addressAutoDetect: false

    # Gossip related configuration
    gossip:
        # Bootstrap set to initialize gossip with.
        # This is a list of other peers that this peer reaches out to at startup.
        # Important: The endpoints here have to be endpoints of peers in the same
        # organization, because the peer would refuse connecting to these endpoints
        # unless they are in the same organization as the peer.
        bootstrap: 127.0.0.1:7051

        # NOTE: orgLeader and useLeaderElection parameters are mutual exclusive.
        # Setting both to true would result in the termination of the peer
        # since this is undefined state. If the peers are configured with
        # useLeaderElection=false, make sure there is at least 1 peer in the
        # organization that its orgLeader is set to true.

        # Defines whenever peer will initialize dynamic algorithm for
        # "leader" selection, where leader is the peer to establish
        # connection with ordering service and use delivery protocol
        # to pull ledger blocks from ordering service.
        useLeaderElection: true
        # Statically defines peer to be an organization "leader",
        # where this means that current peer will maintain connection
        # with ordering service and disseminate block across peers in
        # its own organization. Multiple peers or all peers in an organization
        # may be configured as org leaders, so that they all pull
        # blocks directly from ordering service.
        orgLeader: false

        # Interval for membershipTracker polling
        membershipTrackerInterval: 5s

        # Overrides the endpoint that the peer publishes to peers
        # in its organization. For peers in foreign organizations
        # see 'externalEndpoint'
        endpoint:
        # Maximum count of blocks stored in memory
        maxBlockCountToStore: 100
        # Max time between consecutive message pushes(unit: millisecond)
        maxPropagationBurstLatency: 10ms
        # Max number of messages stored until a push is triggered to remote peers
        maxPropagationBurstSize: 10
        # Number of times a message is pushed to remote peers
        propagateIterations: 1
        # Number of peers selected to push messages to
        propagatePeerNum: 3
        # Determines frequency of pull phases(unit: second)
        # Must be greater than digestWaitTime + responseWaitTime
        pullInterval: 4s
        # Number of peers to pull from
        pullPeerNum: 3
        # Determines frequency of pulling state info messages from peers(unit: second)
        requestStateInfoInterval: 4s
        # Determines frequency of pushing state info messages to peers(unit: second)
        publishStateInfoInterval: 4s
        # Maximum time a stateInfo message is kept until expired
        stateInfoRetentionInterval:
        # Time from startup certificates are included in Alive messages(unit: second)
        publishCertPeriod: 10s
        # Should we skip verifying block messages or not (currently not in use)
        skipBlockVerification: false
        # Dial timeout(unit: second)
        dialTimeout: 3s
        # Connection timeout(unit: second)
        connTimeout: 2s
        # Buffer size of received messages
        recvBuffSize: 20
        # Buffer size of sending messages
        sendBuffSize: 200
        # Time to wait before pull engine processes incoming digests (unit: second)
        # Should be slightly smaller than requestWaitTime
        digestWaitTime: 1s
        # Time to wait before pull engine removes incoming nonce (unit: milliseconds)
        # Should be slightly bigger than digestWaitTime
        requestWaitTime: 1500ms
        # Time to wait before pull engine ends pull (unit: second)
        responseWaitTime: 2s
        # Alive check interval(unit: second)
        aliveTimeInterval: 5s
        # Alive expiration timeout(unit: second)
        aliveExpirationTimeout: 25s
        # Reconnect interval(unit: second)
        reconnectInterval: 25s
        # Max number of attempts to connect to a peer
        maxConnectionAttempts: 120
        # Message expiration factor for alive messages
        msgExpirationFactor: 20
        # This is an endpoint that is published to peers outside of the organization.
        # If this isn't set, the peer will not be known to other organizations.
        externalEndpoint: peer0.org1.example.com:7051
        # Leader election service configuration
        election:
            # Longest time peer waits for stable membership during leader election startup (unit: second)
            startupGracePeriod: 15s
            # Interval gossip membership samples to check its stability (unit: second)
            membershipSampleInterval: 1s
            # Time passes since last declaration message before peer decides to perform leader election (unit: second)
            leaderAliveThreshold: 10s
            # Time between peer sends propose message and declares itself as a leader (sends declaration message) (unit: second)
            leaderElectionDuration: 5s

        pvtData:
            pushAckTimeout: 3s
            maxPeerCount: 3

        # Gossip state transfer related configuration
        state:
            # indicates whenever state transfer is enabled or not
            # default value is true, i.e. state transfer is active
            # and takes care to sync up missing blocks allowing
            # lagging peer to catch up to speed with rest network
            enabled: false
            # checkInterval interval to check whether peer is lagging behind enough to
            # request blocks via state transfer from another peer.
            checkInterval: 10s
            # responseTimeout amount of time to wait for state transfer response from
            # other peers
            responseTimeout: 3s
            # batchSize the number of blocks to request via state transfer from another peer
            batchSize: 10
            # blockBufferSize reflects the size of the re-ordering buffer
            # which captures blocks and takes care to deliver them in order
            # down to the ledger layer. The actual buffer size is bounded between
            # 0 and 2*blockBufferSize, each channel maintains its own buffer
            blockBufferSize: 20
            # maxRetries maximum number of re-tries to ask
            # for single state transfer request
            maxRetries: 3

    # TLS Settings
    tls:
        # Require server-side TLS
        enabled:  false
        # Require client certificates / mutual TLS for inbound connections.
        # Note that clients that are not configured to use a certificate will
        # fail to connect to the peer.
        clientAuthRequired: false
        # X.509 certificate used for TLS server
        cert:
            file: ../fabricconfig/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
        # Private key used for TLS server
        key:
            file: ../fabricconfig/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
        # rootcert.file represents the trusted root certificate chain used for verifying certificates
        # of other nodes during outbound connections.
        # It is not required to be set, but can be used to augment the set of TLS CA certificates
        # available from the MSPs of each channel’s configuration.
        rootcert:
            file: ../fabricconfig/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
        # If mutual TLS is enabled, clientRootCAs.files contains a list of additional root certificates
        # used for verifying certificates of client connections.
        # It augments the set of TLS CA certificates available from the MSPs of each channel’s configuration.
        # Minimally, set your organization's TLS CA root certificate so that the peer can receive join channel requests.

    fileSystemPath: /home/yulin/blockchain/fabric/Hyperledger/peer/production

    # BCCSP (Blockchain crypto provider): Select which crypto implementation or
    # library to use
    BCCSP:
        Default: SW
        # Settings for the SW crypto provider (i.e. when DEFAULT: SW)
        SW:
            # TODO: The default Hash and Security level needs refactoring to be
            # fully configurable. Changing these defaults requires coordination
            # SHA2 is hardcoded in several places, not only BCCSP
            Hash: SHA2
            Security: 256
            # Location of Key Store
            FileKeyStore:
                # If "", defaults to 'mspConfigPath'/keystore
                KeyStore:

    # Path on the file system where peer will find MSP local configurations
    mspConfigPath: ../fabricconfig/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp

    # Identifier of the local MSP
    # ----!!!!IMPORTANT!!!-!!!IMPORTANT!!!-!!!IMPORTANT!!!!----
    # Deployers need to change the value of the localMspId string.
    # In particular, the name of the local MSP ID of a peer needs
    # to match the name of one of the MSPs in each of the channel
    # that this peer is a member of. Otherwise this peer's messages
    # will not be identified as valid by other nodes.
    localMspId: Org1MSP

    profile:
        enabled:     false
        listenAddress: 0.0.0.0:6060

    # Handlers defines custom handlers that can filter and mutate
    # objects passing within the peer, such as:
    #   Auth filter - reject or forward proposals from clients
    #   Decorators  - append or mutate the chaincode input passed to the chaincode
    #   Endorsers   - Custom signing over proposal response payload and its mutation
    # Valid handler definition contains:
    #   - A name which is a factory method name defined in
    #     core/handlers/library/library.go for statically compiled handlers
    #   - library path to shared object binary for pluggable filters
    # Auth filters and decorators are chained and executed in the order that
    # they are defined. For example:
    # authFilters:
    #   -
    #     name: FilterOne
    #     library: /opt/lib/filter.so
    #   -
    #     name: FilterTwo
    # decorators:
    #   -
    #     name: DecoratorOne
    #   -
    #     name: DecoratorTwo
    #     library: /opt/lib/decorator.so
    # Endorsers are configured as a map that its keys are the endorsement system chaincodes that are being overridden.
    # Below is an example that overrides the default ESCC and uses an endorsement plugin that has the same functionality
    # as the default ESCC.
    # If the 'library' property is missing, the name is used as the constructor method in the builtin library similar
    # to auth filters and decorators.
    # endorsers:
    #   escc:
    #     name: DefaultESCC
    #     library: /etc/hyperledger/fabric/plugin/escc.so
    handlers:
        authFilters:
          -
            name: DefaultAuth
          -
            name: ExpirationCheck    # This filter checks identity x509 certificate expiration
        decorators:
          -
            name: DefaultDecorator

###############################################################################
#
#    VM section
#
###############################################################################
vm:

    # Endpoint of the vm management system.  For docker can be one of the following in general
    # unix:///var/run/docker.sock
    # http://localhost:2375
    # https://localhost:2376
    endpoint: unix:///var/run/docker.sock

    # settings for docker vms
    docker:
        tls:
            enabled: false
            ca:
                file: docker/ca.crt
            cert:
                file: docker/tls.crt
            key:
                file: docker/tls.key

        # Enables/disables the standard out/err from chaincode containers for
        # debugging purposes
        attachStdout: false

        # Parameters on creating docker container.
        # Container may be efficiently created using ipam & dns-server for cluster
        # NetworkMode - sets the networking mode for the container. Supported
        # standard values are: `host`(default),`bridge`,`ipvlan`,`none`.
        # Dns - a list of DNS servers for the container to use.
        # Note:  `Privileged` `Binds` `Links` and `PortBindings` properties of
        # Docker Host Config are not supported and will not be used if set.
        # LogConfig - sets the logging driver (Type) and related options
        # (Config) for Docker. For more info,
        # https://docs.docker.com/engine/admin/logging/overview/
        # Note: Set LogConfig using Environment Variables is not supported.
        hostConfig:
            NetworkMode: host
            Dns:
               # - 192.168.0.1
            LogConfig:
                Type: json-file
                Config:
                    max-size: "50m"
                    max-file: "5"
            Memory: 2147483648

###############################################################################
#
#    Chaincode section
#
###############################################################################
chaincode:

    # The id is used by the Chaincode stub to register the executing Chaincode
    # ID with the Peer and is generally supplied through ENV variables
    # the `path` form of ID is provided when installing the chaincode.
    # The `name` is used for all other requests and can be any string.
    id:
        path:
        name:

    # Generic builder environment, suitable for most chaincode types
    builder: $(DOCKER_NS)/fabric-ccenv:$(TWO_DIGIT_VERSION)

    # Enables/disables force pulling of the base docker images (listed below)
    # during user chaincode instantiation.
    # Useful when using moving image tags (such as :latest)
    pull: false

    golang:
        # golang will never need more than baseos
        runtime: $(DOCKER_NS)/fabric-baseos:$(TWO_DIGIT_VERSION)

        # whether or not golang chaincode should be linked dynamically
        dynamicLink: false

    java:
        # This is an image based on java:openjdk-8 with addition compiler
        # tools added for java shim layer packaging.
        # This image is packed with shim layer libraries that are necessary
        # for Java chaincode runtime.
        runtime: $(DOCKER_NS)/fabric-javaenv:$(TWO_DIGIT_VERSION)

    node:
        # This is an image based on node:$(NODE_VER)-alpine
        runtime: $(DOCKER_NS)/fabric-nodeenv:$(TWO_DIGIT_VERSION)

    # List of directories to treat as external builders and launchers for
    # chaincode. The external builder detection processing will iterate over the
    # builders in the order specified below.
    externalBuilders: []
        # - path: /path/to/directory
        #   name: descriptive-builder-name
        #   propagateEnvironment:
        #      - ENVVAR_NAME_TO_PROPAGATE_FROM_PEER
        #      - GOPROXY

    # The maximum duration to wait for the chaincode build and install process
    # to complete.
    installTimeout: 300s

    # Timeout duration for starting up a container and waiting for Register
    # to come through.
    startuptimeout: 300s

    # Timeout duration for Invoke and Init calls to prevent runaway.
    # This timeout is used by all chaincodes in all the channels, including
    # system chaincodes.
    # Note that during Invoke, if the image is not available (e.g. being
    # cleaned up when in development environment), the peer will automatically
    # build the image, which might take more time. In production environment,
    # the chaincode image is unlikely to be deleted, so the timeout could be
    # reduced accordingly.
    executetimeout: 30s

    # There are 2 modes: "dev" and "net".
    # In dev mode, user runs the chaincode after starting peer from
    # command line on local machine.
    # In net mode, peer will run chaincode in a docker container.
    mode: dev

    # keepalive in seconds. In situations where the communication goes through a
    # proxy that does not support keep-alive, this parameter will maintain connection
    # between peer and chaincode.
    # A value <= 0 turns keepalive off
    keepalive: 0

    # enabled system chaincodes
    system:
        _lifecycle: enable
        cscc: enable
        lscc: enable
        qscc: enable

    # Logging section for the chaincode container
    logging:
      # Default level for all loggers within the chaincode container
      level:  info
      # Override default level for the 'shim' logger
      shim:   warning
      # Format for the chaincode container logs
      format: '%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}'

###############################################################################
#
#    Ledger section - ledger configuration encompasses both the blockchain
#    and the state
#
###############################################################################
ledger:

  blockchain:

  state:
    # stateDatabase - options are "goleveldb", "CouchDB"
    # goleveldb - default state database stored in goleveldb.
    # CouchDB - store state database in CouchDB
    stateDatabase: goleveldb
    # Limit on the number of records to return per query
    totalQueryLimit: 100000
    couchDBConfig:
       # It is recommended to run CouchDB on the same server as the peer, and
       # not map the CouchDB container port to a server port in docker-compose.
       # Otherwise proper security must be provided on the connection between
       # CouchDB client (on the peer) and server.
       couchDBAddress: 127.0.0.1:5984
       # This username must have read and write authority on CouchDB
       username:
       # The password is recommended to pass as an environment variable
       # during start up (eg CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD).
       # If it is stored here, the file must be access control protected
       # to prevent unintended users from discovering the password.
       password:
       # Number of retries for CouchDB errors
       maxRetries: 3
       # Number of retries for CouchDB errors during peer startup.
       # The delay between retries doubles for each attempt.
       # Default of 10 retries results in 11 attempts over 2 minutes.
       maxRetriesOnStartup: 10
       # CouchDB request timeout (unit: duration, e.g. 20s)
       requestTimeout: 35s
       # Limit on the number of records per each CouchDB query
       # Note that chaincode queries are only bound by totalQueryLimit.
       # Internally the chaincode may execute multiple CouchDB queries,
       # each of size internalQueryLimit.
       internalQueryLimit: 1000
       # Limit on the number of records per CouchDB bulk update batch
       maxBatchUpdateSize: 1000
       # Warm indexes after every N blocks.
       # This option warms any indexes that have been
       # deployed to CouchDB after every N blocks.
       # A value of 1 will warm indexes after every block commit,
       # to ensure fast selector queries.
       # Increasing the value may improve write efficiency of peer and CouchDB,
       # but may degrade query response time.
       warmIndexesAfterNBlocks: 1
       # Create the _global_changes system database
       # This is optional.  Creating the global changes database will require
       # additional system resources to track changes and maintain the database
       createGlobalChangesDB: false
       # CacheSize denotes the maximum mega bytes (MB) to be allocated for the in-memory state
       # cache. Note that CacheSize needs to be a multiple of 32 MB. If it is not a multiple
       # of 32 MB, the peer would round the size to the next multiple of 32 MB.
       # To disable the cache, 0 MB needs to be assigned to the cacheSize.
       cacheSize: 64

  history:
    # enableHistoryDatabase - options are true or false
    # Indicates if the history of key updates should be stored.
    # All history 'index' will be stored in goleveldb, regardless if using
    # CouchDB or alternate database for the state.
    enableHistoryDatabase: true

###############################################################################
#
#    Metrics section
#
###############################################################################
metrics:
    # metrics provider is one of statsd, prometheus, or disabled
    provider: disabled

    # statsd configuration
    statsd:
        # network type: tcp or udp
        network: udp

        # statsd server address
        address: 127.0.0.1:8125

        # the interval at which locally cached counters and gauges are pushed
        # to statsd; timings are pushed immediately
        writeInterval: 10s

        # prefix is prepended to all emitted statsd metrics
        prefix:

在組態檔core.yaml所在檔案夾中執行以下命令啟動peer節點:

$ export set FABRIC_CFG_PATH=/~/blockchain/fabric/Hyperledger/peer
$ peer node start >> log_peer.log 2>&1 &

在log_peer.log檔案中

2021-02-09 17:56:42.049 CST [nodeCmd] serve -> INFO 001 Starting peer:
 Version: 2.3.0
 Commit SHA: ec81f3e74
 Go version: go1.14.12
 OS/Arch: linux/amd64
 Chaincode:
  Base Docker Label: org.hyperledger.fabric
  Docker Namespace: hyperledger
2021-02-09 17:56:42.050 CST [peer] getLocalAddress -> INFO 002 Auto-detected peer address: 172.17.0.1:7051
2021-02-09 17:56:42.051 CST [peer] getLocalAddress -> INFO 003 Returning peer0.org1.example.com:7051
2021-02-09 17:56:42.051 CST [common.deliverevents] load -> WARN 004 `peer.authentication.timewindow` not set; defaulting to 15m0s
2021-02-09 17:56:42.331 CST [certmonitor] trackCertExpiration -> INFO 005 The enrollment certificate will expire on 2031-02-04 12:08:00 +0000 UTC
2021-02-09 17:56:42.337 CST [gossip.privdata] loadPrivDataConfig -> WARN 006 Configuration key peer.gossip.pvtData.reconcileSleepInterval isn't set, defaulting to 1m0s
2021-02-09 17:56:42.340 CST [gossip.privdata] loadPrivDataConfig -> WARN 007 Configuration key peer.gossip.pvtData.reconcileBatchSize isn't set, defaulting to 10
2021-02-09 17:56:42.341 CST [ledgermgmt] NewLedgerMgr -> INFO 008 Initializing LedgerMgr
2021-02-09 17:56:42.514 CST [leveldbhelper] openDBAndCheckFormat -> INFO 009 DB is empty Setting db format as 2.0
2021-02-09 17:56:42.522 CST [blkstorage] NewProvider -> INFO 00a Creating new file ledger directory at /home/yulin/blockchain/fabric/Hyperledger/peer/production/ledgersData/chains/chains
2021-02-09 17:56:42.590 CST [leveldbhelper] openDBAndCheckFormat -> INFO 00b DB is empty Setting db format as 2.0
2021-02-09 17:56:42.774 CST [leveldbhelper] openDBAndCheckFormat -> INFO 00c DB is empty Setting db format as 2.0
2021-02-09 17:56:42.786 CST [ledgermgmt] NewLedgerMgr -> INFO 00d Initialized LedgerMgr
2021-02-09 17:56:42.790 CST [gossip.service] loadGossipConfig -> WARN 00e Configuration key peer.gossip.pvtData.transientstoreMaxBlockRetention isn't set, defaulting to 1000
2021-02-09 17:56:42.799 CST [gossip.service] New -> INFO 00f Initialize gossip with endpoint peer0.org1.example.com:7051
2021-02-09 17:56:42.802 CST [gossip.gossip] New -> INFO 010 Creating gossip service with self membership of Endpoint: peer0.org1.example.com:7051, InternalEndpoint: peer0.org1.example.com:7051, PKI-ID: 848f9e371f1d4cd7521c1e3517cc8eec6ddc8f09602abc2ed9a630c4622d9ab6, Metadata: 
2021-02-09 17:56:42.803 CST [lifecycle] InitializeLocalChaincodes -> INFO 011 Initialized lifecycle cache with 0 already installed chaincodes
2021-02-09 17:56:42.807 CST [nodeCmd] computeChaincodeEndpoint -> INFO 012 Entering computeChaincodeEndpoint with peerHostname: peer0.org1.example.com
2021-02-09 17:56:42.807 CST [nodeCmd] computeChaincodeEndpoint -> INFO 013 Exit with ccEndpoint: peer0.org1.example.com:7052
2021-02-09 17:56:42.808 CST [sccapi] DeploySysCC -> INFO 014 deploying system chaincode 'lscc'
2021-02-09 17:56:42.813 CST [gossip.gossip] start -> INFO 015 Gossip instance peer0.org1.example.com:7051 started
2021-02-09 17:56:42.830 CST [sccapi] DeploySysCC -> INFO 016 deploying system chaincode 'cscc'
2021-02-09 17:56:42.830 CST [sccapi] DeploySysCC -> INFO 017 deploying system chaincode 'qscc'
2021-02-09 17:56:42.830 CST [sccapi] DeploySysCC -> INFO 018 deploying system chaincode '_lifecycle'
2021-02-09 17:56:42.830 CST [nodeCmd] serve -> INFO 019 Deployed system chaincodes
2021-02-09 17:56:42.830 CST [nodeCmd] serve -> INFO 01a Starting peer with ID=[peer0.org1.emanple.com], network ID=[dev], address=[peer0.org1.example.com:7051]
2021-02-09 17:56:42.830 CST [nodeCmd] serve -> INFO 01b Started peer with ID=[peer0.org1.emanple.com], network ID=[dev], address=[peer0.org1.example.com:7051]
2021-02-09 17:56:42.830 CST [kvledger] LoadPreResetHeight -> INFO 01c Loading prereset height from path [/home/yulin/blockchain/fabric/Hyperledger/peer/production/ledgersData/chains]
2021-02-09 17:56:42.830 CST [blkstorage] preResetHtFiles -> INFO 01d No active channels passed

5. 創建通道

啟動完orderer和peer節點之后,現在可以創建通道了,本文均在peer檔案夾下進行,創建通道的程序一共分為三個步驟:
第一步:創建通道,

$ export set CORE_PEER_LOCALMSPID="Org1MSP"
$ export set CORE_PEER_MSPCONFIGPATH=/home/yulin/blockchain/fabric/Hyperledger/fabricconfig/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
$ peer channel create -t 50s -o orderer.example.com:7050 -c mychannel -f ../order/mychannel.tx
2021-02-10 19:30:52.830 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-02-10 19:30:53.103 CST [cli.common] readBlock -> INFO 002 Received block: 0

遇到了錯誤:
2021-02-10 18:34:12.743 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Error: got unexpected status: FORBIDDEN – config update for existing channel did not pass initial checks: implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the ‘Writers’ sub-policies to be satisfied: permission denied

解決辦法:
原因就是創建創世塊檔案時channelID與創建通道檔案channelID相同,故只需要在生成通道檔案的時候修改,停止并洗掉容器,把容器掛載的卷也洗掉否則仍然存在錯誤,洗掉通過命令configtxgen 生成的 *.tx 檔案,再通過命令configtxgen重新生成,

創建通道完成之后,會在執行命令額當前目錄生成名為“mychannel.block”的通道初始塊,
第二步:讓已經運行的Peer模塊加入通道,

$ export set CORE_PEER_LOCALMSPID="Org1MSP"
$ export set CORE_PEER_ADDRESS=peer0.org1.example.com:7051
$ export set CORE_PEER_MSPCONFIGPATH=/home/yulin/blockchain/fabric/Hyperledger/fabricconfig/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
$ peer channel join -b mychannel.block
2021-02-10 19:43:22.714 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-02-10 19:43:22.926 CST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel

第三步:更新錨節點,

$ peer channel update -o orderer.example.com:7050 -c mychannel -f ../order/Org1MSPanchors.tx
2021-02-10 19:46:05.061 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-02-10 19:46:05.150 CST [channelCmd] update -> INFO 002 Successfully submitted channel update

peer節點端:
在這里插入圖片描述

6. Chaincode的部署和呼叫

現在部署一個chaincode來測驗Peer節點和Orderer節點的部署是否正確,這里采用fabric原始碼自帶的例子來作為測驗chaincode,
chaincode相關的測驗一共有四個步驟:
第一步:部署chaincode代碼,

$ peer chaincode install -n r_test_cc6 -v 2.3.0 -p /home/yulin/go/src/github.com/hyperledger/fabric-samples/chaincode/fabcar/go

在這里插入圖片描述
第二步:實體化chaincode代碼,

$ peer chaincode instantiate -o om:7050 -C mychannel -n r_test_cc6 -v 2.3.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.menber','Org2MSP.menber')"

第三步:通過chaincode寫入資料,

$ peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n r_test_cc6 -v 2.3.0 -c '{"Args":["invoke","a","b","1"]}'

第四步:通過chaincode查詢資料,

peer chaincode query -C mychannel -n r_test_cc6 -v 2.3.0 -c '{"Args":["query","a"]}'

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/259295.html

標籤:區塊鏈

上一篇:【位元幣】為什么位元幣再次增長,突破46000美金。

下一篇:ubuntu16.04下brpc的安裝

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • JAVA使用 web3j 進行token轉賬

    最近新學習了下區塊鏈這方面的知識,所學不多,給大家分享下。 # 1. 關于web3j web3j是一個高度模塊化,反應性,型別安全的Java和Android庫,用于與智能合約配合并與以太坊網路上的客戶端(節點)集成。 # 2. 準備作業 jdk版本1.8 引入maven <dependency> < ......

    uj5u.com 2020-09-10 03:03:06 more
  • 以太坊智能合約開發框架Truffle

    前言 部署智能合約有多種方式,命令列的瀏覽器的渠道都有,但往往跟我們程式員的風格不太相符,因為我們習慣了在IDE里寫了代碼然后打包運行看效果。 雖然現在IDE中已經存在了Solidity插件,可以撰寫智能合約,但是部署智能合約卻要另走他路,沒辦法進行一個快捷的部署與測驗。 如果團隊管理的區塊節點多、 ......

    uj5u.com 2020-09-10 03:03:12 more
  • 谷歌二次驗證碼成為區塊鏈專用安全碼,你怎么看?

    前言 谷歌身份驗證器,前些年大家都比較陌生,但隨著國內互聯網安全的加強,它越來越多地出現在大家的視野中。 比較廣泛接觸的人群是國際3A游戲愛好者,游戲盜號現象嚴重+國外賬號安全應用廣泛,這類游戲一般都會要求用戶系結名為“兩步驗證”、“雙重驗證”等,平臺一般都推薦用谷歌身份驗證器。 后來區塊鏈業務風靡 ......

    uj5u.com 2020-09-10 03:03:17 more
  • 密碼學DAY1

    目錄 ##1.1 密碼學基本概念 密碼在我們的生活中有著重要的作用,那么密碼究竟來自何方,為何會產生呢? 密碼學是網路安全、資訊安全、區塊鏈等產品的基礎,常見的非對稱加密、對稱加密、散列函式等,都屬于密碼學范疇。 密碼學有數千年的歷史,從最開始的替換法到如今的非對稱加密演算法,經歷了古典密碼學,近代密 ......

    uj5u.com 2020-09-10 03:03:50 more
  • 密碼學DAY1_02

    目錄 ##1.1 ASCII編碼 ASCII(American Standard Code for Information Interchange,美國資訊交換標準代碼)是基于拉丁字母的一套電腦編碼系統,主要用于顯示現代英語和其他西歐語言。它是現今最通用的單位元組編碼系統,并等同于國際標準ISO/IE ......

    uj5u.com 2020-09-10 03:04:50 more
  • 密碼學DAY2

    ##1.1 加密模式 加密模式:https://docs.oracle.com/javase/8/docs/api/javax/crypto/Cipher.html ECB ECB : Electronic codebook, 電子密碼本. 需要加密的訊息按照塊密碼的塊大小被分為數個塊,并對每個塊進 ......

    uj5u.com 2020-09-10 03:05:42 more
  • NTP時鐘服務器的特點(京準電子)

    NTP時鐘服務器的特點(京準電子) NTP時鐘服務器的特點(京準電子) 京準電子官V——ahjzsz 首先對時間同步進行了背景介紹,然后討論了不同的時間同步網路技術,最后指出了建立全球或區域時間同步網存在的問題。 一、概 述 在通信領域,“同步”概念是指頻率的同步,即網路各個節點的時鐘頻率和相位同步 ......

    uj5u.com 2020-09-10 03:05:47 more
  • 標準化考場時鐘同步系統推進智能化校園建設

    標準化考場時鐘同步系統推進智能化校園建設 標準化考場時鐘同步系統推進智能化校園建設 安徽京準電子科技官微——ahjzsz 一、背景概述隨著教育事業的快速發展,學校建設如雨后春筍,隨之而來的學校教育、管理、安全方面的問題成了學校管理人員面臨的最大的挑戰,這些問題同時也是學生家長所擔心的。為了讓學生有更 ......

    uj5u.com 2020-09-10 03:05:51 more
  • 位元幣入門

    引言 位元幣基本結構 位元幣基礎知識 1)哈希演算法 2)非對稱加密技術 3)數字簽名 4)MerkleTree 5)哪有位元幣,有的是UTXO 6)位元幣挖礦與共識 7)區塊驗證(共識) 總結 引言 上一篇我們已經知道了什么是區塊鏈,此篇說一下區塊鏈的第一個應用——位元幣。其實先有位元幣,后有的區塊 ......

    uj5u.com 2020-09-10 03:06:15 more
  • 北斗對時服務器(北斗對時設備)電力系統應用

    北斗對時服務器(北斗對時設備)電力系統應用 北斗對時服務器(北斗對時設備)電力系統應用 京準電子科技官微(ahjzsz) 中國北斗衛星導航系統(英文名稱:BeiDou Navigation Satellite System,簡稱BDS),因為是目前世界范圍內唯一可以大面積提供免費定位服務的系統,所以 ......

    uj5u.com 2020-09-10 03:06:20 more
最新发布
  • web3 產品介紹:metamask 錢包 使用最多的瀏覽器插件錢包

    Metamask錢包是一種基于區塊鏈技術的數字貨幣錢包,它允許用戶在安全、便捷的環境下管理自己的加密資產。Metamask錢包是以太坊生態系統中最流行的錢包之一,它具有易于使用、安全性高和功能強大等優點。 本文將詳細介紹Metamask錢包的功能和使用方法。 一、 Metamask錢包的功能 數字資 ......

    uj5u.com 2023-04-20 08:46:47 more
  • Hyperledger Fabric 使用 CouchDB 和復雜智能合約開發

    在上個實驗中,我們已經實作了簡單智能合約實作及客戶端開發,但該實驗中智能合約只有基礎的增刪改查功能,且其中的資料管理功能與傳統 MySQL 比相差甚遠。本文將在前面實驗的基礎上,將 Hyperledger Fabric 的默認資料庫支持 LevelDB 改為 CouchDB 模式,以實作更復雜的資料... ......

    uj5u.com 2023-04-16 07:28:31 more
  • .NET Core 波場鏈離線簽名、廣播交易(發送 TRX和USDT)筆記

    Get Started NuGet You can run the following command to install the Tron.Wallet.Net in your project. PM> Install-Package Tron.Wallet.Net 配置 public reco ......

    uj5u.com 2023-04-14 08:08:00 more
  • DKP 黑客分析——不正確的代幣對比率計算

    概述: 2023 年 2 月 8 日,針對 DKP 協議的閃電貸攻擊導致該協議的用戶損失了 8 萬美元,因為 execute() 函式取決于 USDT-DKP 對中兩種代幣的余額比率。 智能合約黑客概述: 攻擊者的交易:0x0c850f,0x2d31 攻擊者地址:0xF38 利用合同:0xf34ad ......

    uj5u.com 2023-04-07 07:46:09 more
  • Defi開發簡介

    Defi開發簡介 介紹 Defi是去中心化金融的縮寫, 是一項旨在利用區塊鏈技術和智能合約創建更加開放,可訪問和透明的金融體系的運動. 這與傳統金融形成鮮明對比,傳統金融通常由少數大型銀行和金融機構控制 在Defi的世界里,用戶可以直接從他們的電腦或移動設備上訪問廣泛的金融服務,而不需要像銀行或者信 ......

    uj5u.com 2023-04-05 08:01:34 more
  • solidity簡單的ERC20代幣實作

    // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; import "hardhat/console.sol"; //ERC20 同質化代幣,每個代幣的本質或性質都是相同 //ETH 是原生代幣,它不是ERC20代幣, ......

    uj5u.com 2023-03-21 07:56:29 more
  • solidity 參考型別修飾符memory、calldata與storage 常量修飾符C

    在solidity語言中 參考型別修飾符(參考型別為存盤空間不固定的數值型別) memory、calldata與storage,它們只能修飾參考型別變數,比如字串、陣列、位元組等... memory 適用于方法傳參、返參或在方法體內使用,使用完就會清除掉,釋放記憶體 calldata 僅適用于方法傳參 ......

    uj5u.com 2023-03-08 07:57:54 more
  • solidity注解標簽

    在solidity語言中 注釋符為// 注解符為/* 內容*/ 或者 是 ///內容 注解中含有這幾個標簽給予我們使用 @title 一個應該描述合約/介面的標題 contract, library, interface @author 作者的名字 contract, library, interf ......

    uj5u.com 2023-03-08 07:57:49 more
  • 評價指標:相似度、GAS消耗

    【代碼注釋自動生成方法綜述】 這些評測指標主要來自機器翻譯和文本總結等研究領域,可以評估候選文本(即基于代碼注釋自動方法而生成)和參考文本(即基于手工方式而生成)的相似度. BLEU指標^[^?88^^?^]^:其全稱是bilingual evaluation understudy.該指標是最早用于 ......

    uj5u.com 2023-02-23 07:27:39 more
  • 基于NOSTR協議的“公有制”版本的Twitter,去中心化社交軟體Damus

    最近,一個幽靈,Web3的幽靈,在網路游蕩,它叫Damus,這玩意詮釋了什么叫做病毒式營銷,滑稽的是,一個Web3產品卻在Web2的產品鏈上瘋狂傳銷,各方大佬紛紛為其背書,到底發生了什么?Damus的葫蘆里,賣的是什么藥? 注冊和簡單實用 很少有什么產品在用戶注冊環節會有什么噱頭,但Damus確實出 ......

    uj5u.com 2023-02-05 06:48:39 more