-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd2aef4
commit c5395d2
Showing
14 changed files
with
165 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package scheduler | ||
|
||
import ( | ||
"github.com/TimeleapLabs/unchained/internal/service/frost" | ||
) | ||
|
||
// FrostSync is a scheduler for syncing signer of Frost and keep task's dependencies. | ||
type FrostSync struct { | ||
frostService frost.Service | ||
} | ||
|
||
// Run will trigger by the scheduler and process the Frost sync. | ||
func (e *FrostSync) Run() { | ||
err := e.frostService.PushSigners() | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
// NewFrostSync will create a new FrostSync task. | ||
func NewFrostSync(frostService frost.Service) *FrostSync { | ||
e := FrostSync{ | ||
frostService: frostService, | ||
} | ||
|
||
return &e | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package frost | ||
|
||
type Service interface { | ||
PushSigners() error | ||
} | ||
|
||
type service struct { | ||
reserveSigners []bool | ||
Check failure on line 8 in internal/service/frost/frost.go GitHub Actions / build
|
||
currentSigners []bool | ||
} | ||
|
||
func New() Service { | ||
return &service{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package frost | ||
|
||
import ( | ||
"encoding/json" | ||
"github.com/TimeleapLabs/unchained/internal/transport/server/pubsub" | ||
|
||
"github.com/TimeleapLabs/unchained/internal/consts" | ||
"github.com/TimeleapLabs/unchained/internal/model" | ||
"github.com/TimeleapLabs/unchained/internal/transport/server/websocket/store" | ||
"github.com/TimeleapLabs/unchained/internal/utils" | ||
"github.com/gorilla/websocket" | ||
) | ||
|
||
// PushSigners starts calculating of Frost signers by sending signers list to the Broker. | ||
func (s *service) PushSigners() error { | ||
signers := []model.Signer{} | ||
store.Signers.Range(func(_ *websocket.Conn, value model.Signer) bool { | ||
signers = append(signers, value) | ||
return true | ||
}) | ||
|
||
signersBytes, err := json.Marshal(signers) | ||
if err != nil { | ||
utils.Logger.With("Error", err).Error("Cant marshal signers list") | ||
return consts.ErrInternalError | ||
} | ||
|
||
pubsub.Publish(consts.ChannelFrostSignerList, consts.OpCodeSendSignerList, signersBytes) | ||
|
||
return nil | ||
} | ||
|
||
// SyncSigners Get list of signers and check power of voting them and generate a new list (if there is difference) of signers which have power. | ||
func (s *service) SyncSigners(signers []model.Signer) error { | ||
Check failure on line 34 in internal/service/frost/sync.go GitHub Actions / build
|
||
// TODO: get power of list items and delete no power ones. | ||
|
||
// TODO: check the final list with previous one, and replace it if it have difference | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package handler | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
func (h *consumer) InitFrostSigner(ctx context.Context, message []byte) { | ||
Check failure on line 7 in internal/transport/client/handler/frost.go GitHub Actions / build
|
||
// packet := new([]model.Signer).FromBytes(message) | ||
|
||
} | ||
|
||
func (w worker) InitFrostSigner(ctx context.Context, message []byte) { | ||
Check failure on line 12 in internal/transport/client/handler/frost.go GitHub Actions / build
|
||
//packet := new(model.Signers).FromBytes(message) | ||
Check failure on line 13 in internal/transport/client/handler/frost.go GitHub Actions / build
|
||
//TODO implement me | ||
panic("implement me") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters