Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add golines to makefile and execute #177

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ clean:
format: mod-tidy
go fmt ./...

golines:
golines -w --ignore-generated --chain-split-dots --max-len=80 --reformat-tags .

test:
go test -v -race ./...

Expand Down
5 changes: 4 additions & 1 deletion cmd/cardano-node-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ func main() {
oConn.Close()
}

logger.Infof("starting cardano-node-api version %s", version.GetVersionString())
logger.Infof(
"starting cardano-node-api version %s",
version.GetVersionString(),
)

// Start debug listener
if cfg.Debug.ListenPort > 0 {
Expand Down
22 changes: 11 additions & 11 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ import (
ginSwagger "github.com/swaggo/gin-swagger" // gin-swagger middleware
)

// @title cardano-node-api
// @version 1.0
// @description Cardano Node API
// @host localhost
// @Schemes http
// @BasePath /api
// @contact.name Blink Labs
// @contact.url https://blinklabs.io
// @contact.email [email protected]
// @title cardano-node-api
// @version 1.0
// @description Cardano Node API
// @host localhost
// @Schemes http
// @BasePath /api
// @contact.name Blink Labs
// @contact.url https://blinklabs.io
// @contact.email [email protected]
//
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
func Start(cfg *config.Config) error {
// Disable gin debug and color output
gin.SetMode(gin.ReleaseMode)
Expand Down
7 changes: 6 additions & 1 deletion internal/api/chainsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ func handleChainSyncSync(c *gin.Context) {
return
}
if !req.Tip && (req.Slot == 0 || req.Hash == "") {
c.JSON(http.StatusBadRequest, apiError("you must provide the 'slot' and 'hash' parameters or set 'tip' to True"))
c.JSON(
http.StatusBadRequest,
apiError(
"you must provide the 'slot' and 'hash' parameters or set 'tip' to True",
),
)
return
}
// Setup event channel
Expand Down
16 changes: 12 additions & 4 deletions internal/utxorpc/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,18 @@ import (

func Start(cfg *config.Config) error {
mux := http.NewServeMux()
queryPath, queryHandler := queryconnect.NewQueryServiceHandler(&queryServiceServer{})
submitPath, submitHandler := submitconnect.NewSubmitServiceHandler(&submitServiceServer{})
syncPath, syncHandler := syncconnect.NewChainSyncServiceHandler(&chainSyncServiceServer{})
watchPath, watchHandler := watchconnect.NewWatchServiceHandler(&watchServiceServer{})
queryPath, queryHandler := queryconnect.NewQueryServiceHandler(
&queryServiceServer{},
)
submitPath, submitHandler := submitconnect.NewSubmitServiceHandler(
&submitServiceServer{},
)
syncPath, syncHandler := syncconnect.NewChainSyncServiceHandler(
&chainSyncServiceServer{},
)
watchPath, watchHandler := watchconnect.NewWatchServiceHandler(
&watchServiceServer{},
)
mux.Handle(queryPath, queryHandler)
mux.Handle(submitPath, submitHandler)
mux.Handle(syncPath, syncHandler)
Expand Down
5 changes: 3 additions & 2 deletions internal/utxorpc/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (s *queryServiceServer) ReadUtxos(
for _, txo := range keys {
// txo.Hash, txo.Index
tmpTxIn := ledger.ShelleyTransactionInput{
TxId: ledger.Blake2b256(txo.Hash),
TxId: ledger.Blake2b256(txo.Hash),
OutputIndex: uint32(txo.Index),
}
tmpTxIns = append(tmpTxIns, tmpTxIn)
Expand All @@ -137,7 +137,8 @@ func (s *queryServiceServer) ReadUtxos(
var audc query.AnyUtxoData_Cardano
aud.TxoRef = txo
txHash := hex.EncodeToString(txo.Hash)
if utxoId.Hash.String() == txHash && uint32(utxoId.Idx) == txo.Index {
if utxoId.Hash.String() == txHash &&
uint32(utxoId.Idx) == txo.Index {
aud.NativeBytes = utxo.Cbor()
audc.Cardano = utxo.Utxorpc()
aud.ParsedState = &audc
Expand Down
5 changes: 4 additions & 1 deletion internal/utxorpc/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ func (s *submitServiceServer) SubmitTx(
continue
}
// Submit the transaction
err = oConn.LocalTxSubmission().Client.SubmitTx(uint16(txType), txRawBytes)
err = oConn.LocalTxSubmission().Client.SubmitTx(
uint16(txType),
txRawBytes,
)
if err != nil {
resp.Ref = append(resp.Ref, placeholderRef)
errorList[i] = fmt.Errorf("%s", err.Error())
Expand Down
19 changes: 16 additions & 3 deletions internal/utxorpc/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ func (s *chainSyncServiceServer) FetchBlock(
) (*connect.Response[sync.FetchBlockResponse], error) {
ref := req.Msg.GetRef() // BlockRef
fieldMask := req.Msg.GetFieldMask()
log.Printf("Got a FetchBlock request with ref %v and fieldMask %v", ref, fieldMask)
log.Printf(
"Got a FetchBlock request with ref %v and fieldMask %v",
ref,
fieldMask,
)

// Connect to node
oConn, err := node.GetConnection(nil)
Expand Down Expand Up @@ -103,7 +107,12 @@ func (s *chainSyncServiceServer) DumpHistory(
startToken := req.Msg.GetStartToken() // BlockRef
maxItems := req.Msg.GetMaxItems()
fieldMask := req.Msg.GetFieldMask()
log.Printf("Got a DumpHistory request with token %v and maxItems %d and fieldMask %v", startToken, maxItems, fieldMask)
log.Printf(
"Got a DumpHistory request with token %v and maxItems %d and fieldMask %v",
startToken,
maxItems,
fieldMask,
)

// Connect to node
oConn, err := node.GetConnection(nil)
Expand Down Expand Up @@ -135,7 +144,11 @@ func (s *chainSyncServiceServer) DumpHistory(
}
startPoint = tip.Point
}
log.Printf("startPoint slot %d, hash %x\n", startPoint.Slot, startPoint.Hash)
log.Printf(
"startPoint slot %d, hash %x\n",
startPoint.Slot,
startPoint.Hash,
)
// TODO: why is this giving us 0?
start, end, err := oConn.ChainSync().Client.GetAvailableBlockRange(
[]ocommon.Point{startPoint},
Expand Down
6 changes: 5 additions & 1 deletion internal/utxorpc/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ func (s *watchServiceServer) WatchTx(
) error {
predicate := req.Msg.GetPredicate() // Predicate
fieldMask := req.Msg.GetFieldMask()
log.Printf("Got a WatchTx request with predicate %v and fieldMask %v", predicate, fieldMask)
log.Printf(
"Got a WatchTx request with predicate %v and fieldMask %v",
predicate,
fieldMask,
)

// Setup event channel
eventChan := make(chan event.Event, 10)
Expand Down