From cef4ac5a73e6a7ede3b0a0a177f78e096bda3763 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 1 Jan 2021 18:18:02 +0100 Subject: Add content for chapter about blocks Signed-off-by: Matthias Beyer --- doc/paper/main.tex | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/doc/paper/main.tex b/doc/paper/main.tex index 7789f02..976f2fc 100644 --- a/doc/paper/main.tex +++ b/doc/paper/main.tex @@ -8,8 +8,44 @@ \usepackage{textcomp} \usepackage{xcolor} \usepackage{url} +\usepackage{listings} \def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}} + +\colorlet{punct}{red!60!black} +\definecolor{background}{HTML}{EEEEEE} +\definecolor{delim}{RGB}{20,105,176} +\colorlet{numb}{magenta!60!black} + +\lstdefinelanguage{json}{ + basicstyle=\normalfont\ttfamily, + numbers=left, + numberstyle=\scriptsize, + stepnumber=1, + numbersep=8pt, + showstringspaces=false, + breaklines=true, + frame=lines, + backgroundcolor=\color{background}, + literate= + *{0}{{{\color{numb}0}}}{1} + {1}{{{\color{numb}1}}}{1} + {2}{{{\color{numb}2}}}{1} + {3}{{{\color{numb}3}}}{1} + {4}{{{\color{numb}4}}}{1} + {5}{{{\color{numb}5}}}{1} + {6}{{{\color{numb}6}}}{1} + {7}{{{\color{numb}7}}}{1} + {8}{{{\color{numb}8}}}{1} + {9}{{{\color{numb}9}}}{1} + {:}{{{\color{punct}{:}}}}{1} + {,}{{{\color{punct}{,}}}}{1} + {\{}{{{\color{delim}{\{}}}}{1} + {\}}{{{\color{delim}{\}}}}}{1} + {[}{{{\color{delim}{[}}}}{1} + {]}{{{\color{delim}{]}}}}{1}, +} + \begin{document} \title{How to implement a distributed social network using IPFS} @@ -77,6 +113,49 @@ types. % What a "block" is used for and what data it holds % - metadata pointer +As described above, the "Block" data type is used for building the blockchain. +Because this kind of object must be easy to distribute to ensure high +availability of blocks of a single chain, this type must be small in size. +Thus, it should only hold the following elements: + +\begin{itemize} + \item A version number, which describes the version of the format used + \item A list of pointers to parent blocks + \item A pointer to a metadata Block +\end{itemize} + +A block may hold more than one pointer to a parent block to make merges possible +on the block-level. + +\begin{lstlisting}[language=json,caption={Example of a Block},label=jsonblock] +{ +"v": 1, +"parents": ["Qmabc...", "Qmdef..."], +"content": "Qmghi..." +} +\end{lstlisting} + +As shown in \ref{jsonblock}, minimal data is held in the "Block" object. +Because of the small size, replication of block objects is cheap and every +modern end-user device can easily hold millions of blocks. + +If $S_{parents}(b)$ is the size of the list of parents of a block $b$, +and +$S_{base}$ is the size of a block without any parents, +the required disk space can be described by + +\begin{equation} + S_{sum} = n * S_{base} + \sum_{i=1}^{n} S_{parents}(b_i) +\end{equation} + +where $b_i$ is a block and $n$ is the number of blocks. +Depending on the overhead of the encoding technology used, the size of an +individual block is in the lower bytes range. +E.G. assuming a size of 46 bytes for a IPFS hash, a block with only one parent fits +into 100 bytes, even if encoded as JSON. That means that one Gigabyte of storage +could hold more than 10 Million blocks. + + \subsection{Metadata-Block} % What a "metadata-block" is used for and what data it holds % - mime -- cgit v1.2.3