mesg-foundation / engine

Build apps or autonomous workflows with reusable, shareable integrations connecting any service, app, blockchain or decentralized network.
https://mesg.com/
Apache License 2.0
130 stars 13 forks source link

Implement import and export functions in modules #1848

Closed NicolasMahe closed 4 years ago

NicolasMahe commented 4 years ago

Closes https://github.com/mesg-foundation/engine/issues/1847

This PR implements the import and export functions in modules.

To export, use the command:

mesg-daemon export

Make sure the first line returned by the command doesn't contain "WARNING: State is not initialized. Returning genesis file.". If it's the case, try to start the node and stop it mesg-daemon start. I think I have this issue because I'm running the node in docker and the cli on mac. So when I start the node on the Mac, it may resolve the issue.

To import, copy the output of previous command in the genesis.json file of a new node that doesn't have any database, start the node, and see the data are present.

antho1404 commented 4 years ago

I think the export/import should stay as close as possible to the database we use. Here we are losing the key on all export. We usually use the hash but we might change to the address or anything. We shouldn't loose this information. I would recommend to switch to a map instead of array or an array of key/value

NicolasMahe commented 4 years ago

I think the export/import should stay as close as possible to the database we use. Here we are losing the key on all export. We usually use the hash but we might change to the address or anything. We shouldn't loose this information. I would recommend to switch to a map instead of array or an array of key/value

As you say, the keys are the hash. If the data didn't contain keys, then a map can be implemented, but it's not the case. Each module can have its own export and import function, so there is no need to implement exactly the same logic everywhere.

NicolasMahe commented 4 years ago

Now the genesis contains empty array instead of null. Before:

{"instances":null}

After:

{"instances":[]}