mirror of https://github.com/certusone/dc4bc.git
wip
This commit is contained in:
parent
eca8329508
commit
83b86b132b
|
@ -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)
|
||||
|
@ -254,6 +254,7 @@ func (c *Client) handleProcessedOperation(operation types.Operation) error {
|
|||
message := storage.Message{
|
||||
Event: string(operation.Type),
|
||||
Data: operation.Result,
|
||||
DkgRoundID: operation.DKGIdentifier,
|
||||
}
|
||||
|
||||
sig, err := c.signMessage(message.Bytes())
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
3
main.go
3
main.go
|
@ -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(),
|
||||
|
|
Loading…
Reference in New Issue