Blockchain across Oracle
上QQ阅读APP看书,第一时间看更新

Managed by a peer-to-peer network

When you use a traditional ledger, you record the transaction and transfer its assets manually, for example, if you're keeping track of the transaction in an Excel document or using an APEX application running on an Oracle database. Typically, a blockchain is managed by a peer-to-peer network, and transactions are sent to each party using this network. A peer-to-peer (P2P) network is the architecture used for distributed computing/applications and, in the case of blockchains, it is a network in which nodes ("peers") are interconnected and share data or tasks ("resources") among themselves. Within the network, each peer makes a portion of their resources, for example, network bandwidth, processing power, and disk storage, available to other participants in the network. The network runs without the use of a centralized administration system to coordinate transactions.

Peer-to-peer network architecture in a nutshell

The architecture of a peer-to-peer network is designed around nodes or "peers", which function as both client and server simultaneously to any other node on the network. This means that it differs from the traditional client-server model, where a node usually communicates through a central server, such as when transferring a file using an  FTP ( File Transfer Protocol) service. In a P2P network, however, all nodes communicate with each other, for example, when file sharing using BitTorrent.

Peers in a P2P network can connect in two ways. The most common way is to connect to a central server, but the server's only purpose is to index all users who are currently online and connected. The software that runs on a node will query the index server to know to whom it can connect. The second way is that the node seeks out other participants on the internet, such as other nodes running the same software.

In the context of blockchain, there is no central server to which to connect. The software that you run on your machine will need to connect to the IP address of at least one of the active participants. With a public blockchain like Bitcoin or Ethereum, there are seeds that hold a list of active participants, for example, bitseed.xf2.org. The client software that you are running can use these seeds to connect to the network. However, depending on the client, it includes a list of semi-permanent nodes compiled in the code. During runtime, it usually keeps a database of all of the nodes to which it ever connected so that it can easily recover after a reconnect. With a private blockchain, an IP address would usually be provided to you by the regulator or one of the participants, which you can add manually to the client.

As explained, assets transacted on the blockchain come in all types, but usually they have a financial value. Assets that are transferred from you to another entity are recorded in a transaction; for example, cryptocurrency transactions like bitcoins are sent to and from electronic wallets. Wallets are used to sign the transactions digitally for security. I will explain this in more detail later on in this chapter.

With cryptocurrencies, the assets that are transferred are not part of the blockchain transaction—only the metadata of the transaction is recorded. Thus, cryptocurrencies such as Bitcoin, Litecoin, Dash, and Zcash don't exist anywhere–not even in your electronic wallet. They are not physical objects that you can hold, nor do they represent a digital file. Compare this with your bank account, which holds pounds, euros, or dollars. They do not represent a physical object until you exchange them as well. Every peer that joins the network has a particular address, but there are no digital assets held within it.

Instead, the blockchain only holds records of transactions between different addresses, where the balance increases or decreases. If you want to know the current balance of an address, you must reconstruct it by querying the blockchain. For example, client software iterates through all blocks of the blockchain to get the information to construct the balance.

What is a blockchain address?

An address, such as a Bitcoin address, is a simple identifier that has a length of 26 to 35 alphanumeric characters. These addresses represent a possible destination. Unlike an e-mail address, however, one person tends to have many different addresses. With some blockchains like Bitcoin, a unique address is used for each transaction. In other blockchains, however, the address represents one specific entity that stays the same over time.

When looking at a Bitcoin address, the format commonly starts with a 1, for example, 1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2.

An address is case-sensitive and very precise. A typo can result in your transaction being rejected due to an incorrect address. The probability is very low that if you mistype the address, the transaction will be accepted, so I recommend that you always do a copy and paste procedure using your computer's clipboard.

As I mentioned at the beginning of this chapter, the goal of this book is not to look at these cryptocurrencies in great detail, but rather to focus on applications of the blockchain with which you, as Oracle developers, will work and that customers may request. For instance, the kinds of data streams that can be transferred within these applications are totally different to those used for cryptocurrencies. Whereas cryptocurrencies only hold metadata of a payment, the applications you will learn about in this book can hold megabytes of binary data in a single transaction. Think of full XML or JSON documents versus references to actual documents saved in a document store.