Code Monkey home page Code Monkey logo

flowchain-ledger's Introduction

Flowchain-app is an ultra light-weight runtime for flow-based IoT programming.

Flowchain

You can write IoT server, serverless server or localhost server with Flowchain in flow-based programming.

In the flowchain-app, IoT applications are described by a Graph in the JSON format. Flowchain-app can execute the graph as a service process (server) on various hardware, e.g., resource-constrained devices, single-board computers and desktops.

Usage

A easy way to start using flowchain-app is trying console.json.

$ git clone https://github.com/flowchain/flowchain.git
$ cd flowchain
$ npm install
$ export HOST=192.168.0.100
$ ./bin/init.js start graphs/console.json 
[devify] Starting coapBroker server...
WoT/CoAP server is listening at coap://192.168.0.100:8000

Flowchain-app is now listening at the host assigned by HOST environment variable. You can also export the PORT variable to specify the listening port.

Programing IoT device

It is out of scope of flowchain-app. However, there is an example showing a sample in which send sensor data to flowchain-app over CoAP. The following example uses a NodeMCU (aka ESP8266) device with Lua programming language.

-- Configure the ESP as a station (client)
wifi.setmode(wifi.STATION)  
wifi.sta.config("<SSID>", "<PASSWORD>")  
wifi.sta.autoconnect(1)

-- Create a CoAP client
cc = coap.Client()

-- Make a POST request
uri="coap://192.168.0.100:8000/object/12345678/send"

-- Setup a timer to send ADC data
tmr.alarm(0, 1000, 1, function() 
    buf = 
          "{" ..
          "\"quality\":" ..
          adc.read(0) ..
          "}"
    
    cc:post(uri, buf)
    print(buf)
end)

Programming Paradigm

Graph

Flowchain-app will execute the console.json file. The console.json is a sample graph described in JSON format.

{
    "author": "jollen",
    "type": "coapBroker",
    "connections": [
        {
            "upproc": "io.flowchain.console",
            "upport": "out",
            "downproc": "io.flowchain.fs",
            "downport": "in"
        }
    ]
}

The visual graph diagram is also shown as following.

Component

Flowchain-app components could be published as npm modules. One existing component is io.flowchain.console and accessible at io.flowchain.console.

Development Notes

Write Your Graph

There are several flowchain graph examples.

Add a New Component

  1. To develop custom components, please fork this example io.flowchain.console.

  2. Publish your component to npm.

  3. Update package.json by npm install <your-package> --save.

  4. Open lib/main.js file and require (include) your component into flowchain.

var components =[
  ...
  require('io.flowchain.console')
];

You could send a PR to flowchain. All flowchain-app components will also be listed at the flowchain.io website.

Why and What

  • Instead of the classical monolithic application programming model. Flowchain-app is the flow-based programming.

  • Flowchain-app is a flow-based runtime for JavaScript IoT application server.

  • Flowchain-app is a better approach to write IoT application servers.

  • Flowchain-app is based on devify-server.

  • Flowchain-app is one-way data flow design.

Internals

  • Flowchain-app has a ultra-lightweight flow-based runtime called fb0. fb0 is tiny with 300+ lines code.

  • Flowchain-app has CoAP/WebSocket URI-based protocol servers for interoperating with IoT devices.

Credits

Flowchain-app project is heavily inspired by J. Paul Morrison and FBP-like NoFlo.

fb0 is a FBP-like system and is a JavaScript system motivated by J. Paul Morrison, and which uses a number of the same terms and concepts.

Roadmap

  • [2017] Building flowchain-app on JerryScript, an ultra-lightweight JavaScript engine for the Internet of Things.

  • [2017] React component binding with state stores and Flux pattern.

  • [2017] Serverless IoT in a simpilicy way.

License

Flowchain-app is released under the MIT License.

flowchain-ledger's People

Contributors

dependabot[bot] avatar jollen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flowchain-ledger's Issues

How to send data back as acknowledgement

Hello,

