go-streamnet

command module
v0.0.0-...-e899ace Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

README

go-streamnet

StreamNet implemented in Golang.

Modules

  • config: parsing the configuration file.
  • dag: the dag structure and methods.
  • streamwork: the algorithm to 'drag' DAG to chain.
  • tipselection: selecting two tips from dag.
  • server: the http server.
  • store: the storage module.
  • forward: the genesis forward module.
  • network: the network module, for broadcasting and synchronization.
  • docs: documents.
  • examples: all the tests and examples.
  • types: all the common types.
  • utils: all common libs.
  • commands: parsing all subcommands.

Install

From Binary

(not supported yet)

From Source
prerequisite
Ubuntu

You'll need [gorocksdb][redis] installed first.

Get Source Code
mkdir -p $GOPATH/src/github.com/triasteam
cd $GOPATH/src/github.com/triasteam
git clone https://github.com/triasteam/go-streamnet.git
cd go-streamnet
Compile
go build -o main .

This will generate a executable file, named by -o param. . stands for current directory, therefore, you should execute the command above in go-streamnet project root directory.

MacOS
dependencies
  • RocksDb
    $ brew install rocksdb
    
Get Source Code
mkdir -p $GOPATH/src/github.com/triasteam
cd $GOPATH/src/github.com/triasteam
git clone https://github.com/triasteam/go-streamnet.git
cd go-streamnet
Compile
go build -o main .

This will generate a executable file, named by -o param. . stands for current directory, therefore, you should execute the command above in go-streamnet project root directory.

Run

  • first, let us see while parameters can be used to execute this command.
**NAME**
  main -- go-stream project name specified by -o param, while can be to any symbol, change whatever you want.
**SYNOPSIS**
  ./main [-seed] [-port port] [-relaytype autorelay/hop] [-paddr publicAddress]
**DESCRIPTION**
  The main command is used to startup a go-streamnet node. It can be a single host, or a relay hop providing public access channel for nodes hiding the NAT. Multiple nodes defining by this way can form a gossip network. 
  -seed: Specify a node as seed node. If you want to join a network, this param is required.

  -port: Default 45759 for node rcp service, can be changed to any other number.

  -relaytype: If autorelay service is neccessary, this argument is required. Node can choose a identify of autorelay and hop, and only one of them can be seleced. Note that a hop must have a public address.(If deploy you app using docker, /dns4/localhost is used as a hop address.

  -paddr Means public address for node while it launching in internet environment.

  • Start on the same intranet segment
    One of the nodes run
    ./main
    
    Other nodes
    ./main -seed /ip4/ipaddress/tcp/port/p2p/peerid
    
    ipaddresss is the first run nodes's intranet ipaddress,port and peerid is Automatically generated in the first node run. The address can be found in startup log, and you should replace 127.0.0.1 to actural ip/dns address.
  • Start by relay
    first, a hop should be started, which can be specified by -relaytype hot. A hop node is not suggested launching as a seed, for the advising server limited. The hop node will advise it's autorelay protocol only once after start of few minutes. If there is no connection, advising will failed and no one knowns it's a relay hop.
    ./main  -seed /ip4/192.168.50.102/tcp/45759/p2p/Qmxxx -relaytype hop
    
    Second, start a node need relay.
    ./main  -seed /ip4/192.168.50.102/tcp/45759/p2p/Qmxxx -relaytype autorelay
    
    other situations, rcp port and public address can be specefied, but it is not required in LAN.
    ./main  -seed /ip4/192.168.50.102/tcp/45759/p2p/Qmxxx -relaytype autorelay -port 10001 -paddr 10.1.12.12
    

Note: Now you should start another terminal to input commands, or you can start the binary background with '&'.

Client save & get

A go-streamnet provides http server by fixed port 14700.

save
curl -X POST -d '{"Attester": "192.168.1.1", "Attestee": "192.168.1.2", "Score": "1"}' http://127.0.0.1:14700/save
query
curl -s -X POST http://127.0.0.1:14700/QueryNodes -d "{\"period\":1,\"numRank\":100}"
get
curl -X POST -d '{"key": "0xXXXXXXXXXXX"}' http://127.0.0.1:14700/get

For better display, you can use jq to format the output.

Documentation

Overview

Package main

Directories

Path Synopsis
abci
Package dag provides graph storage.
Package dag provides graph storage.
examples
cli
libp2p/chat-with-mdns
Package chat-with-dns represent a demo for usage of mdns flag contains startup argument for this demo Package chat-with-dns represent a demo for usage of mdns mdns implements the mdns protocol for the demo
Package chat-with-dns represent a demo for usage of mdns flag contains startup argument for this demo Package chat-with-dns represent a demo for usage of mdns mdns implements the mdns protocol for the demo
libp2p/go-libp2p-chat
* * The MIT License (MIT) * * Copyright (c) 2014 Juan Batiz-Benet * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software.
* * The MIT License (MIT) * * Copyright (c) 2014 Juan Batiz-Benet * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software.
libp2p/pubsub
* * The MIT License (MIT) * * Copyright (c) 2014 Juan Batiz-Benet * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software.
* * The MIT License (MIT) * * Copyright (c) 2014 Juan Batiz-Benet * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software.
libp2p/relay-demo
* * The MIT License (MIT) * * Copyright (c) 2014 Juan Batiz-Benet * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software.
* * The MIT License (MIT) * * Copyright (c) 2014 Juan Batiz-Benet * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software.
network
v1
Package network is now deprecated, more to networkv2 Package network is now deprecated, more to networkv2 Package network is now deprecated, more to networkv2 Package network is now deprecated, more to networkv2 Package network is now deprecated, more to networkv2
Package network is now deprecated, more to networkv2 Package network is now deprecated, more to networkv2 Package network is now deprecated, more to networkv2 Package network is now deprecated, more to networkv2 Package network is now deprecated, more to networkv2
v2
Package networkv2 is an upgraded version of the networkv1, and provides basic network layer components.
Package networkv2 is an upgraded version of the networkv1, and provides basic network layer components.
Package pagerank implements the *weighted* PageRank algorithm.
Package pagerank implements the *weighted* PageRank algorithm.
scripts
relay Module
Package server contain all thing of http server
Package server contain all thing of http server
Package utils contains math utils.
Package utils contains math utils.
crypto/merkle
Package merkle computes a deterministic minimal height Merkle tree hash.
Package merkle computes a deterministic minimal height Merkle tree hash.
crypto/secp256k1/internal/secp256k1
nolint:gocritic Package secp256k1 wraps the bitcoin secp256k1 C library.
nolint:gocritic Package secp256k1 wraps the bitcoin secp256k1 C library.
crypto/xchacha20poly1305
Package xchacha20poly1305 creates an AEAD using hchacha, chacha, and poly1305 This allows for randomized nonces to be used in conjunction with chacha.
Package xchacha20poly1305 creates an AEAD using hchacha, chacha, and poly1305 This allows for randomized nonces to be used in conjunction with chacha.
hash
Package hash contains interface for hash.
Package hash contains interface for hash.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL