From: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Date: Thu, 27 Jun 2019 07:59:31 +0000 (+0800) Subject: feat(federation): add /get-fed-info api (#228) X-Git-Tag: v1.0.5~191 X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=commitdiff_plain;h=118be2d8b20b623c392c7612a5f5d3c8a3a26091 feat(federation): add /get-fed-info api (#228) * fix * add default port * init getFedInfo * init FedInfo struct * clean up * draft fed info * clean up * cealn * cealn * fix --- diff --git a/docs/federation/README-en.md b/docs/federation/README-en.md index 0b82b772..982a0a7b 100644 --- a/docs/federation/README-en.md +++ b/docs/federation/README-en.md @@ -5,14 +5,13 @@ To run a federation node, you will need to: 1. init a MySQL database with this [schema](./federation.sql); 2. run a `bytomd` node; 3. run a `vapord` node and import the federation private key; -4. and last but not least, run a `fedd` node with a `fed_cfg.json`. +4. and last but not least, run a `fedd` node with a `fed_cfg.json` and it will listen at 9886 port. A `fed_cfg.json` would look like this: ```json { "api" : { - "listening_port" : 3000, "is_release_mode": false }, "mysql" : { @@ -127,7 +126,7 @@ Optional: ```js // Request -curl -X POST 127.0.0.1:3000/api/v1/federation/list-crosschain-txs -d '{}' +curl -X POST 127.0.0.1:9886/api/v1/federation/list-crosschain-txs -d '{}' // Result { diff --git a/docs/federation/federation.sql b/docs/federation/federation.sql index 6e95bf29..38d8107a 100644 --- a/docs/federation/federation.sql +++ b/docs/federation/federation.sql @@ -25,7 +25,7 @@ CREATE TABLE `chains` ( `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`), - UNIQUE KEY `block_hash` (`block_hash`) + UNIQUE KEY `block_hash` (`id`,`block_hash`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; LOCK TABLES `chains` WRITE; diff --git a/federation/api/server.go b/federation/api/server.go index 330b1de0..9b01e930 100644 --- a/federation/api/server.go +++ b/federation/api/server.go @@ -2,7 +2,6 @@ package api import ( "encoding/json" - "fmt" "net/http" "reflect" "strings" @@ -43,7 +42,7 @@ func (server *Server) setupRouter() { } func (s *Server) Run() { - s.engine.Run(fmt.Sprintf(":%d", s.cfg.API.ListeningPort)) + s.engine.Run(":9886") } func (s *Server) middleware() gin.HandlerFunc { diff --git a/federation/config/config.go b/federation/config/config.go index 358eee52..52568dc2 100644 --- a/federation/config/config.go +++ b/federation/config/config.go @@ -42,8 +42,7 @@ type Config struct { } type API struct { - ListeningPort uint64 `json:"listening_port"` - IsReleaseMode bool `json:"is_release_mode"` + IsReleaseMode bool `json:"is_release_mode"` } type MySQLConfig struct {