Introducing Blockchain with Java: Program, Implement, and Extend Blockchains with Java 1st Edition Spiro Buzharovski pdf download
Introducing Blockchain with Java: Program, Implement, and Extend Blockchains with Java 1st Edition Spiro Buzharovski pdf download
https://ebookmeta.com/product/introducing-blockchain-with-java-
program-implement-and-extend-blockchains-with-java-1st-edition-
spiro-buzharovski/
https://ebookmeta.com/product/introducing-blockchain-with-java-
program-implement-and-extend-blockchains-with-java-1st-edition-
spiro-buzharovski/
https://ebookmeta.com/product/introducing-blockchain-with-lisp-
implement-and-extend-blockchains-with-the-racket-language-1st-
edition-boro-sitnikovski/
https://ebookmeta.com/product/learn-java-with-math-1st-edition-
ron-dai/
https://ebookmeta.com/product/humans-in-the-siberian-landscapes-
ethnocultural-dynamics-and-interaction-with-nature-and-space-1st-
edition-vladimir-n-bocharnikov/
Thinking with Stephen J. Ball : Lines of Flight in
Education 1st Edition Maria Tamboukou
https://ebookmeta.com/product/thinking-with-stephen-j-ball-lines-
of-flight-in-education-1st-edition-maria-tamboukou/
https://ebookmeta.com/product/violence-against-women-and-
criminal-justice-in-africa-volume-i-legislation-limitations-and-
culture-1st-edition-emma-charlene-lubaale/
https://ebookmeta.com/product/advanced-optical-and-wireless-
communications-systems-2nd-edition-ivan-b-djordjevic/
https://ebookmeta.com/product/ptsd-and-coping-with-trauma-
information-for-teens-teen-health-series-1st-edition-angela-l-
williams/
https://ebookmeta.com/product/heart-of-a-wolf-crescent-
pack-2-1st-edition-jennifer-snyder/
Capturing Christmas A Bratva Age Gap Captive Romance A
Filthy Dirty Christmas 1st Edition Jagger Cole
https://ebookmeta.com/product/capturing-christmas-a-bratva-age-
gap-captive-romance-a-filthy-dirty-christmas-1st-edition-jagger-
cole/
Spiro Buzharovski
This work is subject to copyright. All rights are solely and exclusively
licensed by the Publisher, whether the whole or part of the material is
concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in
any other physical way, and transmission or information storage and
retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed.
The publisher, the authors and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.
1. Introduction to Blockchain
Spiro Buzharovski1
(1) Skopje, North Macedonia
Further, at the end of every day, you all sit together and refer to the
ledger to do the calculations to settle up. Let’s imagine that there is a
pot that is the place where all of the money is kept. If you spent more
than you received, you put that money in the pot; otherwise, you take
that money out.
We want to design the system such that it functions similarly to a
regular bank account. A holder of a wallet (bank account) should be
able to only send money from their wallet to other wallets. Thus, every
person in the system will have a wallet of a kind, which can also be used
to determine the balance for them. Note that with the current setup
using a ledger, we have to go through all the existing records to
determine the balance of a specific wallet.
If we want to avoid going through all the existing records, there is a
way we can optimize this with unspent transaction outputs (UTXOs), as
we will see later in Chapter 3.
A problem that may arise is the double-spending problem , where
Bob can try to send all of his money to Alice and you at the same time,
thus effectively doubling the money he sends in relation to what he
owned. There are several ways this can be resolved, and the solution
that we will provide will be a simple check of the sum of the inputs and
the sum of the outputs.
A problem that might appear with this kind of system is that anyone
can add a transaction. For example, Bob can add a transaction where
Alice pays him a few dollars without Alice’s approval. We need to re-
think our system such that each transaction will have a way to be
verified/signed.
For example, when you are accessing a web page on the Internet using a
browser, your browser is the client, and the web page you’re accessing
is hosted by a server. This represents a centralized system since every
user is getting the information from a single place—the server.
In contrast, in a peer-to-peer network, which represents a
decentralized system, the distinction between a client and a server is
blurred. Every peer is both a client and a server at the same time.
With the system (Figure 1-3), as the list of peers (people) grows, we
might run into a problem of trust. When everybody meets at the end of
the day to sync their ledgers, how can they believe the others that the
transactions listed in their ledgers are true? Even if everybody trusts
everybody else for their ledger, what if a new person wants to join this
network? It’s natural for existing users to ask this newcomer to prove
that they can be trusted. We need to modify our system to support this
kind of trust. One way to achieve that is through so-called proof of work
, which we introduce next.
Figure 1-3 A decentralized ledger
For each record we will also include a special number (or a hash) that
will represent proof of work, in that it will provide proof that the
transaction is valid. We will cover the technical details in the “Hashing”
section.
At the end of the day, we agree that we will trust the ledger of the
person who has put most of the work in it. If Bob has some errands to
run, he can catch up the next day by trusting the rest of the peers in the
network.
In addition to all this, we want the transactions to have an order, so
every record will also contain a link to the previous record. This
represents the actual blockchain, depicted in Figure 1-4.
Figure 1-4 A chain of blocks: blockchain
If everybody agreed to use this ledger as a source of truth, there
would be no need to exchange physical money at all. Everybody can just
use the ledger to put in or retrieve money from it.
To understand the technical bits of digital signatures and proof of
work, we will be looking at encryption and hashing, respectively.
Fortunately for us, the programming language that we will be using has
built-in functionalities for encryption and hashing. We don’t have to dig
too deep into how hashing and encryption and decryption work, but a
basic understanding of them will be sufficient.
Observe how we started with a simple definition of a ledger and
gradually built up to a complex system. We will use the same approach
in programming.
1.2 Encryption
We will start with the following definition.
Note that in this section we will mostly talk about numbers, but
characters and letters can also be encrypted/decrypted with the same
methods, by using the ASCII2 values for the characters.
Before we talk about encryption, we first have to recall what
functions are, since the encoding/decoding values are achieved with
the usage of them.
1.2.1 Functions
For example, you might have a function that accepts as input a person
and as output returns the person’s age or name. Another example is the
function f (x) = x + 1. There are many inputs this function can accept: 1,
2, 3.14. For example, when we input 2, it gives us an output of 3, since f
(2) = 2 + 1 = 3.
One simple way to think of functions is in the form of tables. For a
function f (x) accepting a single argument x, we have a two-column
table where the first column is the input, and the second column is the
output. For a function f (x, y) accepting two arguments x and y, we have
a three-column table where the first and second columns represent the
input, and the third column is the output. Thus, to display the function
discussed earlier in the form of a table, it would look like this:
x f (x)
1 2
2 3
… …
1.2.2 Symmetric-Key Algorithm
We can assume that there exist functions E(x) and D(x) for encryption
and decryption, respectively. We want these functions to have the
following properties:
E(x) ≠ x, meaning that the encrypted value should not be the
same as the original value
E(x) ≠ D(x), meaning that the encryption and decryption
functions produce different values
D(E(x)) = x, meaning that the decryption of an encrypted value
should return the original value
For example, let’s assume there’s some kind of an encryption
scheme, say E("Boro") = 426f726f. We can “safely” communicate
the value 426f726f without actually exposing our original value, and
only those who know the decryption scheme D(x) will be able to see
that D(426f726f) = "Boro".
Another example of encryption scheme is for E(x) to shift every
character in x forward, and for D(x) to shift every character in x
backward. This scheme is known as the Caesar cipher. To encrypt the
text “abc” we have E("abc") = "bcd", and to decrypt it we have
D("bcd") = "abc".
However, the scheme described makes a symmetric algorithm
(Figure 1-6), meaning that we have to share the functions E and D with
the parties involved, and as such, they may be open to attacks.
This algorithm scheme has a neat property where only the private
key can decode a message, and the public key can encode a message.
We have two functions that should have the same properties as
those for the symmetric-key algorithm.
E(x, p), which encrypts a message x given a public key p
D(x′ , s), which decrypts an encrypted message x′ given a
private (secret) key s
In our example, we will rely on the modulo operation. Recall that a
mod b represents the remainder when a is divided by b. For example, 4
mod 2 = 0 because there is no remainder when dividing 4 by 2;
however, 5 mod 2 = 1.
Here’s one example of a basic encryption algorithm based on
addition and modulo operations:
1. Pick one random number, for example 100. This will represent a
common, publicly available key.
2. Pick another random number in the range (1, 100), for example 97.
This will represent the private key s.
5. To decrypt data, we use the same logic but with our private key, so
D(x′ , s) = (x′ + s) mod 100.
EXERCISE 1-1
Come up with a table of functions such that:
1. The input is a number, and the output is a number
EXERCISE 1-2
Check the three properties for a symmetric-key algorithm to ensure
the Caesar cipher is compatible with them.
EXERCISE 1-3
Come up with an encryption scheme, based on mathematical
substitution.
EXERCISE 1-4
Use the asymmetric-key algorithm we defined to sign a message and
verify it.
1.3 Hashing
EXERCISE 1-5
Come up with your own hashing function.
EXERCISE 1-6
In which way can the linked list depicted in Figure 1-4 be traversed?
What are the implications of this property?
1.5 Bitcoin
Bitcoin was the world’s first implementation of a blockchain. In
November 2008, a link to a paper authored by Satoshi Nakamoto titled
“Bitcoin: A Peer-to-Peer Electronic Cash System” was published on a
cryptography mailing list. Bitcoin’s white paper consists of nine pages;
however, it is a mostly theoretical explanation of the design and as such
may be a bit overwhelming to newcomers.
The Bitcoin software is open source code and was released in
January 2009 on SourceForge. The design of a Bitcoin includes a
decentralized network (peer-to-peer network), block (mining),
blockchain, transactions, and wallets, each of which we will look at in
detail in this book.
Although there are many blockchain models and each one of them
differs in implementation details, the blockchain we will be building
upon in this book will look pretty similar to Bitcoin, with some parts
simplified.
1.7 Summary
The point of this chapter is to get a vague idea of how the system that
we will implement looks. Things will become much clearer in the next
chapter where we will be explicit about the definitions of every entity.
Here’s what we learned in this chapter, briefly:
The core entity of the system is a block.
A block contains (among other data) transactions.
We have a ledger that is an ordered list of all valid blocks
(blockchain.)
Every peer involved with the ledger has a wallet.
Every record in the ledger is signed by the owner and can be verified
by the public (digital signatures).
The ledger is in a decentralized location; that is, everybody has a
copy of it.
Trust is based upon proof of work (mining).
Footnotes
1 We will use this definition throughout the book, but note that there are many
different definitions on the Internet. By the end of this book, you should be able to
distinguish the slight nuances and similarities in each definition.
2 An ASCII table is a table that assigns a unique number to each character (such as !,
@, a, Z, etc.).
3 Hashcash was initially targeted for limiting email spam and other attacks.
However, recently it’s also become known for its usage in blockchains as part of the
mining process. Hashcash was proposed in 1997 by Adam Backa.
© The Author(s), under exclusive license to APress Media, LLC, part of Springer
Nature 2022
S. Buzharovski, Introducing Blockchain with Java
https://doi.org/10.1007/978-1-4842-7927-4_2
2.1 Block.java
We will start first by listing the imports in the following code snippet:
1 package com.company.Model;
2
3 import sun.security.provider.DSAPublicKeyImpl;
4
5 import java.io.Serializable;
6 import java.security.InvalidKeyException;
7 import java.security.Signature;
8 import java.security.SignatureException;
9 import java.util.ArrayList;
10 import java.util.Arrays;
11 import java.util.LinkedList;
12
55
56 @Override
57 public boolean equals(Object o) {
58 if (this == o) return true;
59 if (!(o instanceof Block)) return false;
60 Block block = (Block) o;
61 return Arrays.equals(getPrevHash(),
block.getPrevHash());
62 }
63
64 @Override
65 public int hashCode() {
66 return Arrays.hashCode(getPrevHash());
67 }
68
69 public byte[] getPrevHash() { return prevHash;
}
70 public byte[] getCurrHash() { return currHash;
}
71
72 public void setPrevHash(byte[] prevHash) {
this.prevHash = prevHash; }
73 public void setCurrHash(byte[] currHash) {
this.currHash = currHash; }
74
75 public ArrayList<Transaction>
getTransactionLedger() {
return transactionLedger; }
76 public void setTransactionLedger(
ArrayList<Transaction> transactionLedger)
{
77 this.transactionLedger =
transactionLedger;
78 }
79
80 public String getTimeStamp() { return
timeStamp; }
81 public void setMinedBy(byte[] minedBy) {
this.minedBy = minedBy; }
82
83 public void setTimeStamp(String timeStamp) {
this.timeStamp = timeStamp; }
84
85 public byte[] getMinedBy() { return minedBy; }
86
87 public Integer getMiningPoints() { return
miningPoints; }
88 public void setMiningPoints(Integer
miningPoints) {
this.miningPoints = miningPoints; }
89 public Double getLuck() { return luck; }
90 public void setLuck(Double luck) { this.luck =
luck; }
91
92 public Integer getLedgerId() { return
ledgerId; }
93 public void setLedgerId(Integer ledgerId) {
this.ledgerId = ledgerId; }
94
95 @Override
96 public String toString() {
97 return "Block{" +
98 "prevHash=" +
Arrays.toString(prevHash) +
99 ", timeStamp='" + timeStamp + '\''
+
100 ", minedBy=" +
Arrays.toString(minedBy) +
101 ", ledgerId=" + ledgerId +
102 ", miningPoints=" + miningPoints +
103 ", luck=" + luck +
104 '}';
105 }
106}
107
The first thing to note here is that the equals method compares the
previous hash of the block class. We’ll use this later in Chapter 6 when we
explain the consensus algorithm further. The other thing of note is the
fields contained in the toString method . We include everything that
goes into verifying the block against the current hash.
Important!
The miner’s public key is used for other peers to verify the block by
comparing the signature’s hash against the hash of the block’s data.
Note how all of the essential fields that make certain the block is
unique are included in the toString() method.
2.2 Transaction.java
We briefly mentioned that we keep an array list of transactions in our
Block class in the previous section, and now it’s time to explain in detail
what our Transaction.java class contains. First we’ll start with the
imports found in the following code snippet:
1 package com.company.Model;
2
3 import sun.security.provider.DSAPublicKeyImpl;
4
5 import java.io.Serializable;
6 import java.security.InvalidKeyException;
7 import java.security.Signature;
8 import java.security.SignatureException;
9 import java.time.LocalDateTime;
10 import java.util.Arrays;
11 import java.util.Base64;
12
Next let’s go over the class declaration and its fields, as shown in the
next code snippet:
13 public class Transaction implements Serializable {
14
15 private byte[] from;
16 private String fromFX;
17 private byte[] to;
18 private String toFX;
19 private Integer value;
20 private String timestamp;
21 private byte[] signature;
22 private String signatureFX;
23 private Integer ledgerId;
24
Since this class also creates objects from which we are building our
blockchain, it will implement the interface serializable so that it’s shareable
through the network.
The fields from and to will contain the public keys/addresses of the
account that sends and the account that receives the coins, respectively.
The value is the amount of coins that will be sent, and timeStamp is the
time at which the transaction has occurred. Signature will contain the
encrypted information of all the fields, and it will be used to verify the
validity of the transaction (it will be used the same way the field
currHash was used in the previous class).The ledgerId serves the same
purpose as in the previous class. The fields with the FX suffix are simple
duplicates formatted to String instead of byte[]. We do this so that we
can easily display them on our front end.
In this class we also have two constructors; the first one is used when
we retrieve a transaction from the database, and the second one is used
when we want to create a new transaction within our application. Let’s
observe them in the following code snippet:
To achieve this, first we set up our data by initiating our class fields
from the parameters and add a timestamp as shown on lines 44 to 50. Now
once we have our data that we would like to encrypt, we set our private key
to the signing object with the statement on line 51. This tells the signing
object, when encrypting, to use the private key we provided. On line 52 we
are putting all the data we want to encrypt in a single String object by
using the toString() method . On line 53 we are feeding all the data we
want to encrypt to the signing object, and on line 54 we are actually
encrypting the data and assigning it to our signature field.
Next is our method for the verification of transactions, as shown in the
following snippet:
65 @Override
66 public String toString() {
67 return "Transaction{" +
68 "from=" + Arrays.toString(from) +
69 ", to=" + Arrays.toString(to) +
70 ", value=" + value +
71 ", timeStamp= " + timestamp +
72 ", ledgerId=" + ledgerId +
73 '}';
74 }
75
76 public byte[] getFrom() { return from; }
77 public void setFrom(byte[] from) { this.from =
from; }
78
79 public byte[] getTo() { return to; }
80 public void setTo(byte[] to) { this.to = to; }
81
82 public Integer getValue() { return value; }
83 public void setValue(Integer value) {
this.value = value; }
84 public byte[] getSignature() { return
signature; }
85
86 public Integer getLedgerId() { return ledgerId;
}
87 public void setLedgerId(Integer ledgerId) {
this.ledgerId = ledgerId; }
88
89 public String getTimestamp() { return
timestamp; }
90
91 public String getFromFX() { return fromFX; }
92 public String getToFX() { return toFX; }
93 public String getSignatureFX() { return
signatureFX; }
94
95
96 @Override
97 public boolean equals(Object o) {
98 if (this == o) return true;
99 if (!(o instanceof Transaction)) return
false;
100 Transaction that = (Transaction) o;
101 return Arrays.equals(getSignature(),
that.getSignature());
102 }
103
104 @Override
105 public int hashCode() {
106 return Arrays.hashCode(getSignature());
107 }
108
109}
Important!
Note how all the essential fields that make certain the transaction
is unique are included in the toString() method.
EXERCISE 2-1
If we fail to include a timestamp as part of the verification process in our
transaction object, can you think of a way to exploit this vulnerability?
2.3 Wallet.java
Let’s start as always with the imports for this class located in the following
snippet:
1 package com.company.Model;
2
3 import java.io.Serializable;
4 import java.security.*;
5
Important!
Our blockchain wallet also won’t contain any field containing the
current balance of the wallet. We will explain how we obtain our
wallet balance in Chapter 6.
Let’s look at our first two constructors on our next snippet, which will be
used when we want to create a new wallet and assign a new key pair to it:
18
19 //Constructor for importing Keys only
20 public Wallet(PublicKey publicKey, PrivateKey
privateKey) {
21 this.keyPair = new
KeyPair(publicKey,privateKey);
22 }
The code here simply receives public and private key objects and
creates a new KeyPair object with them.
Finally, we finish up this class and chapter by including the generic
getters and setters in the following snippet:
23
24 public KeyPair getKeyPair() { return keyPair; }
25
26 public PublicKey getPublicKey() { return
keyPair.getPublic(); }
27 public PrivateKey getPrivateKey() {
return keyPair.getPrivate(); }
28}
2.4 Summary
In this chapter, we covered the creation of our model layer of the
application. These classes and their methods will be used as basic building
blocks throughout the rest of the application. Therefore, having nice grasp
of them now will greatly benefit you in understanding the more complex
logic in the upcoming chapters. This is a small recap of what concepts we
covered so far:
Representation of a single block of the blockchain by implementing our
Block.java class
Java implementation of importing blocks from an existing blockchain and
creation of the head block of the blockchain
Representation of a blockchain transaction by implementing our
Transaction.java class
Java implementation for importing transactions and creating new
transactions
Java implementation of encryption and verification (creating signatures
and verifying them)
Representation of a blockchain wallet by implementing our
Wallet.java class
Answer to Exercise 2-1: Someone can copy and paste a signed
transaction, and it will pass the validation checks since there is no way to
make sure the transaction is unique in time.
Other documents randomly have
different content
1 813 107
2 706 61
3 645 46
4 599 33
5 566 30
6 536 20
7 516 11
8 505 9
9 496 7
10 489 6
11 483 5
12 478 5
13 473 6
14 467 6
15 461 6
16 455 7
17 448 6
18 442 6
19 436 6
20 430 5
21 425 5
22 420 5
23 415 6
24 409 6
25 403 6
26 397 6
27 391 7
28 384 7
29 377 7
30 370 6
31 364 6
32 358 5
33 353 6
34 347 7
35 340 8
36 332 8
37 324 8
38 316 9
39 307 9
40 298 8
41 290 7
42 283 6
43 277 6
44 271 7
45 264 8
46 256 9
47 247 9
48 238 9
49 229 9
50 220 8
51 212 7
52 205 7
53 198 7
54 191 7
55 184 8
56 176 8
57 168 9
58 159 8
59 151 8
60 143 7
61 136 7
62 129 6
63 123 7
64 116 7
65 109 8
66 101 8
67 93 8
68 85 7
69 78 7
70 71 6
71 65 5
72 60 5
73 55 4
74 51 4
75 47 5
76 42 5
77 37 5
78 32 5
79 27 4
80 23 3
81 20 2
82 18 2
83 16 2
84 14 2
85 12 2
86 10 2
87 8 2
88 6 2
89 4 1
90 3 1
91 2 1
92 1 1
A Table of Thirty Years, taken from the London Bills, beginning with
1728, and ending with 1757; shewing the Total Number of
Deaths and Decrease in this Period, at every Age.
Years of Age. Died.
Under ——— 2 272903
{2 to 5 64745
{5 ——— 10 25912
{ 10 ——— 20 22891
{ 20 ——— 30 58474
{ 30 ——— 40 71502
From { 40 ——— 50 73258
{ 50 ——— 60 59872
{ 60 ——— 70 47269
{ 70 ——— 80 33679
{ 80 ——— 90 16948
{ 90 ——— 100 2496
{100 ——— 138 242
———
Total Deaths in this Period, at all Ages } 750,191
The two following Tables are taken from Dr. Price. I have however
omitted the fractions, for reasons which shall be explained when
treating of the inaccuracy of the public registers. The expectations of
life are here rated a few years inferior to the standard of most other
authors.
The probable Expectations or Prospects of Life in
Country Holy Cross, Pais de
Ages. London. Vienna. Berlin. parish of near Vaud, in
Brandenburg. Shrewsbury. Switzerland.
At
18 yrs. 17 yrs. 18 yrs. 33 yrs. 33 yrs. 37 yrs.
birth
Age 12 34 36 36 44 44 44
25 26 28 27 36 35 35
30 24 26 25 32 32 31
35 22 23 24 26 28 28
40 20 21 21 25 26 24
45 18 18 19 22 23 21
50 16 16 16 18 20 18
55 14 14 14 15 17 15
60 13 12 13 12 15 12
65 11 10 11 10 12 10
70 9 9 9 8 10 8
75 7 7 7 6 8 6
80 5 6 6 5 5 5
The Odds or Probability of living one Year in
Country Holy Cross, Pais de
Ages. London. Vienna. Berlin. parish of near Vaud, in
Brandenburg. Shrewsbury. Switzerland.
At
2 to 1 2 to 1 2 to 1 4 to 1 5 to 1 5 to 1
birth
Age 12 75 to 1 84 to 1 123 to 1 112 to 1 144 to 1 160 to 1
25 56 to 1 66 to 1 50 to 1 110 to 1 100 to 1 117 to 1
30 45 to 1 56 to 1 44 to 1 107 to 1 96 to 1 111 to 1
40 31 to 1 36 to 1 32 to 1 78 to 1 55 to 1 83 to 1
50 24 to 1 27 to 1 30 to 1 50 to 1 50 to 1 49 to 1
60 18 to 1 19 to 1 18 to 1 25 to 1 26 to 1 23 to 1
70 12 to 1 11 to 1 12 to 1 11 to 1 16 to 1 10 to 1
80 7 to 1 7 to 1 7 to 1 6 to 1 8 to 1 4 to 1
Having in the preceding part endeavoured to establish the mortality
of the human species at different ages, I am now to attempt a more
arduous task; to ascertain the mortality by different diseases. I
propose therefore, in imitation of the geographers, to spread out and
to review, in one general Chart, the enormous host of diseases which
disgorge their virulence over the earth, and, with frightful rapacity,
wage incessant hostilities with mankind. By this means, we shall, to
use a military phrase, reconnoitre more distinctly our enemies
arranged in hostile front; and be warned to make the best disposition
and preparation for defence where the greatest danger is
apprehended, and the most formidable assaults to be sustained.
Armed with diseases, the grim King of Terrors appears in the most
hideous aspect. Under all these predatory disguises and morbifick
forms, I shall track him grappling with mankind, and with his
tremendous scythe mowing down generations. The learned Sauvages
thus expresses himself: “Utinam numerus respectivus diversorum
morborum a nostratibus inquirarentur.” It is, in some measure, from
ignorance in this subject, that the streams of medical inquiries, of
academick rudiments, and of charitable donations to poverty in
disease, have not yet been pointedly directed to publick utility.
I could easily have exhibited tables of the Diseases and Casualties in
London during the greater part of the last century. But, compared to
its present magnitude, the British metropolis was then insignificant in
size: 23 new parishes have been since gradually added to the London
bills: there is also a chasm of 10 years in which the registers are lost.
Again, until 1665 and 6, London was infested with the plague; which
disease, previous to that date, seems to have been one primary
object of the registers: and to adopt Graunt and Short’s sentiments,
these records, from various political and religious obstacles, were
then very negligently managed. During the early part of this interval,
the kingdom was distracted with civil war; and after the great
pestilence in 1665, London must have required some years to recruit.
Besides, had I attempted to form tables for even the latter part of the
last century, the reader would have been fruitlesly embarrassed; and
such an attempt must ever prove abortive. For example, under one
and the same title, in the annual bills of mortality, are often
confounded flox, small pox, and measles: consumptions and tissick:
cancer, canker, and thrush: wolf, cancer, gangrene, and fistula:
cancer, gangrene, fistula, and mortification: gout and sciatica:
vapours and water in the head: quinsey and thrush: teeth and
worms: sores, ulcers, bruised and broken limbs: cough, cold, and
chincough, &c. These are a few specimens of Nosological absurdity in
the superintendents of the publick registers.
Notwithstanding this rabble of diseases in commenting upon the
London bills and diseases of the present century, I constantly refer
back, and contrast them with the bills of the last thirty years of the
preceding century; so that, as near as the imperfection of the
materials will admit, the mortality and diseases of 105 years in
London is presented at one view; and comprehends the various acute
and chronic diseases, by which about two million and a half of the
human species have been destroyed. The few authors who have
written on bills of mortality, have obscured their works in a cloud of
figures and calculation: the reader must have no small portion of
phlegm and resolution to follow them throughout with attention: they
often tax the memory and patience with a numerical superfluity, even
to a nuisance.
For the above, and many other reasons, I have compressed into one
chart, the London Diseases and Casualties of seventy-five years in
the present century: each disease and casualty arranged in a
progressive series of fifteen years mortality; in a fifth column is
added together the mortality of the preceding five divisions. During
this period, London has been more populous and stationary in
numbers: and by this means, the actual and comparative magnitude,
rise, and declension of different diseases, will be more conspicuous in
each period or interval: and by measuring the mortality with the
population, we are enabled, with certain precautions and exceptions,
to make the diseases and casualties of London serve as a morbid
barometer to the whole nation. The important reason which
determined me in forming an arrangement of fifteen years, in
preference to any other number or period, was, that the annual
havock by similar diseases and casualties, throughout this and the
neighbouring island, might be computed with some probability by
each fifteen years of the London bills; and thereby to elicite a new,
curious, and comprehensive proportion in medicine. For instance, if
we suppose the standing number, on an average, of the London
inhabitants at six hundred thousand; and the total inhabitants in
Britain and Ireland at nine million; and if the same diseases and
casualties were equally diffused and fatal to this whole community,
then, in such case, the London bills would serve as a scale or index of
mortality to both kingdoms: as many would die annually of every
disease and casualty throughout nine million, as are cut off in fifteen
years in London; for six hundred thousand multiplied by fifteen,
amounts to nine million.
But to supply the probable deficiency in the annual mortality of
London by different diseases and casualties, we must make an
addition to each of one third or fourth. To the mortality of Small-Pox,
in London, during fifteen years, and rated at thirty thousand, we
should add one third or fourth more to raise it to its just standard;
that is, to about thirty-eight thousand; which would be the annual
mortality amongst nine million in Britain and Ireland, supposing
small-pox equally universal, one time or other, and destructive. By
the same hypothesis, amongst two hundred million in Europe
Variolous mortality annually, would amount to four hundred
thousand; and, amongst eight hundred million; that is, the whole
human race would exceed three million annually. On this simple
principle, a gross estimate may be formed of the annual havock by
every other disease and casualty; taking the precaution, however, to
attend to the subsequent criticisms on the London bills.
Another curious corollary may be grounded on the above hypothesis;
which is, to form a probable conjecture of the numbers who are
annually Sick, or afflicted with different diseases. Example: if one of
every seven die of the Small Pox, and the variolous deaths
throughout Britain and Ireland are rated at thirty-eight thousand
annually, this number, multiplied by seven, amounts to two hundred
and sixty-six thousand annually, infected with variolous contagion.
Apply the same rule to Childbed mortality; rate the annual havock by
parturition in the two islands at four thousand: it will hereafter be
shewn, that in London one of seventy-four women die in childbed:
multiply therefore 4,000 by 74, the product is 296,000, which, in
reality, cannot be very distant from the total annual procreation in
both islands. And in these two examples, I have suggested what may
be termed an inverse proof of both propositions. From these tables
and commentaries, we are likewise furnished with a key to the
comparative mortality of each disease amongst a community:
whether its devastation is in the proportion of a fifth, tenth,
twentieth, or hundredth. Gentlemen who have not particularly
attended to the subject of morbid calculations (and very few of the
medical profession have) will, on better information, be astonished at
the flagrant errors daily committed by authors when treating of these
topicks. Out of the many examples which might be enumerated, I
shall merely select one in proof. Baron Dimsdale, in a Treatise on
Inoculation, dedicated to the present Empress of Russia, calculated
that, at least, two million were annually destroyed by Small Pox alone
in the Russian empire; and it was not until after the publication of my
Observations on his different Inoculating Essays, that this error and
others were erased.
I would request the reader’s particular attention to another
circumstance: which is, that on comparing the gradations of mortality
in the following chart, we are not to estimate the relative number,
frequency, or proportion of certain diseases, compared to others by
the absolute mortality of each. For instance, Apoplexy kills rather
more annually in London than Measles; but yet the latter disease is
infinitely more universal and diffused amongst the community, and
consequently less dangerous to life: Cancerous and Venereal cases
are widely different in the annual number afflicted with each,
although the deaths are not far distant from an equality. The same
observations will apply to Rheumatism, compared to the Dropsy, and
to many other diseases.
There are between eighty and ninety diseases and casualties
enumerated in the London bills, which, in the subsequent comments,
I have disentangled into their separate genera. But, to prevent the
possibility of aberration, after the chart of London diseases, I have
added a correct Medical Chart of all the principal diseases and
casualties with which mankind, in every part of the earth and ocean,
are afflicted or harrassed. This will operate as a check and correction
to the public registers; and by this, the defects and errors in the
London bills will be apparent; and it will serve as an index to our
future commentaries. But objections and difficulties occur in our
researches for collateral information and illustration from hospital
records. The reasons are glaring, why, in the latter, diseases should
be less fatal; and in this respect, cities should have the advantage of
the country. We cannot therefore apply hospital registers as a general
criterion to a nation. Whenever authentic and systematic records of
diseases, recovery, and mortality, are kept in hospitals, domestick as
well as military, and annually published, whatever may be alledged
respecting the importance and demerits of such institutions, the
community, at all events, will derive much useful information.