Skip to content

Commit

Permalink
feat: update/modify for new version of utxorpc (#258)
Browse files Browse the repository at this point in the history
Signed-off-by: Ales Verbic <[email protected]>
  • Loading branch information
verbotenj authored Sep 29, 2024
1 parent eb485b9 commit 1adf09e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 32 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/swaggo/files v1.0.1
github.com/swaggo/gin-swagger v1.6.0
github.com/swaggo/swag v1.16.3
github.com/utxorpc/go-codegen v0.9.0
github.com/utxorpc/go-codegen v0.10.0
go.uber.org/automaxprocs v1.5.3
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.27.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVM
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/utxorpc/go-codegen v0.9.0 h1:sV5vK/QiQs3WvKynRVo+U+5n2tmKU7yMz5y3rEX90Hg=
github.com/utxorpc/go-codegen v0.9.0/go.mod h1:+npvJc9wftIf8JMtWaRXxwjX0YlOCpNp1OlZVioNEO0=
github.com/utxorpc/go-codegen v0.10.0 h1:EVRNc136CThXbbGeYV/oIy6NKfcZGLH2QSRmLTPE6TQ=
github.com/utxorpc/go-codegen v0.10.0/go.mod h1:+npvJc9wftIf8JMtWaRXxwjX0YlOCpNp1OlZVioNEO0=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
37 changes: 8 additions & 29 deletions internal/utxorpc/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ func (s *submitServiceServer) ReadMempool(
ctx context.Context,
req *connect.Request[submit.ReadMempoolRequest],
) (*connect.Response[submit.ReadMempoolResponse], error) {

txim := req.Msg.GetTx() // []*TxInMempool
log.Printf("Got a ReadMempool request with %d transactions", len(txim))
log.Printf("Got a ReadMempool request")
resp := &submit.ReadMempoolResponse{}

// Connect to node
Expand Down Expand Up @@ -221,30 +219,15 @@ func (s *submitServiceServer) ReadMempool(
if txRawBytes == nil {
break
}
var act submit.AnyChainTx
var actr submit.AnyChainTx_Raw
actr.Raw = txRawBytes
act.Type = &actr

record := &submit.TxInMempool{
Tx: &act,
Stage: submit.Stage_STAGE_MEMPOOL,
NativeBytes: txRawBytes,
Stage: submit.Stage_STAGE_MEMPOOL,
}
mempool = append(mempool, record)
}

// Check each requested Tx against our mempool
for _, txi := range txim {
txi.Stage = submit.Stage_STAGE_UNSPECIFIED
for _, tx := range mempool {
if txi.Stage == submit.Stage_STAGE_MEMPOOL {
break
}
if txi.Tx.String() == tx.Tx.String() {
txi.Stage = submit.Stage_STAGE_MEMPOOL
}
}
resp.Stage = append(resp.Stage, txi.Stage)
}
resp.Items = mempool
return connect.NewResponse(resp), nil
}

Expand Down Expand Up @@ -312,16 +295,12 @@ func (s *submitServiceServer) WatchMempool(
}
cTx := tx.Utxorpc() // *cardano.Tx
resp := &submit.WatchMempoolResponse{}
var act submit.AnyChainTx
var actr submit.AnyChainTx_Raw
actr.Raw = txRawBytes
act.Type = &actr
record := &submit.TxInMempool{
Tx: &act,
Stage: submit.Stage_STAGE_MEMPOOL,
NativeBytes: txRawBytes,
Stage: submit.Stage_STAGE_MEMPOOL,
}
resp.Tx = record
if record.Tx.String() == cTx.String() {
if string(record.NativeBytes) == cTx.String() {
if predicate == nil {
err := stream.Send(resp)
if err != nil {
Expand Down

0 comments on commit 1adf09e

Please sign in to comment.