This commit is contained in:
programmer10110 2020-08-20 18:37:13 +03:00
parent eca8329508
commit 83b86b132b
3 changed files with 12 additions and 5 deletions

View File

@ -100,7 +100,7 @@ func (c *Client) Poll() error {
operations, err := c.GetOperations()
if err != nil {
log.Println("Failed to get operations: %v", err)
log.Printf("Failed to get operations: %v", err)
}
for _, operation := range operations {
processedOperations, err := c.airgapped.HandleOperation(*operation)
@ -252,8 +252,9 @@ func (c *Client) handleProcessedOperation(operation types.Operation) error {
}
message := storage.Message{
Event: string(operation.Type),
Data: operation.Result,
Event: string(operation.Type),
Data: operation.Result,
DkgRoundID: operation.DKGIdentifier,
}
sig, err := c.signMessage(message.Bytes())

View File

@ -123,7 +123,12 @@ func (s *LevelDBState) SaveFSM(dkgRoundID string, dump []byte) error {
fsmInstances[dkgRoundID] = dump
if err := s.stateDb.Put([]byte(fsmStateKey), dump, nil); err != nil {
fsmInstancesBz, err := json.Marshal(fsmInstances)
if err != nil {
return fmt.Errorf("failed to marshal FSM instances: %w", err)
}
if err := s.stateDb.Put([]byte(fsmStateKey), fsmInstancesBz, nil); err != nil {
return fmt.Errorf("failed to save fsm state: %w", err)
}

View File

@ -4,6 +4,7 @@ import (
"context"
"crypto/ed25519"
"crypto/md5"
"encoding/hex"
"encoding/json"
"fmt"
"github.com/depools/dc4bc/airgapped"
@ -128,7 +129,7 @@ func main() {
dkgRoundID := md5.Sum(messageDataBz)
message := storage.Message{
ID: uuid.New().String(),
DkgRoundID: string(dkgRoundID[:]),
DkgRoundID: hex.EncodeToString(dkgRoundID[:]),
Event: string(spf.EventInitProposal),
Data: messageDataBz,
SenderAddr: nodes[0].client.GetAddr(),