-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added draft implementation for pool qubic client (#9)
* added draft implementation for pool qubic client * added docker build for dev branch * properly closing and putting back conn from pool * added rpc_server and switched deploymen to it * added block-height * fixed broadcast tx decode issue * added base64 decoding to broadcast-transaction * added encodedtx to broadcast transaction response * bumped go-node-connector version --------- Co-authored-by: 0xluk <luk@dev>
- Loading branch information
Showing
29 changed files
with
2,854 additions
and
629 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,25 @@ | ||
name: Deploy dev images to GHCR | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'dev' | ||
|
||
jobs: | ||
push-store-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 'Checkout GitHub Action' | ||
uses: actions/checkout@main | ||
|
||
- name: 'Login to GitHub Container Registry' | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{github.actor}} | ||
password: ${{secrets.GITHUB_TOKEN}} | ||
|
||
- name: 'Build Inventory Image' | ||
run: | | ||
docker build . --tag ghcr.io/qubic/qubic-http:dev | ||
docker push ghcr.io/qubic/qubic-http:dev |
File renamed without changes.
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,96 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/pkg/errors" | ||
qubic "github.com/qubic/go-node-connector" | ||
rpc "github.com/qubic/qubic-http/foundation/rpc_server" | ||
"log" | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
"time" | ||
|
||
"github.com/ardanlabs/conf" | ||
) | ||
|
||
const prefix = "QUBIC_API_SIDECAR" | ||
|
||
func main() { | ||
log := log.New(os.Stdout, prefix, log.LstdFlags|log.Lmicroseconds|log.Lshortfile) | ||
if err := run(log); err != nil { | ||
log.Fatalf("main: exited with error: %s", err.Error()) | ||
} | ||
} | ||
|
||
func run(log *log.Logger) error { | ||
var cfg struct { | ||
Server struct { | ||
ReadTimeout time.Duration `conf:"default:5s"` | ||
WriteTimeout time.Duration `conf:"default:5s"` | ||
ShutdownTimeout time.Duration `conf:"default:5s"` | ||
HttpHost string `conf:"default:0.0.0.0:8000"` | ||
GrpcHost string `conf:"default:0.0.0.0:8001"` | ||
} | ||
Pool struct { | ||
NodeFetcherUrl string `conf:"default:http://127.0.0.1:8080/peers"` | ||
NodeFetcherTimeout time.Duration `conf:"default:2s"` | ||
InitialCap int `conf:"default:5"` | ||
MaxIdle int `conf:"default:20"` | ||
MaxCap int `conf:"default:30"` | ||
IdleTimeout time.Duration `conf:"default:15s"` | ||
} | ||
} | ||
|
||
if err := conf.Parse(os.Args[1:], prefix, &cfg); err != nil { | ||
switch err { | ||
case conf.ErrHelpWanted: | ||
usage, err := conf.Usage(prefix, &cfg) | ||
if err != nil { | ||
return errors.Wrap(err, "generating config usage") | ||
} | ||
fmt.Println(usage) | ||
return nil | ||
case conf.ErrVersionWanted: | ||
version, err := conf.VersionString(prefix, &cfg) | ||
if err != nil { | ||
return errors.Wrap(err, "generating config version") | ||
} | ||
fmt.Println(version) | ||
return nil | ||
} | ||
return errors.Wrap(err, "parsing config") | ||
} | ||
|
||
out, err := conf.String(&cfg) | ||
if err != nil { | ||
return errors.Wrap(err, "generating config for output") | ||
} | ||
log.Printf("main: Config :\n%v\n", out) | ||
|
||
pool, err := qubic.NewPoolConnection(qubic.PoolConfig{ | ||
InitialCap: cfg.Pool.InitialCap, | ||
MaxCap: cfg.Pool.MaxCap, | ||
MaxIdle: cfg.Pool.MaxIdle, | ||
IdleTimeout: cfg.Pool.IdleTimeout, | ||
NodeFetcherUrl: cfg.Pool.NodeFetcherUrl, | ||
NodeFetcherTimeout: cfg.Pool.NodeFetcherTimeout, | ||
NodePort: "21841", | ||
}) | ||
if err != nil { | ||
return errors.Wrap(err, "creating qubic pool") | ||
} | ||
|
||
rpcServer := rpc.NewServer(cfg.Server.GrpcHost, cfg.Server.HttpHost, pool) | ||
rpcServer.Start() | ||
|
||
shutdown := make(chan os.Signal, 1) | ||
signal.Notify(shutdown, os.Interrupt, syscall.SIGTERM) | ||
|
||
for { | ||
select { | ||
case <-shutdown: | ||
return errors.New("shutting down") | ||
} | ||
} | ||
} |
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
Oops, something went wrong.