# Syncing new node - questions about the sync

**URL:** https://forum.duniter.org/t/syncing-new-node-questions-about-the-sync/563
**Category:** Nodes
**Created:** [20 November 2015 13:24 UTC](https://forum.duniter.org/t/syncing-new-node-questions-about-the-sync/563 "2015-11-20T13:24:54Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Sylvain](https://forum.duniter.org/user_avatar/forum.duniter.org/sylvain/32/433_2.png) [@Sylvain](https://forum.duniter.org/u/Sylvain)
#### Post date: [20 November 2015 13:24 UTC](https://forum.duniter.org/t/syncing-new-node-questions-about-the-sync/563/1 "2015-11-20T13:24:54Z")

</div>

Following [my post on installing a new node](http://forum.duniter.org/t/installing-your-own-node/72/22?u=sylvain) I’ve some newbee question about the syncing process.

I issued a sync command from my fresh node:

ucoind --version  
0.11.13

ucoind sync [metab.ucoin.io](http://metab.ucoin.io) 9201

```auto
Download: [||||||||||||||||||||] 100 %
Apply: [||||] 22 %

Status: Remaining 16 hours

```

After few hours, it still in progress.

Can I safely interrupt the sync? And may be move this VM somewhere else. Or will it fail to restart?

Cgeek has said that the sync process will be easier with ucoind-v0.12. Does the version upgrade take care of previous work or should it be restarted from scratch.

As far as I know the protocol of syncing a node must slowdown newcomer node to stabilize the network of node of the community. Avoiding alien node to multiply and takeover a community may be. Which seems perfectly reasonable to me. But not if it can’t be interrupted at any time and restarted later.

What the node is doing during the download/Apply?  
Can it do something else during the period?  
Can we see where it is in the apply process?

If I can stop the node, can I slow down it’s CPU usage during the sync.  
Can I upgrade the node with 0.12 code and make it use downloaded or even computed data of the version0.11?

Regards,  
Sylvain.

---

<div class="post-metadata">

### Author: ![Moul](https://forum.duniter.org/user_avatar/forum.duniter.org/moul/32/9145_2.png) [@Moul](https://forum.duniter.org/u/Moul)
#### Post date: [20 November 2015 13:52 UTC](https://forum.duniter.org/t/syncing-new-node-questions-about-the-sync/563/2 "2015-11-20T13:52:55Z")

</div>

Hi @Sylvain,

I have update documentation to [install a node](https://github.com/ucoin-io/ucoin/wiki/Install-uCoin-node).

Yep, you can interrupt sync.  
You should use uCoin 0.12 witch have a faster syncing method and you should use the `--nocautious` arguments when syncing which doesn’t verify blockchain

The verifying part consume lot of CPU.

You should be able to sync in less than 20 min.

---

<div class="post-metadata">

### Author: ![cgeek](https://forum.duniter.org/user_avatar/forum.duniter.org/cgeek/32/279_2.png) [@cgeek](https://forum.duniter.org/u/cgeek)
#### Post date: [20 November 2015 14:18 UTC](https://forum.duniter.org/t/syncing-new-node-questions-about-the-sync/563/3 "2015-11-20T14:18:18Z")

</div>

You could have a little word about `--autoconf` option too, but what you wrote is OK. Thank you 🙂

---

<div class="post-metadata">

### Author: ![Sylvain](https://forum.duniter.org/user_avatar/forum.duniter.org/sylvain/32/433_2.png) [@Sylvain](https://forum.duniter.org/u/Sylvain)
#### Post date: [20 November 2015 16:31 UTC](https://forum.duniter.org/t/syncing-new-node-questions-about-the-sync/563/4 "2015-11-20T16:31:45Z")

</div>

Cool I will try it.

Where do I find stored blockchain to save and restart using different parameter?

Where do I find log files?

---

<div class="post-metadata">

### Author: ![Moul](https://forum.duniter.org/user_avatar/forum.duniter.org/moul/32/9145_2.png) [@Moul](https://forum.duniter.org/u/Moul)
#### Post date: [20 November 2015 17:42 UTC](https://forum.duniter.org/t/syncing-new-node-questions-about-the-sync/563/5 "2015-11-20T17:42:06Z")

</div>

Data and blockchain are stored in `~/.config/ucoin/ucoin_default/`.  
Actually, uCoin doesn’t store logs in a file.  
But, you could store logs in a file using [`--log` pm2 parameter](https://moul.re/repo/moul/ucoin_ynh/src/master/scripts/install#L45).

---

<div class="post-metadata">

### Author: ![Sylvain](https://forum.duniter.org/user_avatar/forum.duniter.org/sylvain/32/433_2.png) [@Sylvain](https://forum.duniter.org/u/Sylvain)
#### Post date: [20 November 2015 19:27 UTC](https://forum.duniter.org/t/syncing-new-node-questions-about-the-sync/563/6 "2015-11-20T19:27:31Z")

</div>

Ah, OK. nice!

I see the CoreFS structure, a lot of inodes here. 4k each for the default ext4 partitioning. I read it was a choice to not use a alternative database for storing data, is there a discussion about that choice?

Where do the call like:

```auto
          logger.info('Sync started.');

```

are written?

```auto
var logger = require('./logger')('sync');

```

this correspond to this code:

/usr/local/lib/node\_modules/ucoin/node\_modules/log4js/lib/logger.js

probably more this one first:  
/usr/local/lib/node\_modules/ucoin/app/lib/logger.js

right?

I stop this VM, I will dig more next time, thanks for the link. I will try to read the difference in the sync algorithm from v0.11 and v0.12.

Sylvain.

---

<div class="post-metadata">

### Author: ![cgeek](https://forum.duniter.org/user_avatar/forum.duniter.org/cgeek/32/279_2.png) [@cgeek](https://forum.duniter.org/u/cgeek)
#### Post date: [21 November 2015 15:34 UTC](https://forum.duniter.org/t/syncing-new-node-questions-about-the-sync/563/7 "2015-11-21T15:34:01Z")

</div>

> [@Sylvain](#):
>
> probably more this one first:/usr/local/lib/node\_modules/ucoin/app/lib/logger.js
> 
> right?

This is the logging module, it produces loggers. So the following code:

```js
var logger = require('./logger')('sync');

```

procudes a logger that can be used for logging messages with `logger.info` for example.

Every logging message stepped through this logging module in a first place. This is a logging abstraction, actually.

> [@Sylvain](#):
>
> I stop this VM, I will dig more next time, thanks for the link. I will try to read the difference in the sync algorithm from v0.11 and v0.12.

Essentially, the algorithm changed in commit [37c25b9d](https://github.com/ucoin-io/ucoin/commit/37c25b9d8578844c7e198d345dd68175aef6724d).

To sum it up: previously, I was using the “normal” process for adding blocks ([line 125 of sync.js: method “applyGivenBlock”](https://github.com/ucoin-io/ucoin/commit/37c25b9d8578844c7e198d345dd68175aef6724d#diff-e542d7626d9e3dfa00592b40f60666edR125)) which uses the same process as a node running and receiving a new block from HTTP interface. But now, I use a shortcut method ([line 139 of sync.js: method “saveBlocksInMainBranch”](https://github.com/ucoin-io/ucoin/commit/37c25b9d8578844c7e198d345dd68175aef6724d#diff-e542d7626d9e3dfa00592b40f60666edR139)) which avoid a lot of useless treatments. That’s why it is faster: no rules checking + less treatments accessing the database.

> [@Sylvain](#):
>
> I see the CoreFS structure, a lot of inodes here. 4k each for the default ext4 partitioning. I read it was a choice to not use a alternative database for storing data, is there a discussion about that choice?

Well I do not speak that much alone, so you won’t find such a discussion 🙂 however in substance:

- I want uCoin to run on almost any computer
- I do not want users to have to install extra server databases like MySQL, MongoDB, …

So the simplest approach for me in a first place was to use simple files. It works everywhere, and FS is able to index files through directories.

However with data growing, uCoin became slower and slower so I had to look for another solution. That’s why 0.12 is now using LokiJS, an in-memory JavaScript database. It regularly persists its data on the file system too, but works exclusively in memory. This is a huge improvement in terms of performances and does not require an extra server database.

Still, almost all blocks are directly stored on the file system for archiving. Most of the time we only work with 10% of the blocks (I don’t know the exact number, we could calculate it).

You can see it & test it using DEV version (master branch).

---

<div class="post-metadata">

### Author: ![Sylvain](https://forum.duniter.org/user_avatar/forum.duniter.org/sylvain/32/433_2.png) [@Sylvain](https://forum.duniter.org/u/Sylvain)
#### Post date: [21 November 2015 17:06 UTC](https://forum.duniter.org/t/syncing-new-node-questions-about-the-sync/563/8 "2015-11-21T17:06:11Z")

</div>

Hi,

I didn’t read the logger api yet. How can I log to a file for the syncing process and see those logger messages?

[quote=“cgeek, post:7, topic:563, full:true”]That’s why it is faster: no rules checking + less treatments accessing the database.  
[/quote]

Yes, I see, thanks for the direct link it will save me some time.

> [@cgeek](#):
>
> Well I do not speak that much alone, so you won’t find such a discussion 🙂 however in substance: [was about CoreFS]
> 
> - I want uCoin to run on almost any computer
> - I do not want users to have to install extra server databases like MySQL, MongoDB, …

I’m not agree with this reasoning, but I don’t know yet enough to suggest anything better. I had to eat more code to see what you need and why you do it that way.

FS + file are consuming a lot of disk space and introduce a lot of redundancy in the records. I don’t know the data structure yet but I had a look at the blocks sub folder, I have for 41 000 records = 140 Mb of disk space, and a .tgz only 9Mb, approx values. But you get fs natural tools: grep, find, git, and more…

> [@cgeek](#):
>
> So the simplest approach for me in a first place was to use simple files. It works everywhere, and FS is able to index files through directories.

Not really, it take a bunch of disk space consuming inodes, and you have to take care of folder limitation on the FS and using “fragmentation” to store your blocks in many sub-folders to avoid folder limitation in number of file. For example…

Of course now you have programmed what database engine are performing naturally: in memory live data + persistence, transaction, replication, and more…

Once again, I need to read more code to understand your reflexion path.

Thank you, for sharing.  
Sylvain.

---

<div class="post-metadata">

### Author: ![cgeek](https://forum.duniter.org/user_avatar/forum.duniter.org/cgeek/32/279_2.png) [@cgeek](https://forum.duniter.org/u/cgeek)
#### Post date: [21 November 2015 17:25 UTC](https://forum.duniter.org/t/syncing-new-node-questions-about-the-sync/563/9 "2015-11-21T17:25:05Z")

</div>

Just to be clear for people reading us, about my position for uCoin:

- I do not pretend to make a “one-shot” software that would just work out-of-the-box for thousand years
- I do not pretend to master all the technologies I deal with, I am young and still have a lot to learn
- I did not particularly took care about optimisations in general, either that would be about:
  - disk space usage
  - memory usage
  - CPU consumption

All I want to produce is a first software that could be installed easily and allowing a first freedom money to kick off and live hundred of years. But the software does not need to be the same all the way along 🙂 I do hope it will evolve!
