From 06ef734c63ffb71fd303eb0422239e7681ce3346 Mon Sep 17 00:00:00 2001 From: programmer10110 Date: Thu, 30 Jul 2020 18:09:13 +0300 Subject: [PATCH 1/4] WIP: http server for client --- client/client.go | 4 +- client/client_test.go | 8 +- client/http_server.go | 109 ++++++++++++++++++ client/state_test.go | 2 +- fsm/cmd/test/test.go | 4 +- fsm/fsm_pool/fsm_pool.go | 2 +- fsm/state_machines/provider.go | 10 +- .../signature_construct_fsm/init.go | 4 +- .../signature_proposal_fsm/actions.go | 6 +- .../signature_proposal_fsm/helpers.go | 4 +- .../signature_proposal_fsm/init.go | 4 +- fsm/types/requests/signature_proposal.go | 2 +- go.mod | 2 +- main.go | 2 +- mocks/clientMocks/state_mock.go | 2 +- mocks/storageMocks/storage_mock.go | 2 +- qr/qr.go | 11 ++ 17 files changed, 149 insertions(+), 29 deletions(-) create mode 100644 client/http_server.go diff --git a/client/client.go b/client/client.go index 66407b4..869f0bc 100644 --- a/client/client.go +++ b/client/client.go @@ -8,8 +8,8 @@ import ( "path/filepath" "time" - "github.com/p2p-org/dc4bc/qr" - "github.com/p2p-org/dc4bc/storage" + "github.com/depool/dc4bc/qr" + "github.com/depool/dc4bc/storage" ) const ( diff --git a/client/client_test.go b/client/client_test.go index e9eca34..3703941 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -9,13 +9,13 @@ import ( "testing" "time" - "github.com/p2p-org/dc4bc/mocks/qrMocks" + "github.com/depool/dc4bc/mocks/qrMocks" - "github.com/p2p-org/dc4bc/client" + "github.com/depool/dc4bc/client" + "github.com/depool/dc4bc/mocks/clientMocks" + "github.com/depool/dc4bc/mocks/storageMocks" "github.com/golang/mock/gomock" - "github.com/p2p-org/dc4bc/mocks/clientMocks" - "github.com/p2p-org/dc4bc/mocks/storageMocks" "github.com/stretchr/testify/require" ) diff --git a/client/http_server.go b/client/http_server.go new file mode 100644 index 0000000..665a8b8 --- /dev/null +++ b/client/http_server.go @@ -0,0 +1,109 @@ +package client + +import ( + "encoding/json" + "fmt" + "github.com/depool/dc4bc/storage" + "io/ioutil" + "log" + "net/http" +) + +func errorResponse(w http.ResponseWriter, statusCode int, err string) { + log.Println(err) + w.WriteHeader(statusCode) + if _, err := w.Write([]byte(err)); err != nil { + panic(fmt.Sprintf("failed to write response: %v", err)) + } +} + +func successResponse(w http.ResponseWriter, response []byte) { + if _, err := w.Write(response); err != nil { + panic(fmt.Sprintf("failed to write response: %v", err)) + } +} + +func (c *Client) StartHTTPServer(listenAddr string) error { + http.HandleFunc("/sendMessage", c.sendMessageHandler) + http.HandleFunc("/getOperations", c.getOperationsHandler) + http.HandleFunc("/getOperationQRPath", c.getOperationQRPathHandler) + http.HandleFunc("/readProcessedOperationFromCamera", c.readProcessedOperationFromCameraHandler) + return http.ListenAndServe(listenAddr, nil) +} + +func (c *Client) sendMessageHandler(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodPost { + errorResponse(w, http.StatusBadRequest, "Wrong HTTP method") + return + } + reqBytes, err := ioutil.ReadAll(r.Body) + if err != nil { + errorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to read request body: %v", err)) + return + } + + var msg storage.Message + if err = json.Unmarshal(reqBytes, &msg); err != nil { + errorResponse(w, http.StatusInternalServerError, fmt.Sprintf("failed to unmarshal message: %v", err)) + return + } + + if err = c.SendMessage(msg); err != nil { + errorResponse(w, http.StatusInternalServerError, fmt.Sprintf("failed to send message to the storage: %v", err)) + return + } + + successResponse(w, []byte("ok")) +} + +func (c *Client) getOperationsHandler(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodGet { + errorResponse(w, http.StatusBadRequest, "Wrong HTTP method") + return + } + + operations, err := c.GetOperations() + if err != nil { + errorResponse(w, http.StatusInternalServerError, fmt.Sprintf("failed to get operations: %v", err)) + return + } + + response, err := json.Marshal(operations) + if err != nil { + errorResponse(w, http.StatusInternalServerError, fmt.Sprintf("failed to marshal operations: %v", err)) + return + } + + successResponse(w, response) +} + +func (c *Client) getOperationQRPathHandler(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodGet { + errorResponse(w, http.StatusBadRequest, "Wrong HTTP method") + return + } + operationID := r.URL.Query().Get("operationID") + + qrPath, err := c.GetOperationQRPath(operationID) + if err != nil { + errorResponse(w, http.StatusInternalServerError, fmt.Sprintf("failed to get operation QR path: %v", err)) + return + } + + successResponse(w, []byte(qrPath)) +} + +func (c *Client) readProcessedOperationFromCameraHandler(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodGet { + errorResponse(w, http.StatusBadRequest, "Wrong HTTP method") + return + } + + if err := c.ReadProcessedOperation(); err != nil { + errorResponse(w, http.StatusInternalServerError, + fmt.Sprintf("failed to read processed operation from camera path: %v", err)) + return + } + + successResponse(w, []byte("ok")) +} diff --git a/client/state_test.go b/client/state_test.go index 62e8eb0..c62ea2f 100644 --- a/client/state_test.go +++ b/client/state_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/p2p-org/dc4bc/client" + "github.com/depool/dc4bc/client" "github.com/stretchr/testify/require" ) diff --git a/fsm/cmd/test/test.go b/fsm/cmd/test/test.go index 54f9f8d..3824b02 100644 --- a/fsm/cmd/test/test.go +++ b/fsm/cmd/test/test.go @@ -1,8 +1,8 @@ package main import ( - "github.com/p2p-org/dc4bc/fsm/state_machines" - "github.com/p2p-org/dc4bc/fsm/types/requests" + "github.com/depool/dc4bc/fsm/state_machines" + "github.com/depool/dc4bc/fsm/types/requests" "log" ) diff --git a/fsm/fsm_pool/fsm_pool.go b/fsm/fsm_pool/fsm_pool.go index 3b24ec5..0c43328 100644 --- a/fsm/fsm_pool/fsm_pool.go +++ b/fsm/fsm_pool/fsm_pool.go @@ -2,7 +2,7 @@ package fsm_pool import ( "errors" - "github.com/p2p-org/dc4bc/fsm/fsm" + "github.com/depool/dc4bc/fsm/fsm" ) type IStateMachine interface { diff --git a/fsm/state_machines/provider.go b/fsm/state_machines/provider.go index c029694..65d6942 100644 --- a/fsm/state_machines/provider.go +++ b/fsm/state_machines/provider.go @@ -3,11 +3,11 @@ package state_machines import ( "encoding/json" "errors" - "github.com/p2p-org/dc4bc/fsm/fsm" - "github.com/p2p-org/dc4bc/fsm/fsm_pool" - "github.com/p2p-org/dc4bc/fsm/state_machines/internal" - "github.com/p2p-org/dc4bc/fsm/state_machines/signature_construct_fsm" - "github.com/p2p-org/dc4bc/fsm/state_machines/signature_proposal_fsm" + "github.com/depool/dc4bc/fsm/fsm" + "github.com/depool/dc4bc/fsm/fsm_pool" + "github.com/depool/dc4bc/fsm/state_machines/internal" + "github.com/depool/dc4bc/fsm/state_machines/signature_construct_fsm" + "github.com/depool/dc4bc/fsm/state_machines/signature_proposal_fsm" ) // Is machine state scope dump will be locked? diff --git a/fsm/state_machines/signature_construct_fsm/init.go b/fsm/state_machines/signature_construct_fsm/init.go index 5f80f06..8b5fe15 100644 --- a/fsm/state_machines/signature_construct_fsm/init.go +++ b/fsm/state_machines/signature_construct_fsm/init.go @@ -1,8 +1,8 @@ package signature_construct_fsm import ( - "github.com/p2p-org/dc4bc/fsm/fsm" - "github.com/p2p-org/dc4bc/fsm/fsm_pool" + "github.com/depool/dc4bc/fsm/fsm" + "github.com/depool/dc4bc/fsm/fsm_pool" ) const ( diff --git a/fsm/state_machines/signature_proposal_fsm/actions.go b/fsm/state_machines/signature_proposal_fsm/actions.go index aba5f4b..ce28ee7 100644 --- a/fsm/state_machines/signature_proposal_fsm/actions.go +++ b/fsm/state_machines/signature_proposal_fsm/actions.go @@ -2,9 +2,9 @@ package signature_proposal_fsm import ( "errors" - "github.com/p2p-org/dc4bc/fsm/state_machines/internal" - "github.com/p2p-org/dc4bc/fsm/types/requests" - "github.com/p2p-org/dc4bc/fsm/types/responses" + "github.com/depool/dc4bc/fsm/state_machines/internal" + "github.com/depool/dc4bc/fsm/types/requests" + "github.com/depool/dc4bc/fsm/types/responses" "log" ) diff --git a/fsm/state_machines/signature_proposal_fsm/helpers.go b/fsm/state_machines/signature_proposal_fsm/helpers.go index 2da1020..81588a6 100644 --- a/fsm/state_machines/signature_proposal_fsm/helpers.go +++ b/fsm/state_machines/signature_proposal_fsm/helpers.go @@ -3,8 +3,8 @@ package signature_proposal_fsm import ( "crypto/sha256" "encoding/base64" - "github.com/p2p-org/dc4bc/fsm/state_machines/internal" - "github.com/p2p-org/dc4bc/fsm/types/responses" + "github.com/depool/dc4bc/fsm/state_machines/internal" + "github.com/depool/dc4bc/fsm/types/responses" "math/rand" ) diff --git a/fsm/state_machines/signature_proposal_fsm/init.go b/fsm/state_machines/signature_proposal_fsm/init.go index 4ab0d18..c62229b 100644 --- a/fsm/state_machines/signature_proposal_fsm/init.go +++ b/fsm/state_machines/signature_proposal_fsm/init.go @@ -1,8 +1,8 @@ package signature_proposal_fsm import ( - "github.com/p2p-org/dc4bc/fsm/fsm" - "github.com/p2p-org/dc4bc/fsm/fsm_pool" + "github.com/depool/dc4bc/fsm/fsm" + "github.com/depool/dc4bc/fsm/fsm_pool" ) const ( diff --git a/fsm/types/requests/signature_proposal.go b/fsm/types/requests/signature_proposal.go index 06f6b1c..ada2a97 100644 --- a/fsm/types/requests/signature_proposal.go +++ b/fsm/types/requests/signature_proposal.go @@ -2,7 +2,7 @@ package requests import ( "errors" - "github.com/p2p-org/dc4bc/fsm/config" + "github.com/depool/dc4bc/fsm/config" ) // Requests diff --git a/go.mod b/go.mod index 8fb0edc..9ea0846 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/p2p-org/dc4bc +module github.com/depool/dc4bc go 1.13 diff --git a/main.go b/main.go index 7636feb..3fc879c 100644 --- a/main.go +++ b/main.go @@ -10,7 +10,7 @@ import ( "go.dedis.ch/kyber/v3" - dkglib "github.com/p2p-org/dc4bc/dkg" + dkglib "github.com/depool/dc4bc/dkg" _ "image/gif" _ "image/png" diff --git a/mocks/clientMocks/state_mock.go b/mocks/clientMocks/state_mock.go index 94e12b6..398a656 100644 --- a/mocks/clientMocks/state_mock.go +++ b/mocks/clientMocks/state_mock.go @@ -5,8 +5,8 @@ package clientMocks import ( + client "github.com/depool/dc4bc/client" gomock "github.com/golang/mock/gomock" - client "github.com/p2p-org/dc4bc/client" reflect "reflect" ) diff --git a/mocks/storageMocks/storage_mock.go b/mocks/storageMocks/storage_mock.go index 5f0716b..a182d06 100644 --- a/mocks/storageMocks/storage_mock.go +++ b/mocks/storageMocks/storage_mock.go @@ -5,8 +5,8 @@ package storageMocks import ( + storage "github.com/depool/dc4bc/storage" gomock "github.com/golang/mock/gomock" - storage "github.com/p2p-org/dc4bc/storage" reflect "reflect" ) diff --git a/qr/qr.go b/qr/qr.go index 454651b..a99a9d7 100644 --- a/qr/qr.go +++ b/qr/qr.go @@ -2,6 +2,7 @@ package qr import ( "fmt" + "image" "log" "time" @@ -88,3 +89,13 @@ func (p *CameraProcessor) WriteQR(path string, data []byte) error { return nil } + +func ReadQRFromImg(img image.Image) (*gozxing.Result, error) { + bmp, err := gozxing.NewBinaryBitmapFromImage(img) + if err != nil { + return nil, fmt.Errorf("failed to get NewBinaryBitmapFromImage: %w", err) + } + + qrReader := qrcode.NewQRCodeReader() + return qrReader.Decode(bmp, nil) +} From b7da6b06b247b8e268a55cb6ca1214eb65281360 Mon Sep 17 00:00:00 2001 From: programmer10110 Date: Fri, 31 Jul 2020 17:55:47 +0300 Subject: [PATCH 2/4] WIP: http server for client --- client/client.go | 24 +++++++++++---- client/http_server.go | 71 ++++++++++++++++++++++++++++++++++++++++++- qr/qr.go | 25 +++++++-------- 3 files changed, 99 insertions(+), 21 deletions(-) diff --git a/client/client.go b/client/client.go index 869f0bc..b6a21b1 100644 --- a/client/client.go +++ b/client/client.go @@ -95,18 +95,26 @@ func (c *Client) GetOperations() (map[string]*Operation, error) { return c.state.GetOperations() } -// GetOperationQRPath returns a path to the image with the QR generated -// for the specified operation. It is supposed that the user will open -// this file herself. -func (c *Client) GetOperationQRPath(operationID string) (string, error) { +func (c *Client) getOperationJSON(operationID string) ([]byte, error) { operation, err := c.state.GetOperationByID(operationID) if err != nil { - return "", fmt.Errorf("failed to get operation: %w", err) + return nil, fmt.Errorf("failed to get operation: %w", err) } operationJSON, err := json.Marshal(operation) if err != nil { - return "", fmt.Errorf("failed to marshal operation: %w", err) + return nil, fmt.Errorf("failed to marshal operation: %w", err) + } + return operationJSON, nil +} + +// GetOperationQRPath returns a path to the image with the QR generated +// for the specified operation. It is supposed that the user will open +// this file herself. +func (c *Client) GetOperationQRPath(operationID string) (string, error) { + operationJSON, err := c.getOperationJSON(operationID) + if err != nil { + return "", fmt.Errorf("failed to get operation in JSON: %w", err) } operationQRPath := filepath.Join(QrCodesDir, operationID) @@ -131,6 +139,10 @@ func (c *Client) ReadProcessedOperation() error { return fmt.Errorf("failed to unmarshal processed operation") } + return c.handleProcessedOperation(operation) +} + +func (c *Client) handleProcessedOperation(operation Operation) error { storedOperation, err := c.state.GetOperationByID(operation.ID) if err != nil { return fmt.Errorf("failed to find matching operation: %w", err) diff --git a/client/http_server.go b/client/http_server.go index 665a8b8..486edd0 100644 --- a/client/http_server.go +++ b/client/http_server.go @@ -3,7 +3,9 @@ package client import ( "encoding/json" "fmt" + "github.com/depool/dc4bc/qr" "github.com/depool/dc4bc/storage" + "image" "io/ioutil" "log" "net/http" @@ -28,6 +30,9 @@ func (c *Client) StartHTTPServer(listenAddr string) error { http.HandleFunc("/getOperations", c.getOperationsHandler) http.HandleFunc("/getOperationQRPath", c.getOperationQRPathHandler) http.HandleFunc("/readProcessedOperationFromCamera", c.readProcessedOperationFromCameraHandler) + + http.HandleFunc("/readProcessedOperation", c.readProcessedOperationFromBodyHandler) + http.HandleFunc("/getOperationQR", c.getOperationQRToBodyHandler) return http.ListenAndServe(listenAddr, nil) } @@ -93,6 +98,30 @@ func (c *Client) getOperationQRPathHandler(w http.ResponseWriter, r *http.Reques successResponse(w, []byte(qrPath)) } +func (c *Client) getOperationQRToBodyHandler(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodGet { + errorResponse(w, http.StatusBadRequest, "Wrong HTTP method") + return + } + operationID := r.URL.Query().Get("operationID") + + operationJSON, err := c.getOperationJSON(operationID) + if err != nil { + errorResponse(w, http.StatusInternalServerError, fmt.Sprintf("failed to get operation in JSON: %v", err)) + return + } + + encodedData, err := qr.EncodeQR(operationJSON) + if err != nil { + errorResponse(w, http.StatusInternalServerError, fmt.Sprintf("failed to encode operation: %v", err)) + return + } + + w.Header().Set("Content-Type", "image/jpeg") + w.Header().Set("Content-Length", fmt.Sprintf("%d", len(encodedData))) + successResponse(w, encodedData) +} + func (c *Client) readProcessedOperationFromCameraHandler(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { errorResponse(w, http.StatusBadRequest, "Wrong HTTP method") @@ -101,9 +130,49 @@ func (c *Client) readProcessedOperationFromCameraHandler(w http.ResponseWriter, if err := c.ReadProcessedOperation(); err != nil { errorResponse(w, http.StatusInternalServerError, - fmt.Sprintf("failed to read processed operation from camera path: %v", err)) + fmt.Sprintf("failed to handle processed operation from camera path: %v", err)) return } successResponse(w, []byte("ok")) } + +func (c *Client) readProcessedOperationFromBodyHandler(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodPost { + errorResponse(w, http.StatusBadRequest, "Wrong HTTP method") + return + } + + if err := r.ParseMultipartForm(10 << 20); err != nil { + errorResponse(w, http.StatusInternalServerError, fmt.Sprintf("failed to parse multipat form: %v", err)) + return + } + + file, _, err := r.FormFile("qr") + if err != nil { + errorResponse(w, http.StatusInternalServerError, fmt.Sprintf("failed to retrieve a file: %v", err)) + return + } + defer file.Close() + img, _, err := image.Decode(file) + if err != nil { + errorResponse(w, http.StatusInternalServerError, fmt.Sprintf("failed to decode an image: %v", err)) + return + } + + qrData, err := qr.ReadDataFromQR(img) + if err != nil { + return + } + + var operation Operation + if err = json.Unmarshal(qrData, &operation); err != nil { + errorResponse(w, http.StatusInternalServerError, + fmt.Sprintf("failed to unmarshal processed operation: %v", err)) + return + } + if err := c.handleProcessedOperation(operation); err != nil { + errorResponse(w, http.StatusInternalServerError, fmt.Sprintf("failed to handle an operation: %v", err)) + return + } +} diff --git a/qr/qr.go b/qr/qr.go index a99a9d7..b264437 100644 --- a/qr/qr.go +++ b/qr/qr.go @@ -67,18 +67,7 @@ loop: return nil, fmt.Errorf("failed to get image object: %w", err) } - bmp, err := gozxing.NewBinaryBitmapFromImage(imgObject) - if err != nil { - return nil, fmt.Errorf("failed to get NewBinaryBitmapFromImage: %w", err) - } - - qrReader := qrcode.NewQRCodeReader() - result, err := qrReader.Decode(bmp, nil) - if err != nil { - return nil, fmt.Errorf("failed to decode the QR-code contents: %w", err) - } - - return result.GetRawBytes(), err + return ReadDataFromQR(imgObject) } func (p *CameraProcessor) WriteQR(path string, data []byte) error { @@ -90,12 +79,20 @@ func (p *CameraProcessor) WriteQR(path string, data []byte) error { return nil } -func ReadQRFromImg(img image.Image) (*gozxing.Result, error) { +func ReadDataFromQR(img image.Image) ([]byte, error) { bmp, err := gozxing.NewBinaryBitmapFromImage(img) if err != nil { return nil, fmt.Errorf("failed to get NewBinaryBitmapFromImage: %w", err) } qrReader := qrcode.NewQRCodeReader() - return qrReader.Decode(bmp, nil) + result, err := qrReader.Decode(bmp, nil) + if err != nil { + return nil, fmt.Errorf("failed to decode the QR-code contents: %w", err) + } + return result.GetRawBytes(), nil +} + +func EncodeQR(data []byte) ([]byte, error) { + return encoder.Encode(string(data), encoder.Medium, 512) } From bdc38546469b51822c8f7a1ee14a0852fceb0677 Mon Sep 17 00:00:00 2001 From: Andrej Zavgorodnij Date: Tue, 4 Aug 2020 09:34:10 +0300 Subject: [PATCH 3/4] depool -> depools --- client/client.go | 4 ++-- client/client_test.go | 8 ++++---- client/http_server.go | 5 +++-- client/state_test.go | 2 +- fsm/cmd/test/test.go | 5 +++-- fsm/fsm_pool/fsm_pool.go | 3 ++- fsm/state_machines/provider.go | 11 ++++++----- fsm/state_machines/signature_construct_fsm/init.go | 4 ++-- fsm/state_machines/signature_proposal_fsm/actions.go | 7 ++++--- fsm/state_machines/signature_proposal_fsm/helpers.go | 5 +++-- fsm/state_machines/signature_proposal_fsm/init.go | 4 ++-- fsm/types/requests/signature_proposal.go | 3 ++- go.mod | 2 +- main.go | 2 +- mocks/clientMocks/state_mock.go | 5 +++-- mocks/storageMocks/storage_mock.go | 5 +++-- 16 files changed, 42 insertions(+), 33 deletions(-) diff --git a/client/client.go b/client/client.go index b6a21b1..5923173 100644 --- a/client/client.go +++ b/client/client.go @@ -8,8 +8,8 @@ import ( "path/filepath" "time" - "github.com/depool/dc4bc/qr" - "github.com/depool/dc4bc/storage" + "github.com/depools/dc4bc/qr" + "github.com/depools/dc4bc/storage" ) const ( diff --git a/client/client_test.go b/client/client_test.go index 3703941..d539894 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -9,12 +9,12 @@ import ( "testing" "time" - "github.com/depool/dc4bc/mocks/qrMocks" + "github.com/depools/dc4bc/mocks/qrMocks" - "github.com/depool/dc4bc/client" + "github.com/depools/dc4bc/client" - "github.com/depool/dc4bc/mocks/clientMocks" - "github.com/depool/dc4bc/mocks/storageMocks" + "github.com/depools/dc4bc/mocks/clientMocks" + "github.com/depools/dc4bc/mocks/storageMocks" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" ) diff --git a/client/http_server.go b/client/http_server.go index 486edd0..8170d28 100644 --- a/client/http_server.go +++ b/client/http_server.go @@ -3,12 +3,13 @@ package client import ( "encoding/json" "fmt" - "github.com/depool/dc4bc/qr" - "github.com/depool/dc4bc/storage" "image" "io/ioutil" "log" "net/http" + + "github.com/depools/dc4bc/qr" + "github.com/depools/dc4bc/storage" ) func errorResponse(w http.ResponseWriter, statusCode int, err string) { diff --git a/client/state_test.go b/client/state_test.go index c62ea2f..018752e 100644 --- a/client/state_test.go +++ b/client/state_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/depool/dc4bc/client" + "github.com/depools/dc4bc/client" "github.com/stretchr/testify/require" ) diff --git a/fsm/cmd/test/test.go b/fsm/cmd/test/test.go index 3824b02..42fa7ba 100644 --- a/fsm/cmd/test/test.go +++ b/fsm/cmd/test/test.go @@ -1,9 +1,10 @@ package main import ( - "github.com/depool/dc4bc/fsm/state_machines" - "github.com/depool/dc4bc/fsm/types/requests" "log" + + "github.com/depools/dc4bc/fsm/state_machines" + "github.com/depools/dc4bc/fsm/types/requests" ) func main() { diff --git a/fsm/fsm_pool/fsm_pool.go b/fsm/fsm_pool/fsm_pool.go index 0c43328..23f5429 100644 --- a/fsm/fsm_pool/fsm_pool.go +++ b/fsm/fsm_pool/fsm_pool.go @@ -2,7 +2,8 @@ package fsm_pool import ( "errors" - "github.com/depool/dc4bc/fsm/fsm" + + "github.com/depools/dc4bc/fsm/fsm" ) type IStateMachine interface { diff --git a/fsm/state_machines/provider.go b/fsm/state_machines/provider.go index 65d6942..2930197 100644 --- a/fsm/state_machines/provider.go +++ b/fsm/state_machines/provider.go @@ -3,11 +3,12 @@ package state_machines import ( "encoding/json" "errors" - "github.com/depool/dc4bc/fsm/fsm" - "github.com/depool/dc4bc/fsm/fsm_pool" - "github.com/depool/dc4bc/fsm/state_machines/internal" - "github.com/depool/dc4bc/fsm/state_machines/signature_construct_fsm" - "github.com/depool/dc4bc/fsm/state_machines/signature_proposal_fsm" + + "github.com/depools/dc4bc/fsm/fsm" + "github.com/depools/dc4bc/fsm/fsm_pool" + "github.com/depools/dc4bc/fsm/state_machines/internal" + "github.com/depools/dc4bc/fsm/state_machines/signature_construct_fsm" + "github.com/depools/dc4bc/fsm/state_machines/signature_proposal_fsm" ) // Is machine state scope dump will be locked? diff --git a/fsm/state_machines/signature_construct_fsm/init.go b/fsm/state_machines/signature_construct_fsm/init.go index 8b5fe15..1ab2f94 100644 --- a/fsm/state_machines/signature_construct_fsm/init.go +++ b/fsm/state_machines/signature_construct_fsm/init.go @@ -1,8 +1,8 @@ package signature_construct_fsm import ( - "github.com/depool/dc4bc/fsm/fsm" - "github.com/depool/dc4bc/fsm/fsm_pool" + "github.com/depools/dc4bc/fsm/fsm" + "github.com/depools/dc4bc/fsm/fsm_pool" ) const ( diff --git a/fsm/state_machines/signature_proposal_fsm/actions.go b/fsm/state_machines/signature_proposal_fsm/actions.go index ce28ee7..81516c8 100644 --- a/fsm/state_machines/signature_proposal_fsm/actions.go +++ b/fsm/state_machines/signature_proposal_fsm/actions.go @@ -2,10 +2,11 @@ package signature_proposal_fsm import ( "errors" - "github.com/depool/dc4bc/fsm/state_machines/internal" - "github.com/depool/dc4bc/fsm/types/requests" - "github.com/depool/dc4bc/fsm/types/responses" "log" + + "github.com/depools/dc4bc/fsm/state_machines/internal" + "github.com/depools/dc4bc/fsm/types/requests" + "github.com/depools/dc4bc/fsm/types/responses" ) // init -> awaitingConfirmations diff --git a/fsm/state_machines/signature_proposal_fsm/helpers.go b/fsm/state_machines/signature_proposal_fsm/helpers.go index 81588a6..4954b81 100644 --- a/fsm/state_machines/signature_proposal_fsm/helpers.go +++ b/fsm/state_machines/signature_proposal_fsm/helpers.go @@ -3,9 +3,10 @@ package signature_proposal_fsm import ( "crypto/sha256" "encoding/base64" - "github.com/depool/dc4bc/fsm/state_machines/internal" - "github.com/depool/dc4bc/fsm/types/responses" "math/rand" + + "github.com/depools/dc4bc/fsm/state_machines/internal" + "github.com/depools/dc4bc/fsm/types/responses" ) // Request and response mutators diff --git a/fsm/state_machines/signature_proposal_fsm/init.go b/fsm/state_machines/signature_proposal_fsm/init.go index c62229b..f9eed50 100644 --- a/fsm/state_machines/signature_proposal_fsm/init.go +++ b/fsm/state_machines/signature_proposal_fsm/init.go @@ -1,8 +1,8 @@ package signature_proposal_fsm import ( - "github.com/depool/dc4bc/fsm/fsm" - "github.com/depool/dc4bc/fsm/fsm_pool" + "github.com/depools/dc4bc/fsm/fsm" + "github.com/depools/dc4bc/fsm/fsm_pool" ) const ( diff --git a/fsm/types/requests/signature_proposal.go b/fsm/types/requests/signature_proposal.go index ada2a97..c6a5b10 100644 --- a/fsm/types/requests/signature_proposal.go +++ b/fsm/types/requests/signature_proposal.go @@ -2,7 +2,8 @@ package requests import ( "errors" - "github.com/depool/dc4bc/fsm/config" + + "github.com/depools/dc4bc/fsm/config" ) // Requests diff --git a/go.mod b/go.mod index 9ea0846..995da70 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/depool/dc4bc +module github.com/depools/dc4bc go 1.13 diff --git a/main.go b/main.go index 3fc879c..59634fe 100644 --- a/main.go +++ b/main.go @@ -10,7 +10,7 @@ import ( "go.dedis.ch/kyber/v3" - dkglib "github.com/depool/dc4bc/dkg" + dkglib "github.com/depools/dc4bc/dkg" _ "image/gif" _ "image/png" diff --git a/mocks/clientMocks/state_mock.go b/mocks/clientMocks/state_mock.go index 398a656..2a5c74f 100644 --- a/mocks/clientMocks/state_mock.go +++ b/mocks/clientMocks/state_mock.go @@ -5,9 +5,10 @@ package clientMocks import ( - client "github.com/depool/dc4bc/client" - gomock "github.com/golang/mock/gomock" reflect "reflect" + + client "github.com/depools/dc4bc/client" + gomock "github.com/golang/mock/gomock" ) // MockState is a mock of State interface diff --git a/mocks/storageMocks/storage_mock.go b/mocks/storageMocks/storage_mock.go index a182d06..642fae5 100644 --- a/mocks/storageMocks/storage_mock.go +++ b/mocks/storageMocks/storage_mock.go @@ -5,9 +5,10 @@ package storageMocks import ( - storage "github.com/depool/dc4bc/storage" - gomock "github.com/golang/mock/gomock" reflect "reflect" + + storage "github.com/depools/dc4bc/storage" + gomock "github.com/golang/mock/gomock" ) // MockStorage is a mock of Storage interface From 74e6ac400768d307d751a2e9600f8608bad8d1f0 Mon Sep 17 00:00:00 2001 From: Andrej Zavgorodnij Date: Tue, 4 Aug 2020 09:40:40 +0300 Subject: [PATCH 4/4] merged master --- fsm/fsm/fsm_machines_data_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/fsm/fsm/fsm_machines_data_test.go b/fsm/fsm/fsm_machines_data_test.go index 46dc196..5aa2dba 100644 --- a/fsm/fsm/fsm_machines_data_test.go +++ b/fsm/fsm/fsm_machines_data_test.go @@ -8,6 +8,7 @@ const ( FSM1Name = "fsm1" // Init process from global idle state FSM1StateInit = StateGlobalIdle + FSM2StateInit = StateGlobalIdle // Set up data FSM1StateStage1 = State("state_fsm1_stage1") // Process data