Hyperledger Fabric v1.4(LTS) 系列(3.9):关键概念-Ledger

Key Concepts-Ledger

  • Introduction
  • Hyperledger Fabric Functionalities
  • Hyperledger Fabric Model
  • Blockchain network
  • Identity
  • Membership
  • Peers
  • Smart Contracts and Chaincode
  • Ledger
  • The Ordering Service
  • Private data
  • Use Cases

Ledger

Audience: Architects, Application and smart contract developers,administrators

A ledger is a key concept in Hyperledger Fabric; it stores important factual information about business objects; both the current value of the attributes of the objects, and the history of transactions that resulted in these current values.
受众:架构师,应用和智能合约开发人员,管理员

账本是Hyperledger Fabric中的一个关键概念;它存储有关业务对象的重要事实信息;对象属性的当前值,以及带来这些当前值的交易历史。

In this topic, we’re going to cover:

What is a Ledger?

A ledger contains the current state of a business as a journal of transactions. The earliest European and Chinese ledgers date from almost 1000 years ago, and the Sumerians had stone ledgers 4000 years ago – but let’s start with a more up-to-date example!
分类帐以交易日记账保存当前业务状态。欧洲和中国最早的分类账大约是1000年前的,而苏美尔人在4000年前就有了石板上的分类账–但是让我们从现代的例子开始。

You’re probably used to looking at your bank account. What’s most important to you is the available balance – it’s what you’re able to spend at the current moment in time. If you want to see how your balance was derived, then you can look through the transaction credits and debits that determined it. This is a real life example of a ledger – a state (your bank balance), and a set of ordered transactions (credits and debits) that determine it. Hyperledger Fabric is motivated by these same two concerns – to present the current value of a set of ledger states, and to capture the history of the transactions that determined these states.
你可能已经习惯于银行账户。对你来说最重要的是可用余额—它是你在当前能够花费的部分。如果您想了解余额是如何得出的,您可以查看决定余额的信用贷记和借记。这是一个真实的分类账例子—一个状态(您的银行余额)和一组确定它的有序交易(贷记和借记)。Hyperledger Fabric 受与之相同的两个因素的驱动—呈现一组分类帐状态的当前值,并捕获确定这些状态的事务的历史。

Ledgers, Facts and States

A ledger doesn’t literally store business objects – instead it stores facts about those objects. When we say “we store a business object in a ledger” what we really mean is that we’re recording the facts about the current state of an object, and the facts about the history of transactions that led to the current state. In an increasingly digital world, it can feel like we’re looking at an object, rather than facts about an object. In the case of a digital object, it’s likely that it lives in an external datastore; the facts we store in the ledger allow us to identify its location along with other key information about it.
分类账并不真正存储业务对象—而是存储关于这些对象的事实。当我们说“我们将业务对象存储在分类账中”时,我们真正记录的是对象当前状态的事实,以及导致当前状态的交易历史的事实。在一个日益数字化的世界里,人们会觉得我们在看一个物体,而不是一个物体的事实。对于数字化对象,它很可能位于外部数据存储中;我们存储在分类帐中的事实允许我们识别它的位置以及有关它的其他关键信息。

While the facts about the current state of a business object may change, the history of facts about it is immutable, it can be added to, but it cannot be retrospectively changed. We’re going to see how thinking of a blockchain as an immutable history of facts about business objects is a simple yet powerful way to understand it.
虽然有关业务对象当前状态的事实可能会更改,但有关它的事实的历史记录是不可变的,它可以被追加,但不能向回更改。我们将看到,将区块链视为有关业务对象事实的不可变历史,是理解它的一种简单而强大的方式。

Let’s now take a closer look at the Hyperledger Fabric ledger structure!
现在仔细看一下Hyperledger Fabric分类账的结构!

The Ledger

In Hyperledger Fabric, a ledger consists of two distinct, though related, parts – a world state and a blockchain. Each of these represents a set of facts about a set of business objects.
在超级账本结构中,账本由两个不同但相关的部分组成:全局状态和区块链。各自都代表一组关于一组业务对象的事实。

