-
Notifications
You must be signed in to change notification settings - Fork 8
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 #24 from somatic-labs/faddat/grpc2
use 10 positions
- Loading branch information
Showing
20 changed files
with
1,365 additions
and
427 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv) | ||
emails/ | ||
configurations/ |
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,23 @@ | ||
// Hardhat .cursorrules | ||
|
||
// HTMX and Go best practices | ||
const htmxGoBestPractices = [ | ||
"follow practices suited for cosmos-sdk v0.50.x", | ||
"follow practices suited for ibc-go v8.x.x" | ||
]; | ||
|
||
// Folder structure | ||
const folderStructure = ` | ||
main.go | ||
lib/ | ||
|
||
modules/ | ||
go.mod | ||
go.sum | ||
`; | ||
|
||
// Additional instructions | ||
const additionalInstructions = ` | ||
1. We are building a high speed test framework for mainnets | ||
2. We should aim for this application to be precise and performant | ||
`; |
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,29 @@ | ||
# .github/workflows/clippy.yml | ||
name: Clippy | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
clippy: | ||
name: Run Clippy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
components: clippy | ||
- name: Run Clippy | ||
uses: actions-rs/clippy-check@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
args: --all-features --manifest-path contracts/statefilestore/Cargo.toml -- -D warnings |
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,21 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
name: Test | ||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
go-version: [1.23.x] | ||
os: [ubuntu-latest, macos-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- run: go test ./... |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
target/ | ||
**seedphrase | ||
**meteorite | ||
**meteorite |
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,68 @@ | ||
package broadcast | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"sync" | ||
"time" | ||
|
||
cometrpc "github.com/cometbft/cometbft/rpc/client/http" | ||
coretypes "github.com/cometbft/cometbft/rpc/core/types" | ||
tmtypes "github.com/cometbft/cometbft/types" | ||
) | ||
|
||
type Client struct { | ||
client *cometrpc.HTTP | ||
} | ||
|
||
var ( | ||
clients = make(map[string]*Client) | ||
clientsMux sync.RWMutex | ||
) | ||
|
||
func GetClient(rpcEndpoint string) (*Client, error) { | ||
clientsMux.RLock() | ||
if client, exists := clients[rpcEndpoint]; exists { | ||
clientsMux.RUnlock() | ||
return client, nil | ||
} | ||
clientsMux.RUnlock() | ||
|
||
// If client doesn't exist, acquire write lock and create it | ||
clientsMux.Lock() | ||
defer clientsMux.Unlock() | ||
|
||
// Double-check after acquiring write lock | ||
if client, exists := clients[rpcEndpoint]; exists { | ||
return client, nil | ||
} | ||
|
||
// Create new client | ||
cmtCli, err := cometrpc.New(rpcEndpoint, "/websocket") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
client := &Client{ | ||
client: cmtCli, | ||
} | ||
clients[rpcEndpoint] = client | ||
return client, nil | ||
} | ||
|
||
func (b *Client) Transaction(txBytes []byte) (*coretypes.ResultBroadcastTx, error) { | ||
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) | ||
defer cancel() | ||
|
||
t := tmtypes.Tx(txBytes) | ||
res, err := b.client.BroadcastTxSync(ctx, t) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if res.Code != 0 { | ||
return res, fmt.Errorf("broadcast error code %d: %s", res.Code, res.Log) | ||
} | ||
|
||
return res, nil | ||
} |
Oops, something went wrong.