One more RPC (get_server_height), and update comment
to include full RPC name.
This commit is contained in:
parent
b298454727
commit
71e79c553e
3 changed files with 43 additions and 1 deletions
|
@ -87,6 +87,18 @@ func min[Ord constraints.Ordered](x, y Ord) Ord {
|
|||
return y
|
||||
}
|
||||
|
||||
type BlockGetServerHeightReq struct{}
|
||||
type BlockGetServerHeightResp uint32
|
||||
|
||||
func (s *BlockchainService) Get_server_height(r *http.Request, req *BlockGetServerHeightReq, resp **BlockGetServerHeightResp) error {
|
||||
if s.DB == nil || s.DB.LastState == nil {
|
||||
return fmt.Errorf("unknown height")
|
||||
}
|
||||
result := BlockGetServerHeightResp(s.DB.LastState.Height)
|
||||
*resp = &result
|
||||
return nil
|
||||
}
|
||||
|
||||
type BlockGetChunkReq uint32
|
||||
type BlockGetChunkResp string
|
||||
|
||||
|
|
|
@ -8,6 +8,36 @@ import (
|
|||
"github.com/lbryio/lbcd/chaincfg"
|
||||
)
|
||||
|
||||
func TestServerGetHeight(t *testing.T) {
|
||||
dbPath := "/Users/swdev1/hub/scribe_db.599529/lbry-rocksdb"
|
||||
// dbPath := "/mnt/d/data/snapshot_1072108/lbry-rocksdb/"
|
||||
secondaryPath := "asdf"
|
||||
db, toDefer, err := db.GetProdDB(dbPath, secondaryPath)
|
||||
defer toDefer()
|
||||
if err != nil {
|
||||
t.Skip("DB not found")
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
s := &BlockchainService{
|
||||
DB: db,
|
||||
Chain: &chaincfg.MainNetParams,
|
||||
}
|
||||
|
||||
req := BlockGetServerHeightReq{}
|
||||
var resp *BlockGetServerHeightResp
|
||||
err = s.Get_server_height(nil, &req, &resp)
|
||||
if err != nil {
|
||||
t.Errorf("handler err: %v", err)
|
||||
}
|
||||
marshalled, err := json.MarshalIndent(resp, "", " ")
|
||||
if err != nil {
|
||||
t.Errorf("unmarshal err: %v", err)
|
||||
}
|
||||
t.Logf("resp: %v", string(marshalled))
|
||||
}
|
||||
|
||||
func TestGetChunk(t *testing.T) {
|
||||
dbPath := "/Users/swdev1/hub/scribe_db.599529/lbry-rocksdb"
|
||||
// dbPath := "/mnt/d/data/snapshot_1072108/lbry-rocksdb/"
|
||||
|
|
|
@ -23,7 +23,7 @@ type Result struct {
|
|||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
// Resolve is the json rpc endpoint for resolve
|
||||
// Resolve is the json rpc endpoint for 'blockchain.claimtrie.resolve'.
|
||||
func (t *ClaimtrieService) Resolve(r *http.Request, args *ResolveData, result **pb.Outputs) error {
|
||||
log.Println("Resolve")
|
||||
res, err := InternalResolve(args.Data, t.DB)
|
||||
|
|
Loading…
Reference in a new issue