I recently run the examples that are described at wiki (https://github.com/flowchain/flowchain-ledger/wiki) and all works fine. I was wondering if it's possible to send an acknowledgement inside onmessage event callback in peer.js file. I am running a slightly modified version of this example: https://github.com/flowchain/flowchain-ledger/wiki/3.-Send-IoT-Data-to-the-P2P-Network an i want after each message send and received by peer to send the ack.

Thanks in advance!

Consensus systems

I see that you've started on a new consensus system. How can I use that?

[0330Lab]0x54a735f7c273bd6926ce8ef14da4dd711bc53f9c

{
"address": "0x54a735f7c273bd6926ce8ef14da4dd711bc53f9c",
"msg": "[Flowchain.io 13A396F776 0x54a735f7c273bd6926ce8ef14da4dd711bc53f9c]",
"sig": "0x1c163c16dba00351c9aa9c489f650791343f839e9154ee70606873a73b5673ff307cf50c24902d1c25a03e8e765b4d6e86d7ea6600e9436cc21d58351f9f9da21b",
"version": "2"
}

Transaction data

I've followed the steps to run the boot node and a few peer nodes and send transaction data to the nodes. I'm trying to understand how I can get the data out of the blocks and how to connect an endpoint (as described in the whitepaper) that will receive the validated transactions to do further processing.

Help

Hello
I have problem which file I wil use to start the flowchian ledger , there are many file like , p2p , consensus , nodes and so else ,,, i was try the commands but it not works I hope anyone can help me to fix the problem basically the issues how can i run the flowchain ledger a

Warm regards
Mohammed

Cannot find module 'flowchain-ledger'

I got an issue in command node boot.js

module.js:472
    throw err;
    ^

Error: Cannot find module 'flowchain-ledger'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/kwangin/workspace/github_source/flowchain-ledger/boot.js:1:79)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)

It looks like path of package at var Flowchain = require('flowchain-ledger');. need to be changed, but I could'nt find this package inside project.
Please look on.

How to start the debug server

Use of Debug Tool

The flowchain-sim project is a conveient tool that you can debug flowchain-ledger by watching the activities of the underlying p2p networking. Please start the debug tool flowchain-sim, and use the DEBUGSERVER and DEBUGSERVER_PORT environment variables:

$ export HOST=192.168.1.2           ; Peer Node (My IP address)
$ export PORT=8001                  ; Peer Node (My listening port)
$ export PEER_ADDR=192.168.1.1      ; Boot Node (The node intend to join)
$ export PEER_PORT=8000             ; Boot Node (The node intend to join)
$ export DEBUGSERVER=192.168.1.100  ; The debug server IP address (Optional)
$ export DEBUGSERVER_PORT=9000 	    ; The debug server listening port number (Optional)
$ node peer.js                      ; Start the new peer node

ReferenceError: db is not defined

I found bug like below while running boot.js.

...
----------------------
[Blockchain] no usable block now, data is ignored.
predecessor_ttl = 3
predecessor_ttl = 2
successor_ttl = 6
[Blockchain] no usable block now, data is ignored.
predecessor_ttl = 1
predecessor_ttl = 6
Difficulty: 00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Block #1: 0078ff4ec5677a2749e99d1f39d74c6dbf7eea39cdab571c6f845ad9a9afb30b
----------------------
successor: {"address":"localhost","port":8000,"id":"e7ff381eba983a99c2489e7eeb7424b2df9347dc"}
predecessor: null
----------------------
ReferenceError: db is not defined
    at Object.onmessage (/Users/kwangin/workspace/flowchain-ledger/boot.js:56:5)
    at Automation.Server.onData (/Users/kwangin/workspace/flowchain-ledger/server/index.js:239:26)
    at emitOne (events.js:115:13)
    at WebsocketBroker.emit (events.js:210:7)
    at WebSocketConnection.onWsConnMessage (/Users/kwangin/workspace/flowchain-ledger/wot/broker.js:177:10)
    at emitOne (events.js:115:13)
    at WebSocketConnection.emit (events.js:210:7)
    at WebSocketConnection.processFrame (/Users/kwangin/workspace/flowchain-ledger/node_modules/websocket/lib/WebSocketConnection.js:547:26)
    at /Users/kwangin/workspace/flowchain-ledger/node_modules/websocket/lib/WebSocketConnection.js:321:40
    at _combinedTickCallback (internal/process/next_tick.js:95:7)

Inside the code, I couldn't find db variable.
Could you look on?

What is finger table and chord ring?

Hello.
I'm looking on current code, and cannot understand some part in boot.
What does 'finger table' and 'chord ring' means? Can I find it on your paper?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.