-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Chris Gianelloni <[email protected]>
- Loading branch information
Showing
12 changed files
with
502 additions
and
2 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,70 @@ | ||
// Copyright 2024 Blink Labs Software | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package utxorpc | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
"connectrpc.com/connect" | ||
query "github.com/utxorpc/go-codegen/utxorpc/v1alpha/query" | ||
"github.com/utxorpc/go-codegen/utxorpc/v1alpha/query/queryconnect" | ||
) | ||
|
||
// queryServiceServer implements the QueryService API | ||
type queryServiceServer struct { | ||
queryconnect.UnimplementedQueryServiceHandler | ||
} | ||
|
||
// ReadParams | ||
func (s *queryServiceServer) ReadParams( | ||
ctx context.Context, | ||
req *connect.Request[query.ReadParamsRequest], | ||
) (*connect.Response[query.ReadParamsResponse], error) { | ||
fieldMask := req.Msg.GetFieldMask() | ||
|
||
log.Printf("Got a ReadParams request with fieldMask %v", fieldMask) | ||
resp := &query.ReadParamsResponse{} | ||
|
||
return connect.NewResponse(resp), nil | ||
} | ||
|
||
// ReadUtxos | ||
func (s *queryServiceServer) ReadUtxos( | ||
ctx context.Context, | ||
req *connect.Request[query.ReadUtxosRequest], | ||
) (*connect.Response[query.ReadUtxosResponse], error) { | ||
keys := req.Msg.GetKeys() // []*TxoRef | ||
|
||
log.Printf("Got a ReadUtxos request with keys %v", keys) | ||
resp := &query.ReadUtxosResponse{} | ||
|
||
return connect.NewResponse(resp), nil | ||
} | ||
|
||
// SearchUtxos | ||
func (s *queryServiceServer) SearchUtxos( | ||
ctx context.Context, | ||
req *connect.Request[query.SearchUtxosRequest], | ||
) (*connect.Response[query.SearchUtxosResponse], error) { | ||
predicate := req.Msg.GetPredicate() // UtxoPredicate | ||
|
||
log.Printf("Got a SearchUtxos request with predicate %v", predicate) | ||
resp := &query.SearchUtxosResponse{} | ||
|
||
return connect.NewResponse(resp), nil | ||
} | ||
|
||
// StreamUtxos |
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,83 @@ | ||
// Copyright 2024 Blink Labs Software | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package utxorpc | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
"connectrpc.com/connect" | ||
submit "github.com/utxorpc/go-codegen/utxorpc/v1alpha/submit" | ||
"github.com/utxorpc/go-codegen/utxorpc/v1alpha/submit/submitconnect" | ||
) | ||
|
||
// submitServiceServer implements the SubmitService API | ||
type submitServiceServer struct { | ||
submitconnect.UnimplementedSubmitServiceHandler | ||
} | ||
|
||
// SubmitTx | ||
func (s *submitServiceServer) SubmitTx( | ||
ctx context.Context, | ||
req *connect.Request[submit.SubmitTxRequest], | ||
) (*connect.Response[submit.SubmitTxResponse], error) { | ||
txRawList := req.Msg.GetTx() // []*AnyChainTx | ||
|
||
log.Printf("Got a SubmitTx request with %d transactions", len(txRawList)) | ||
resp := &submit.SubmitTxResponse{} | ||
|
||
return connect.NewResponse(resp), nil | ||
} | ||
|
||
func (s *submitServiceServer) WaitForTx( | ||
ctx context.Context, | ||
req *connect.Request[submit.WaitForTxRequest], | ||
stream *connect.ServerStream[submit.WaitForTxResponse], | ||
) error { | ||
ref := req.Msg.GetRef() // [][]byte | ||
|
||
log.Printf("Received WaitForTx request with %d transactions", len(ref)) | ||
return nil | ||
} | ||
|
||
// ReadMempool | ||
func (s *submitServiceServer) ReadMempool( | ||
ctx context.Context, | ||
req *connect.Request[submit.ReadMempoolRequest], | ||
) (*connect.Response[submit.ReadMempoolResponse], error) { | ||
|
||
log.Printf("Got a ReadMempool request") | ||
resp := &submit.ReadMempoolResponse{} | ||
|
||
return connect.NewResponse(resp), nil | ||
} | ||
|
||
// WatchMempool | ||
func (s *submitServiceServer) WatchMempool( | ||
ctx context.Context, | ||
req *connect.Request[submit.WatchMempoolRequest], | ||
stream *connect.ServerStream[submit.WatchMempoolResponse], | ||
) error { | ||
|
||
predicate := req.Msg.GetPredicate() // Predicate | ||
fieldMask := req.Msg.GetFieldMask() | ||
|
||
log.Printf( | ||
"Got a WatchMempool request with predicate %v and fieldMask %v", | ||
predicate, | ||
fieldMask, | ||
) | ||
return nil | ||
} |
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,99 @@ | ||
// Copyright 2024 Blink Labs Software | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package utxorpc | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
"connectrpc.com/connect" | ||
sync "github.com/utxorpc/go-codegen/utxorpc/v1alpha/sync" | ||
"github.com/utxorpc/go-codegen/utxorpc/v1alpha/sync/syncconnect" | ||
) | ||
|
||
// syncServiceServer implements the SyncService API | ||
type syncServiceServer struct { | ||
syncconnect.UnimplementedSyncServiceHandler | ||
} | ||
|
||
// FetchBlock | ||
func (s *syncServiceServer) FetchBlock( | ||
ctx context.Context, | ||
req *connect.Request[sync.FetchBlockRequest], | ||
) (*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, | ||
) | ||
|
||
resp := &sync.FetchBlockResponse{} | ||
// TODO: replace with something that works NtC | ||
// for _, point := range points { | ||
// log.Printf("Point Slot: %d, Hash: %x\n", point.Slot, point.Hash) | ||
// block, err := oConn.BlockFetch().Client.GetBlock( | ||
// ocommon.NewPoint(point.Slot, point.Hash), | ||
// ) | ||
// if err != nil { | ||
// return nil, err | ||
// } | ||
// var acb sync.AnyChainBlock | ||
// var acbc sync.AnyChainBlock_Cardano | ||
// ret := NewBlockFromBlock(block) | ||
// acbc.Cardano = &ret | ||
// acb.Chain = &acbc | ||
// resp.Block = append(resp.Block, &acb) | ||
// } | ||
|
||
return connect.NewResponse(resp), nil | ||
} | ||
|
||
// DumpHistory | ||
func (s *syncServiceServer) DumpHistory( | ||
ctx context.Context, | ||
req *connect.Request[sync.DumpHistoryRequest], | ||
) (*connect.Response[sync.DumpHistoryResponse], error) { | ||
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, | ||
) | ||
|
||
resp := &sync.DumpHistoryResponse{} | ||
// TODO: the thing | ||
return connect.NewResponse(resp), nil | ||
} | ||
|
||
// FollowTip | ||
func (s *syncServiceServer) FollowTip( | ||
ctx context.Context, | ||
req *connect.Request[sync.FollowTipRequest], | ||
stream *connect.ServerStream[sync.FollowTipResponse], | ||
) error { | ||
intersect := req.Msg.GetIntersect() // []*BlockRef | ||
|
||
log.Printf("Got a FollowTip request with intersect %v", intersect) | ||
|
||
// TODO: the thing | ||
return nil | ||
} |
Oops, something went wrong.