-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from rarimo/feature/gist-transfers
Adding separate gist and state transfers
- Loading branch information
Showing
10 changed files
with
323 additions
and
135 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package voting | ||
|
||
import ( | ||
"context" | ||
"sync" | ||
"time" | ||
|
||
"github.com/rarimo/evm-identity-saver-svc/internal/config" | ||
rarimocore "github.com/rarimo/rarimo-core/x/rarimocore/types" | ||
"github.com/rarimo/saver-grpc-lib/voter" | ||
"gitlab.com/distributed_lab/running" | ||
) | ||
|
||
const ( | ||
OpQueryGISTUpdate = "tm.event='Tx' AND new_operation.operation_type='IDENTITY_GIST_TRANSFER'" | ||
OpQueryStateUpdate = "tm.event='Tx' AND new_operation.operation_type='IDENTITY_STATE_TRANSFER'" | ||
) | ||
|
||
func RunVoter(ctx context.Context, cfg config.Config) { | ||
gistV := NewGISTUpdateVerifier(cfg) | ||
stateV := NewStateUpdateVerifier(cfg) | ||
|
||
v := voter.NewVoter(cfg.Ethereum().NetworkName, cfg.Log(), cfg.Broadcaster(), map[rarimocore.OpType]voter.Verifier{ | ||
rarimocore.OpType_IDENTITY_STATE_TRANSFER: stateV, | ||
rarimocore.OpType_IDENTITY_GIST_TRANSFER: gistV, | ||
}) | ||
|
||
// catchup tends to panic on startup and doesn't handle it by itself, so we wrap it into retry loop | ||
running.UntilSuccess(ctx, cfg.Log(), "voter-catchup", func(ctx context.Context) (bool, error) { | ||
voter. | ||
NewCatchupper(cfg.Cosmos(), v, cfg.Log()). | ||
Run(ctx) | ||
|
||
return true, nil | ||
}, 1*time.Second, 5*time.Second) | ||
|
||
wg := sync.WaitGroup{} | ||
wg.Add(2) | ||
|
||
go func() { | ||
defer wg.Done() | ||
voter. | ||
NewSubscriber(v, cfg.Tendermint(), cfg.Cosmos(), OpQueryStateUpdate, cfg.Log(), cfg.Subscriber()). | ||
Run(ctx) | ||
}() | ||
|
||
go func() { | ||
defer wg.Done() | ||
voter. | ||
NewSubscriber(v, cfg.Tendermint(), cfg.Cosmos(), OpQueryGISTUpdate, cfg.Log(), cfg.Subscriber()). | ||
Run(ctx) | ||
}() | ||
|
||
wg.Wait() | ||
} |
Oops, something went wrong.