Firstly, there’s a world state – a database that holds a cache of the current values of a set of ledger states. The world state makes it easy for a program to directly access the current value of a state rather than having to calculate it by traversing the entire transaction log. Ledger states are, by default, expressed as key-value pairs, and we’ll see later how Hyperledger Fabric provides flexibility in this regard. The world state can change frequently, as states can be created, updated and deleted.
首先,有一个全局状态,保存一组分类帐状态当前值缓存的数据库。全局状态使得程序可以方便地直接访问状态的当前值,而不必通过遍历整个事务日志来计算它。默认情况下,分类帐状态表示为键值对,稍后我们将看到Hyperledger Fabirc如何在这方面提供灵活性。全局状态可以频繁更改,因为状态可以被创建、更新和删除。

Secondly, there’s a blockchain – a transaction log that records all the changes that have resulted in the current the world state. Transactions are collected inside blocks that are appended to the blockchain – enabling you to understand the history of changes that have resulted in the current world state. The blockchain data structure is very different to the world state because once written, it cannot be modified; it is immutable.
其次,区块链:一个记录所有导致当前全局状态变化的交易日志。交易被收集到块中,块附加到区块链上,使您能够了解带来当前全局状态的变化历史。区块链数据结构与全局状态非常不同,因为一旦写入,就无法修改;它是不可变的。

ledger.ledger
A Ledger L comprises blockchain B and world state W, where blockchain B determines world state W. We can also say that world state W is derived from blockchain B.
分类帐L由区块链B和全局状态W组成,其中区块链B决定全局状态W。我们也可以说世界状态W源自区块链B。

It’s helpful to think of there being one logical ledger in a Hyperledger Fabric network. In reality, the network maintains multiple copies of a ledger – which are kept consistent with every other copy through a process called consensus. The term Distributed Ledger Technology (DLT) is often associated with this kind of ledger – one that is logically singular, but has many consistent copies distributed throughout a network.
在一个Fabric网络中有一个逻辑账本是很有帮助的。实际上,网络维护了一个分类账的多个副本。通过称为共识的过程,这些副本与其他所有副本保持一致。术语分布式账本技术DLT)通常与这种账本相关—账本在逻辑上是单一的,但在整个网络中分布着许多一致的副本。

Let’s now examine the world state and blockchain data structures in more detail.
现在详细研究全局状态和区块链数据结构。

World State

The world state holds the current value of the attributes of a business object as a unique ledger state. That’s useful because programs usually require the current value of an object; it would be cumbersome to traverse the entire blockchain to calculate an object’s current value – you just get it directly from the world state.
全局状态将业务对象属性的当前值保存为唯一的分类帐状态。这很有用,因为程序通常需要一个对象的当前值;遍历整个区块链来计算一个对象的当前值会很麻烦——您只需直接从全局状态获取它。

ledger.worldstate

A ledger world state containing two states. The first state is: key=CAR1 and value=Audi. The second state has a more complex value: key=CAR2 and value={model:BMW, color=red, owner=Jane}. Both states are at version 0.
分类帐全局状态包含两个状态。第一种状态是:key=CAR1 and value=Audi。第二个状态有一个更复杂的值:key=CAR2 and value={model:BMW, color=red, owner=Jane}。两个状态都处于Version 0。

A ledger state records a set of facts about a particular business object. Our example shows ledger states for two cars, CAR1 and CAR2, each having a key and a value. An application program can invoke a smart contract which uses simple ledger APIs to get, put and delete states. Notice how a state value can be simple (Audi…) or compound (type:BMW…). The world state is often queried to retrieve objects with certain attributes, for example to find all red BMWs.

分类帐状态记录有关特定业务对象的一组事实。我们的示例显示了CAR1和CAR2两辆车的分类帐状态,每辆车都有一个键和值。应用可以调用智能合约以使用简单的分类账API来获取更新删除状态。注意状态值可以是简单的(奥迪…)或复合的(类型:宝马…)。通常查询全局状态来检索具有特定属性的对象,例如查找所有红色BMW。

The world state is implemented as a database. This makes a lot of sense because a database provides a rich set of operators for the efficient storage and retrieval of states. We’ll see later that Hyperledger Fabric can be configured to use different world state databases to address the needs of different types of state values and the access patterns required by applications, for example in complex queries.
全局状态是用数据库实现的。这很有意义,因为数据库提供了一组丰富的运算符以有效地存储和检索状态。稍后我们将看到,Hyperledger Fabric配置为使用不同的全局状态数据库来满足不同类型状态值及应用所需的访问模式,例如复杂查询。

Applications submit transactions which capture changes to the world state, and these transactions end up being committed to the ledger blockchain. Applications are insulated from the details of this consensus mechanism by the Hyperledger Fabric SDK; they merely invoke a smart contract, and are notified when the transaction has been included in the blockchain (whether valid or invalid). The key design point is that only transactions that are signed by the required set of endorsing organizations will result in an update to the world state. If a transaction is not signed by sufficient endorsers, it will not result in a change of world state. You can read more about how applications use smart contracts, and how to develop applications.

应用提交捕获全局状态变化的事务,这些事务最终被提交到分类账区块链。应用通过Hyperledger Fabric SDK中的共识 机制的细节进行隔离;它们只调用智能合约,并在交易被包含到区块链中(无论有效还是无效)时得到通知。关键的设计点是,只有由所需的一组背书组织签署的的交易才会导致对全局状态的更新。如果一项事务没有足够的背书人签署,就不会导致全局状态的变化。您可以阅读更多有关应用如何使用智能合约, 以及如何开发应用程序的信息。

You’ll also notice that a state has an version number, and in the diagram above, states CAR1 and CAR2 are at their starting versions, 0. The version number for internal use by Hyperledger Fabric, and is incremented every time the state changes. The version is checked whenever the state is updated to make sure the current states matches the version at the time of endorsement. This ensures that the world state is changing as expected; that there has not been a concurrent update.
您还将注意到一个状态有一个版本号,在上面的图表中,状态CAR1和CAR2开始于初始版本0。版本号是供Hyperledger Fabric内部使用,并在每次状态更改时递增的。每次更新状态时都会检查版本,以确保当前状态与背书时的版本匹配。这样可以确保全局状态如预期的那样发生变化而没有并发更新。

Finally, when a ledger is first created, the world state is empty. Because any transaction which represents a valid change to world state is recorded on the blockchain, it means that the world state can be re-generated from the blockchain at any time. This can be very convenient – for example, the world state is automatically generated when a peer is created. Moreover, if a peer fails abnormally, the world state can be regenerated on peer restart, before transactions are accepted.
最后,当分类帐首次创建时,全局状态为空。因为任何代表全局状态有效变化的交易都记录在区块链上,这意味着全局状态可以随时从区块链中重新生成。这非常方便—例如,当创建节点时,会自动生成全局状态。此外,如果一个节点出现异常故障,在接受事务之前,可以在节点重新启动时重新生成全局状态。

Blockchain

Let’s now turn our attention from the world state to the blockchain. Whereas the world state contains a set of facts relating to the current state of a set of business objects, the blockchain is an historical record of the facts about how these objects arrived at their current states. The blockchain has recorded every previous version of each ledger state and how it has been changed.
现在让我们把注意力从全局状态转移到区块链上。虽然全局状态包含与一组业务对象的当前状态相关的一组事实,但区块链是有关这些对象如何形成其当前状态的事实的历史记录。区块链记录了每一个分类账状态的每一个早期版本以及它是如何被改变的。

The blockchain is structured as sequential log of interlinked blocks, where each block contains a sequence of transactions, each transaction representing a query or update to the world state. The exact mechanism by which transactions are ordered is discussed elsewhere; what’s important is that block sequencing, as well as transaction sequencing within blocks, is established when blocks are first created by a Hyperledger Fabric component called the ordering service.
区块链被构造为相互连接的顺序日志,其中每个块包含一系列事务,每个事务展示对全局状态的查询或更新。这里讨论了事务排序的确切机制;重要的是,块排序以及块内的事务排序是在由名为排序服务的Hyperledger Fabric组件首次创建块时建立的。

Each block’s header includes a hash of the block’s transactions, as well a copy of the hash of the prior block’s header. In this way, all transactions on the ledger are sequenced and cryptographically linked together. This hashing and linking makes the ledger data very secure. Even if one node hosting the ledger was tampered with, it would not be able to convince all the other nodes that it has the ‘correct’ blockchain because the ledger is distributed throughout a network of independent nodes.
每个块的头包含块事务的哈希值,以及前一个块头的哈希值的副本。通过这种方式,分类账上的所有交易都按顺序排列并以加密方式链接在一起。这种散列和链接使得分类帐数据非常安全。即使一个托管分类账的节点被篡改,它也无法说服所有其他节点它拥有“正确”的区块链,因为分类账分布在一个由独立节点组成的网络中。

The blockchain is always implemented as a file, in contrast to the world state, which uses a database. This is a sensible design choice as the blockchain data structure is heavily biased towards a very small set of simple operations. Appending to the end of the blockchain is the primary operation, and query is currently a relatively infrequent operation.
区块链始终以一个文件实现,与使用数据库的全局状态不同。这是一个明智的设计选择,因为区块链数据结构偏向于一组轻量的简单操作。附加到区块链末尾是主要操作,而查询目前是一个相对较少的操作。

Let’s have a look at the structure of a blockchain in a little more detail.
让我们更详细地了解一下区块链的结构。

ledger.blockchain
A blockchain B containing blocks B0, B1, B2, B3. B0 is the first block in the blockchain, the genesis block.
包含区块B0, B1, B2, B3的区块链B。B0是区块链中的第一个区块,创世区块。

In the above diagram, we can see that block B2 has a block data D2 which contains all its transactions: T5, T6, T7.
在上图中,我们可以看到B2有一个块数据D2,它包含了该块的所有事务:T5、T6、T7。

Most importantly, B2 has a block header H2, which contains a cryptographic hash of all the transactions in D2 as well as with the equivalent hash from the previous block B1. In this way, blocks are inextricably and immutably linked to each other, which the term blockchain so neatly captures!
最重要的是,B2有一个块头H2,其中包含D2中所有事务的加密哈希值,以及前一个块B1中的同样的哈希。通过这种方式,区块是不可分割和不可变地相互连接的,术语区块链巧妙地捕捉到了这一点!

Finally, as you can see in the diagram, the first block in the blockchain is called the genesis block. It’s the starting point for the ledger, though it does not contain any user transactions. Instead, it contains a configuration transaction containing the initial state of the network channel (not shown). We discuss the genesis block in more detail when we discuss the blockchain network and channels in the documentation.
最后,如图中所示,区块链中的第一个区块称为创世区块。它是分类帐的起点,尽管它不包含任何用户事务。相反,它包含一个包含网络通道初始状态的配置事务(未显示)。当我们在文档中讨论区块链网络和通道时,我们将更详细地讨论创世区块。

Blocks

Let’s have a closer look at the structure of a block. It consists of three sections
让我们仔细看看一个区块的结构。它由三部分组成

  • Block Header

    This section comprises three fields, written when a block is created.
    这一部分包含三个字段,在创建块时写入。

    • Block number: An integer starting at 0 (the genesis block), and increased by 1 for every new block appended to the blockchain.

    • 块序号:从创世区块的0开始的整数,对于附加到区块链的每个新块,该整数增加1。

    • Current Block Hash: The hash of all the transactions contained in the current block.

    • 当前区块哈希:当前区块中包含的所有事务的哈希。

    • Previous Block Hash: A copy of the hash from the previous block in the blockchain.

    • 上一区块哈希:区块链上一区块的哈希副本。

    These fields are internally derived by cryptographically hashing the block data. They ensure that each and every block is inextricably linked to its neighbour, leading to an immutable ledger.
    这些字段是通过对区块数据进行加密散列而在内部生成的。它们确保每个区块并所有区块都与它的邻居紧密相连,从而形成一个不变的分类账。

    ledger.blocks
    Block header details. The header H2 of block B2 consists of block number 2, the hash CH2 of the current block data D2, and a copy of a hash PH1 from the previous block, block number 1.
    区块头详细信息。区块B2的头H2由区块编号2、当前区块数据D2的hash CH2和上一块的hash PH1的副本(块号1)组成。

  • Block Data
    This section contains a list of transactions arranged in order. It is written when the block is created by the ordering service. These transactions have a rich but straightforward structure, which we describe later in this topic.

  • 块数据
    此部分包含按顺排列的事务列表。它是在订购服务创建块时写入的。这些事务具有丰富但简单的结构,我们将在本主题中后边描述这些事务。

  • Block Metadata
    This section contains the time when the block was written, as well as the certificate, public key and signature of the block writer. Subsequently, the block committer also adds a valid/invalid indicator for every transaction, though this information is not included in the hash, as that is created when the block is created.

  • 区块元数据
    此部分包含区块的写入时间,以及区块写入程序的证书、公钥和签名。随后,区块提交者还为每个事务添加了一个有效/无效的指示器,尽管这些信息未包含在哈希值中,因为哈希值是在创建区块时创建的。

Transactions

As we’ve seen, a transaction captures changes to the world state. Let’s have a look at the detailed blockdata structure which contains the transactions in a block.
正如我们所看到的,事务捕捉到全局状态的变化。让我们仔细看看的blockdata中包含一个区块中的事务的结构。

ledger.transaction
Transaction details. Transaction T4 in blockdata D1 of block B1 consists of transaction header, H4, a transaction signature, S4, a transaction proposal P4, a transaction response, R4, and a list of endorsements, E4.
*事务明细。区块B1的区块数据D1中的事务T4由事务标题H4、事务签名S4、事务提案P4、事务响应R4和背书列表E4组成。

In the above example, we can see the following fields:
在上例中,我们可以看到以下字段:

  • Header
    This section, illustrated by H4, captures some essential metadata about the transaction – for example, the name of the relevant chaincode, and its version.

  • 标题
    这个部分,如H4,它捕获了有关事务的一些基本元数据—如相关链码的名称及其版本。

  • Signature
    This section, illustrated by S4, contains a cryptographic signature, created by the client application. This field is used to check that the transaction details have not been tampered with, as it requires the application’s private key to generate it.

  • 签名
    这个部分,如S4,包含由客户端应用创建的加密签名。此字段用于检查事务详细信息是否被篡改,也因此需要应用的私钥来生成它。

  • Proposal
    This field, illustrated by P4, encodes the input parameters supplied by an application to the smart contract which creates the proposed ledger update. When the smart contract runs, this proposal provides a set of input parameters, which, in combination with the current world state, determines the new world state.

  • 提案
    这个部分,如P4,对应用程序提供给智能合约的输入参数进行编码,智能合约创建分类帐更新提案。当智能合约运行时,此提案提供一组输入参数,与当前全局状态结合,确定新的全局状态。

  • Response
    This section, illustrated by R4, captures the before and after values of the world state, as a Read Write set (RW-set). It’s the output of a smart contract, and if the transaction is successfully validated, it will be applied to the ledger to update the world state.

  • 响应
    这个部分,如R4,以读写集(RW-set)的形式捕获全局状态的前后值。它是智能合约的输出,如果交易被成功验证,它将被应用到分类帐以更新全局状态。

  • Endorsements
    As shown in E4, this is a list of signed transaction responses from each required organization sufficient to satisfy the endorsement policy. You’ll notice that, whereas only one transaction response is included in the transaction, there are multiple endorsements. That’s because each endorsement effectively encodes its organization’s particular transaction response – meaning that there’s no need to include any transaction response that doesn’t match sufficient endorsements as it will be rejected as invalid, and not update the world state.

  • 背书
    如E4所示,这是所需的每个组织签名后的事务响应列表,足以满足背书策略。您会注意到,虽然事务中只包含一个事务响应,但有多个背书。这是因为每个背书都有效地编码了其组织的特定事务响应—这意味着不需要包括任何与足够背书不匹配的事务响应,因为它将被视为无效而拒绝,并且不更新全局状态。

That concludes the major fields of the transaction – there are others, but these are the essential ones that you need to understand to have a solid understanding of the ledger data structure.
这就总结了事务的主要字段,当然还有其他,但这些是您需要了解的重要字段,以便对分类帐数据结构有一个坚实的了解。

World State database options

The world state is physically implemented as a database, to provide simple and efficient storage and retrieval of ledger states. As we’ve seen, ledger states can have simple or compound values, and to accommodate this, the world state database implementation can vary, allowing these values to be efficiently implemented. Options for the world state database currently include LevelDB and CouchDB.
全局状态在物理上用一个数据库实现,以提供对分类帐状态的简单有效的存储和检索。正如我们所看到的,分类帐状态可以具有简单的或复合的值,为了适应这种情况,全局状态数据库的实现会有所不同,从而允许有效地实现这些值。目前,全局状态数据库的选项包括LevelDB和CouchDB。

LevelDB is the default and is particularly appropriate when ledger states are simple key-value pairs. A LevelDB database is closely co-located with a network node – it is embedded within the same operating system process.
LevelDB是默认值,尤其适用于分类帐状态是简单的键值对时。一个LevelDB数据库与一个网络节点结合紧密,和后者于同一个操作系统进程中。

CouchDB is a particularly appropriate choice when ledger states are structured as JSON documents because CouchDB supports the rich queries and update of richer data types often found in business transactions. Implementation-wise, CouchDB runs in a separate operating system process, but there is still a 1:1 relation between a peer node and a CouchDB instance. All of this is invisible to a smart contract. See CouchDB as the StateDatabase for more information on CouchDB.
当分类帐状态结构以JSON实现时,CouchDB是一个特别合适的选择,因为CouchDB支持对业务事务中经常出现的更丰富的数据类型进行多样的查询和更新。在实现方面,CouchDB在单独的操作系统进程中运行,但节点和CouchDB实例之间仍然存在1:1的关系。所有这些对智能合约来说都是不可见的。有关CouchDB的详细信息,请参阅CouchDB as the StateDatabase

In LevelDB and CouchDB, we see an important aspect of Hyperledger Fabric – it is pluggable. The world state database could be a relational data store, or a graph store, or a temporal database. This provides great flexibility in the types of ledger states that can be efficiently accessed, allowing Hyperledger Fabric to address many different types of problems.
在LevelDB和CouchDB中,我们看到了Hyperledger Fabric的一个重要方面—它是可插入的。全局状态数据库可以是关系型数据存储、图存储或临时数据库。这为可有效访问的各种分类帐提供了很大的灵活性,允许Hyperledger Fabric处理许多不同类型的问题。

Example Ledger: fabcar

As we end this topic on the ledger, let’s have a look at a sample ledger. If you’ve run the fabcar sample application, then you’ve created this ledger.
在分类帐这个主题的末尾,让我们看一个分类帐示例。如果你已经运行了fabcar 示例应用,那么你已经创建了这个账本。

The fabcar sample app creates a set of 10 cars each with a unique identity; a different color, make, model and owner. Here’s what the ledger looks like after the first four cars have been created.
fabcar示例创建了一组10辆车,每辆车都有一个独特的标识;不同的颜色、品牌、型号和所有者。这是创建前四辆汽车后的分类账。

ledger.transaction
The ledger, L, comprises a world state, W and a blockchain, B. W contains four states with keys: CAR1, CAR2, CAR3 and CAR4. B contains two blocks, 0 and 1. Block 1 contains four transactions: T1, T2, T3, T4.
分类帐L,由一个全局状态W和一个区块链B组成,W包含四个状态,key分别是:CAR1、CAR2、CAR3和CAR4。B包含两个块,0和1。块1包含四个事务:T1、T2、T3、T4.

We can see that the world state contains states that correspond to CAR0, CAR1, CAR2 and CAR3. CAR0 has a value which indicates that it is a blue Toyota Prius, currently owned by Tomoko, and we can see similar states and values for the other cars. Moreover, we can see that all car states are at version number 0, indicating that this is their starting version number – they have not been updated since they were created.
我们可以看到,全局状态包含与CAR0、CAR1、CAR2和CAR3相对应的状态。CAR0的值表明它是一辆蓝色丰田普锐斯,目前归Tomoko所有,我们可以看到类似的其他汽车的状态和值。此外,我们可以看到所有汽车状态的版本号都是0,这表明这是它们的初始版本号——它们自创建以来就没有更新过。

We can also see that the blockchain contains two blocks. Block 0 is the genesis block, though it does not contain any transactions that relate to cars. Block 1 however, contains transactions T1, T2, T3, T4 and these correspond to transactions that created the initial states for CAR0 to CAR3 in the world state. We can see that block 1 is linked to block 0.
我们还可以看到区块链包含两个区块。0块是创世区块,虽然它不包含任何与汽车相关的事务。但是,区块1包含事务T1、T2、T3、T4,这些事务对应于在全局状态下为CAR0到CAR3创建初始状态的事务。我们可以看到区块1链接到区块0。

We have not shown the other fields in the blocks or transactions, specifically headers and hashes. If you’re interested in the precise details of these, you will find a dedicated reference topic elsewhere in the documentation. It gives you a fully worked example of an entire block with its transactions in glorious detail – but for now, you have achieved a solid conceptual understanding of a Hyperledger Fabric ledger. Well done!
我们没有在区块或事务中显示其他字段,特别是区块头和散列值。如果您对这些内容的细节感兴趣,可以在文档的其他地方找到一个专门的参考主题。它为您提供了一个完整的例子,展示了一个完整的区块,其中的事务处理非常详细——但现在,您已经对一个超级账本结构分类账有了一个坚实的概念理解。做得好!

Namespaces

Even though we have presented the ledger as though it were a single world state and single blockchain, that’s a little bit of an over-simplification. In reality, each chaincode has its own world state that is separate from all other chaincodes. World states are in a namespace so that only smart contracts within the same chaincode can access a given namespace.
尽管我们把分类账看作是一个单一的全局状态和单一的区块链,但这有点过于简单了。实际上,每个链码都有自己的全局状态,与所有其他链码独立。全局状态位于命名空间中,因此只有同一链码中的智能合约才能访问给定的命名空间。

A blockchain is not namespaced. It contains transactions from many different smart contract namespaces. You can read more about chaincode namespaces in this topic.
区块链没有命名空间。它包含来自许多不同智能合约命名空间的事务。您可以阅读本主题中有关chaincode名称空间的更多信息

Let’s now look at how the concept of a namespace is applied within a Hyperledger Fabric channel.
现在让我们来看看命名空间的概念是如何应用于Hyperledge Fabric 通道中的。

Channels

In Hyperledger Fabric, each channel has a completely separate ledger. This means a completely separate blockchain, and completely separate world states, including namespaces. It is possible for applications and smart contracts to communicate between channels so that ledger information can be accessed between them.
在Hyperledger Fabric中,每个通道都有一个完全独立的分类帐。这意味着一个完全独立的区块链,以及完全独立的全局状态,包括命名空间。应用和智能合约可以在通道之间进行通信,以便在通道之间访问分类帐信息。

You can read more about how ledgers work with channels in this topic
您可以阅读本主题中有关分类帐如何处理频道的更多信息

More information

See the Transaction Flow, Read-Write set semantics and CouchDB as the StateDatabase topics for a deeper dive on transaction flow, concurrency control, and the world state database.
请参阅Transaction Flow, Read-Write set semantics and CouchDB as the StateDatabase主题,以深入了解事务流、并发控制和全局状态数据库。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值