OSDN Git Service

feat(federation): add /get-fed-info api (#228)
authorHAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
Thu, 27 Jun 2019 07:59:31 +0000 (15:59 +0800)
committerPaladz <yzhu101@uottawa.ca>
Thu, 27 Jun 2019 07:59:31 +0000 (15:59 +0800)
* fix

* add default port

* init getFedInfo

* init FedInfo struct

* clean up

* draft fed info

* clean up

* cealn

* cealn

* fix

docs/federation/README-en.md
docs/federation/federation.sql
federation/api/server.go
federation/config/config.go

index 0b82b77..982a0a7 100644 (file)
@@ -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
 {
index 6e95bf2..38d8107 100644 (file)
@@ -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;
index 330b1de..9b01e93 100644 (file)
@@ -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 {
index 358eee5..52568dc 100644 (file)
@@ -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 {