Official golang implementation of the Insight Chain
First, you need both a Go (version 1.10 or later) and a C compiler.
make ginb
or, to build the full suite of utilities:
make all
Going through all the possible command line flags is out of scope here ,but we've enumerated a few common parameter combos to get you up to speed quicklyon how you can run your own ginb
instance.
By far the most common scenario is people wanting to simply interact with the INBnetwork: create accounts; transfer funds; Mortgage or release; deploy and interact with contracts. For thisparticular use-case the user doesn't care about years-old historical data, so we canfast-sync quickly to the current state of the network. To do so:
$ ginb console
If you want to be a supernode and have the right to mine, you have to get someone else's vote in advance and only the 21 nodes with the highest number of votes have the chance.
If you meet the above conditions, please continue.
You need to make your nodeid before you start the network.
$ ginb nodekey [datadir]
The returned nodeid (as enodes.id) needs to be configured in the genesis.json file, as well as your ip, port, name, country and so on.Data provide some other K-V information if you want to store
{
"config": {
"chainId": 891,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"vdpos": {
"period": 3,
"signerPeriod": 3,
"signerBlocks": 6,
"epoch": 201600,
"maxSignersCount": 21,
"minVoterBalance": 1000000000000000000,
"genesisTimestamp": 1561544470,
"signers": [
"0x891b2388ce73356917b21ca54f3039cbdfc29313",
"0x4643ce2d6d4fe02e2b57070806364dde9eb8cac9",
"0x230cf5081833c4f16e69e102ea00a4583a33cb11"
],
"enodes":[
{"address":"0x891b2388ce73356917b21ca54f3039cbdfc29313",
"id":"327d1a41974ad0a672d9b3dcfada5a934b4c21207e95a40d534bde44c2f7b39c4f10dda7a7bc060c00868a77b522878ab960dff2f23f463616736a1e6e39ea93",
"ip":"192.168.1.181",
"port":"30001",
"name":"inb",
"nation":"China",
"city":"beijing",
"image":"www.image.com",
"website":"www.insightchain.io",
"email":"insightchain@xx.com",
"data":"{\"hobby\":\"money\",\"age\":\"21\"}"},
{"address":"0x891b2388ce73356917b21ca54f3039cbdfc29313",
"id":"327d1a41974ad0a672d9b3dcfada5a934b4c21207e95a40d534bde44c2f7b39c4f10dda7a7bc060c00868a77b522878ab960dff2f23f463616736a1e6e39ea93",
"ip":"192.168.1.181",
"port":"30001",
"name":"inb",
"nation":"China",
"city":"beijing",
"image":"www.image.com",
"website":"www.insightchain.io",
"email":"insightchain@xx.com",
"data":"{\"hobby\":\"money\",\"age\":\"21\"}"},
{"address":"0x891b2388ce73356917b21ca54f3039cbdfc29313",
"id":"327d1a41974ad0a672d9b3dcfada5a934b4c21207e95a40d534bde44c2f7b39c4f10dda7a7bc060c00868a77b522878ab960dff2f23f463616736a1e6e39ea93",
"ip":"192.168.1.181",
"port":"30001",
"name":"inb",
"nation":"China",
"city":"beijing",
"image":"www.image.com",
"website":"www.insightchain.io",
"email":"insightchain@xx.com",
"data":"{\"hobby\":\"money\",\"age\":\"21\"}"},
]
}
},
"coinbase": "0x0000000000000000000000000000000000000000",
"difficulty": "0x1",
"extraData": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x2fefd8",
"nonce": "0x0",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": "0x00",
"alloc": {
"891b2388ce73356917b21ca54f3039cbdfc29313": {
"balance": "0"
},
"4643ce2d6d4fe02e2b57070806364dde9eb8cac9": {
"balance": "0"
},
"230cf5081833c4f16e69e102ea00a4583a33cb11": {
"balance": "0"
}
}
}
Vdpos is necessary. Period represents the number of seconds between blocks, signerPeriod represents the number of seconds blocks between two super nodes, signerBlocks represents the number of packaged blocks per super node, epoch represents the interval between emptying voting information and re-voting, and maxSignersCount represents the maximum number of super nodes.Enodes represents information about all super nodes that were first voted for and everyone automatically connects to the supernodes' networks.
Tip:Then everyone initializes the Genesis Block with the same set of genesis.json files
$ ginb init path/to/genesis.json
Finally start the network
$ ginb --datadir data1/ --networkid 891 --nodiscover --rpcport 6002 --port 30002 console
Transitioning towards developers, if you'd like to play around with creating INBcontracts, you almost certainly would like to do that without any real money involved untilyou get the hang of the entire system. In other words, instead of attaching to the mainnetwork, you want to join the test network with your node, which is fully equivalent tothe main network, but with play-inber only.
$ ginb --testnet console
The console
subcommand has the exact same meaning as above and they are equallyuseful on the testnet too. Please see above for their explanations if you've skipped here.
Specifying the --testnet
flag, however, will reconfigure your ginb
instance a bit:
~/.inb
on Linux for example), ginb
will nest itself one level deeper into a testnet
subfolder (~/.inb/testnet
onLinux). Note, on OSX and Linux this also means that attaching to a running testnet noderequires the use of a custom endpoint since ginb attach
will try to attach to aproduction node endpoint by default. E.g.ginb attach <datadir>/testnet/ginb.ipc
. Windows users are not affected bythis.Note: Although there are some internal protective measures to prevent transactions fromcrossing over between the main network and test network, you should make sure to alwaysuse separate accounts for play-money and real-money. Unless you manually moveaccounts, ginb
will by default correctly separate the two networks and will not make anyaccounts available between them.
### Configuration
As an alternative to passing the numerous flags to the `ginb` binary, you can also pass a
configuration file via:
```shell
$ geinb --config /path/to/your_config.toml
To get an idea how the file should look like you can use the dumpconfig
subcommand toexport your existing configuration:
$ ginb --your-favourite-flags dumpconfig
ginb
nodesAs a developer, sooner rather than later you'll want to start interacting with ginb
and theInsight network via your own programs and not manually through the console. To aidthis, ginb
has built-in support for a JSON-RPC based APIsand [ginb
specific APIs]These can be exposed via HTTP, WebSockets and IPC (UNIX sockets on UNIX basedplatforms, and named pipes on Windows).
The IPC interface is enabled by default and exposes all the APIs supported by ginb
,whereas the HTTP and WS interfaces need to manually be enabled and only expose asubset of APIs due to security reasons. These can be turned on/off and configured asyou'd expect.
HTTP based JSON-RPC API options:
--rpc
Enable the HTTP-RPC server--rpcaddr
HTTP-RPC server listening interface (default: localhost
)--rpcport
HTTP-RPC server listening port (default: 8545
)--rpcapi
API's offered over the HTTP-RPC interface (default: inb,net,web3
)--rpccorsdomain
Comma separated list of domains from which to accept cross origin requests (browser enforced)--ws
Enable the WS-RPC server--wsaddr
WS-RPC server listening interface (default: localhost
)--wsport
WS-RPC server listening port (default: 8546
)--wsapi
API's offered over the WS-RPC interface (default: inb,net,web3
)--wsorigins
Origins from which to accept websockets requests--ipcdisable
Disable the IPC-RPC server--ipcapi
API's offered over the IPC-RPC interface (default: admin,debug,inb.vdpos,miner,net,personal,shh,txpool,web3
)--ipcpath
Filename for IPC socket/pipe within the datadir (explicit paths escape it)You'll need to use your own programming environments' capabilities (libraries, tools, etc) toconnect via HTTP, WS or IPC to a ginb
node configured with the above flags and you'llneed to speak JSON-RPC on all transports. Youcan reuse the same connection for multiple requests!
Note: Please understand the security implications of opening up an HTTP/WS basedtransport before doing so! Hackers on the internet are actively trying to subvertInsight nodes with exposed APIs! Further, all browser tabs can access locallyrunning web servers, so malicious web pages could try to subvert locally availableAPIs!
Maintaining your own private network is more involved as a lot of configurations taken forgranted in the official networks need to be manually set up.
First, you'll need to create the genesis state of your networks, which all nodes need to beaware of and agree upon. This consists of a small JSON file (e.g. call it genesis.json
):
{
"config": {
"chainId": 891,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"vdpos": {
"period": 3,
"signerPeriod": 3,
"signerBlocks": 6,
"epoch": 201600,
"maxSignersCount": 21,
"minVoterBalance": 1000000000000000000,
"genesisTimestamp": 1561544470,
"signers": [
"0x891b2388ce73356917b21ca54f3039cbdfc29313",
"0x4643ce2d6d4fe02e2b57070806364dde9eb8cac9",
"0x230cf5081833c4f16e69e102ea00a4583a33cb11"
],
"enodes":[
{"address":"0x891b2388ce73356917b21ca54f3039cbdfc29313",
"id":"327d1a41974ad0a672d9b3dcfada5a934b4c21207e95a40d534bde44c2f7b39c4f10dda7a7bc060c00868a77b522878ab960dff2f23f463616736a1e6e39ea93",
"ip":"192.168.1.181",
"port":"30001",
"name":"inb",
"nation":"China",
"city":"beijing",
"image":"www.image.com",
"website":"www.insightchain.io",
"email":"insightchain@xx.com",
"data":"{\"hobby\":\"money\",\"age\":\"21\"}"},
{"address":"0x891b2388ce73356917b21ca54f3039cbdfc29313",
"id":"327d1a41974ad0a672d9b3dcfada5a934b4c21207e95a40d534bde44c2f7b39c4f10dda7a7bc060c00868a77b522878ab960dff2f23f463616736a1e6e39ea93",
"ip":"192.168.1.181",
"port":"30001",
"name":"inb",
"nation":"China",
"city":"beijing",
"image":"www.image.com",
"website":"www.insightchain.io",
"email":"insightchain@xx.com",
"data":"{\"hobby\":\"money\",\"age\":\"21\"}"},
{"address":"0x891b2388ce73356917b21ca54f3039cbdfc29313",
"id":"327d1a41974ad0a672d9b3dcfada5a934b4c21207e95a40d534bde44c2f7b39c4f10dda7a7bc060c00868a77b522878ab960dff2f23f463616736a1e6e39ea93",
"ip":"192.168.1.181",
"port":"30001",
"name":"inb",
"nation":"China",
"city":"beijing",
"image":"www.image.com",
"website":"www.insightchain.io",
"email":"insightchain@xx.com",
"data":"{\"hobby\":\"money\",\"age\":\"21\"}"},
]
}
The above fields should be fine for most purposes, although we'd recommend changingthe nonce
to some random value so you prevent unknown remote nodes from being ableto connect to you. If you'd like to pre-fund some accounts for easier testing, you canpopulate the alloc
field with account configs:
"alloc": {
"0x0000000000000000000000000000000000000001": {
"balance": "111111111"
},
"0x0000000000000000000000000000000000000002": {
"balance": "222222222"
}
}
With the genesis state defined in the above JSON file, you'll need to initialize everyginb
node with it prior to starting it up to ensure all blockchain parameters are correctlyset:
$ ginb init path/to/genesis.json
With all nodes that you want to run initialized to the desired genesis state, you'll need tostart a bootstrap node that others can use to find each other in your network and/or overthe internet. The clean way is to configure and run a dedicated bootnode:
$ bootnode --genkey=boot.key
$ bootnode --nodekey=boot.key
Note: You could also use a full-fledged ginb
node as a bootnode, but it's the lessrecommended way.
With the bootnode operational and externally reachable (you can trytelnet <ip> <port>
to ensure it's indeed reachable), start every subsequent ginb
node pointed to the bootnode for peer discovery via the --bootnodes
flag. It willprobably also be desirable to keep the data directory of your private network separated, sodo also specify a custom --datadir
flag.
$ ginb --datadir=path/to/custom/data/folder --bootnodes=<bootnode-enode-url-from-above>
Note: Since your network will be completely cut off from the main and test networks, you'llalso need to configure a miner to process transactions and create new blocks for you.
Mining on the public Insight network is a complex task as it's only feasible using GPUs,requiring an OpenCL or CUDA enabled inbminer
instance. For information on such asetup
In a private network setting, however a single CPU miner instance is more than enough forpractical purposes as it can produce a stable stream of blocks at the correct intervalswithout needing heavy resources (consider running on a single thread, no need for multipleones either). To start a ginb
instance for mining, run it with all your usual flags, extendedby:
$ ginb <usual-flags> --mine --minerthreads=1 --inberbase=0x0000000000000000000000000000000000000000
生命不止,继续go go go !!! 之前介绍过golang中restful api的博客,是使用redis作为持久化,httprouter作为框架: Go实战–通过httprouter和redis框架搭建restful api服务(github.com/julienschmidt/httprouter) 今天,继续echo框架,这次加入mongodb作为持久化存储,使用jwt进行验证,来搭建一
我把libvirt-go源码中的domain翻了一遍,找到一下全部能够get到的内容,但是具体每个的get操作我只尝试了几个。先mark下吧。每条中的url是libvirt-go对应libvirt的c版本的api文档,go并没有文档,所以需要自己去手动对应。 1. 虚拟cpu信息: a) Extract information about virtual CPUs of domain。 b)
错误表示 需要升级 ❯ sudo apt list --upgradable Listing... Done golang-1.13-go/focal-updates,focal-security 1.13.8-1ubuntu1.1 amd64 [upgradable from: 1.13.8-1ubuntu1] 升级时存在依赖错误 ❯ sudo apt upgrade golang-1.13-
问题内容: 拖放文件上传可以在Firefox 3.6中完成。 通过Google搜索 html5拖放文件上传- gmail,可以看到以下 内容: http://www.appelsiini.net/2009/10/html5-drag-and-drop-multiple-file-upload http://www.thecssninja.com/javascript/drag-and-drop-u
问题内容: 我有一个使用Google Maps API来显示地图的页面。当我直接加载页面时,地图出现。但是,当我尝试使用AJAX加载页面时,出现错误: 为什么是这样? 这是带有地图的页面: 这是带有AJAX调用的页面: 谢谢你的帮助。 问题答案: 默认情况下,文档完成加载后无法加载该API,您需要异步加载该API。 用地图修改页面:
问题内容: 这是Google BigQuery中多级数据透视表的后续问题,我想知道是否可以使用单个查询在GoogleBigQuery中构造嵌套数据透视表。是的,因此在这个后续问题中,我想探讨一下一般情况。 这是我正在使用的数据的示例(此共享Google表格中也包含该数据) 现在,我想构建一个具有以下属性的数据透视表: 行级和列级的嵌套级(上一个问题只有嵌套级) 行和列中的小计(前一个只有总计) 多
问题内容: 如何通过App Engine的URLFetch服务(在Java中)指定用于发出基本身份验证请求的用户名和密码? 看来我可以设置HTTP标头: Basic-Auth的适当标题是什么? 问题答案: 这是HTTP上的基本身份验证标头: 授权:基本的base64编码(用户名:password) 例如: 您将需要执行以下操作: 为此,您将需要一个base64编解码器api,例如Apache Co
问题内容: 我正在使用Java和XStream通过http解析Google地理编码请求。我的想法是拥有一个具有所有地理编码属性(例如纬度/经度,城市,省/州等)的Address类,但是我在使用xstream解析xml时遇到了问题。 Google的回应与此类似: 不能很好地显示出来,但是代码的内容在AddressDetails标记中。 无论如何,我是Java和XStream的新手,所以API术语对我
问题内容: 我正在学习Google Guice。您知道如何解决“机器人腿”问题吗?让我用一个例子解释一下。 假设我有一个叫做的类: 该接口有两种实现: 我的模块是这样实现的: 好吧,我想知道这是否可能: 是否存在一些让我做到这一点的注释或绑定,让我对like这样的成员进行注释,这有助于Guice知道应该向内部注入实现? 编辑: 感谢丹尼尔·马丁(Daniel Martin)在他的评论中给我们提供了