@@ -13,6 +13,7 @@ import (
1313
1414 session "go-wrapper/go-dkls/sessions"
1515
16+ "github.com/pushchain/push-chain-node/universalClient/pushcore"
1617 "github.com/pushchain/push-chain-node/universalClient/store"
1718 "github.com/pushchain/push-chain-node/universalClient/tss/eventstore"
1819 "github.com/pushchain/push-chain-node/universalClient/tss/keyshare"
@@ -22,7 +23,7 @@ import (
2223// Coordinator handles coordinator logic for TSS events.
2324type Coordinator struct {
2425 eventStore * eventstore.Store
25- dataProvider DataProvider
26+ pushCore * pushcore. Client
2627 keyshareManager * keyshare.Manager
2728 validatorAddress string
2829 coordinatorRange uint64
@@ -51,7 +52,7 @@ type ackState struct {
5152// NewCoordinator creates a new coordinator.
5253func NewCoordinator (
5354 eventStore * eventstore.Store ,
54- dataProvider DataProvider ,
55+ pushCore * pushcore. Client ,
5556 keyshareManager * keyshare.Manager ,
5657 validatorAddress string ,
5758 coordinatorRange uint64 ,
@@ -64,7 +65,7 @@ func NewCoordinator(
6465 }
6566 return & Coordinator {
6667 eventStore : eventStore ,
67- dataProvider : dataProvider ,
68+ pushCore : pushCore ,
6869 keyshareManager : keyshareManager ,
6970 validatorAddress : validatorAddress ,
7071 coordinatorRange : coordinatorRange ,
@@ -155,15 +156,15 @@ func (c *Coordinator) GetMultiAddrsFromPeerID(ctx context.Context, peerID string
155156 return nil , errors .Errorf ("peerID %s not found in validators" , peerID )
156157}
157158
158- // GetLatestBlockNum gets the latest block number from the data provider .
159+ // GetLatestBlockNum gets the latest block number from pushCore .
159160func (c * Coordinator ) GetLatestBlockNum () (uint64 , error ) {
160- return c .dataProvider .GetLatestBlockNum ()
161+ return c .pushCore .GetLatestBlockNum ()
161162}
162163
163164// IsPeerCoordinator checks if the given peerID is the coordinator for the current block.
164165// Uses cached allValidators for performance.
165166func (c * Coordinator ) IsPeerCoordinator (ctx context.Context , peerID string ) (bool , error ) {
166- currentBlock , err := c .dataProvider .GetLatestBlockNum ()
167+ currentBlock , err := c .pushCore .GetLatestBlockNum ()
167168 if err != nil {
168169 return false , errors .Wrap (err , "failed to get latest block number" )
169170 }
@@ -210,9 +211,9 @@ func (c *Coordinator) IsPeerCoordinator(ctx context.Context, peerID string) (boo
210211 return coordValidatorAddr == validatorAddress , nil
211212}
212213
213- // GetCurrentTSSKeyId gets the current TSS key ID from the data provider .
214+ // GetCurrentTSSKeyId gets the current TSS key ID from pushCore .
214215func (c * Coordinator ) GetCurrentTSSKeyId () (string , error ) {
215- return c .dataProvider .GetCurrentTSSKeyId ()
216+ return c .pushCore .GetCurrentTSSKeyId ()
216217}
217218
218219// GetEligibleUV returns eligible validators for the given protocol type.
@@ -293,7 +294,7 @@ func (c *Coordinator) pollLoop(ctx context.Context) {
293294
294295// updateValidators fetches and caches all validators.
295296func (c * Coordinator ) updateValidators () {
296- allValidators , err := c .dataProvider .GetUniversalValidators ()
297+ allValidators , err := c .pushCore .GetUniversalValidators ()
297298 if err != nil {
298299 c .logger .Warn ().Err (err ).Msg ("failed to update validators cache" )
299300 return
@@ -308,7 +309,7 @@ func (c *Coordinator) updateValidators() {
308309
309310// processPendingEvents checks if this node is coordinator, and only then reads DB and processes events.
310311func (c * Coordinator ) processPendingEvents (ctx context.Context ) error {
311- currentBlock , err := c .dataProvider .GetLatestBlockNum ()
312+ currentBlock , err := c .pushCore .GetLatestBlockNum ()
312313 if err != nil {
313314 return errors .Wrap (err , "failed to get latest block number" )
314315 }
@@ -605,8 +606,8 @@ func (c *Coordinator) createKeygenSetup(threshold int, partyIDs []string) ([]byt
605606// createSignSetup creates a sign setup message.
606607// Requires loading the keyshare to extract keyID and messageHash from event data.
607608func (c * Coordinator ) createSignSetup (ctx context.Context , eventData []byte , partyIDs []string ) ([]byte , error ) {
608- // Get current TSS keyId from dataProvider
609- keyIDStr , err := c .dataProvider .GetCurrentTSSKeyId ()
609+ // Get current TSS keyId from pushCore
610+ keyIDStr , err := c .pushCore .GetCurrentTSSKeyId ()
610611 if err != nil {
611612 return nil , errors .Wrap (err , "failed to get current TSS keyId" )
612613 }
@@ -665,8 +666,8 @@ func (c *Coordinator) createSignSetup(ctx context.Context, eventData []byte, par
665666// oldParticipantIndices: indices of Active validators (staying participants)
666667// newParticipantIndices: indices of Pending Join validators (new participants)
667668func (c * Coordinator ) createQcSetup (ctx context.Context , threshold int , partyIDs []string , participants []* types.UniversalValidator ) ([]byte , error ) {
668- // Get current TSS keyId from dataProvider
669- keyIDStr , err := c .dataProvider .GetCurrentTSSKeyId ()
669+ // Get current TSS keyId from pushCore
670+ keyIDStr , err := c .pushCore .GetCurrentTSSKeyId ()
670671 if err != nil {
671672 return nil , errors .Wrap (err , "failed to get current TSS keyId" )
672673 }
0 commit comments