-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
main,openrpc,main: refactor openrpc supporting code to own package
This eliminates code duplication. Signed-off-by: meows <b5c6@protonmail.com>
- Loading branch information
Showing
3 changed files
with
48 additions
and
206 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,41 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"log" | ||
|
||
"github.com/filecoin-project/lotus/api/apistruct" | ||
"github.com/filecoin-project/lotus/api/openrpc" | ||
) | ||
|
||
func main() { | ||
commonPermStruct := &apistruct.CommonStruct{} | ||
fullStruct := &apistruct.FullNodeStruct{} | ||
|
||
doc := openrpc.NewLotusOpenRPCDocument() | ||
|
||
doc.RegisterReceiverName("common", commonPermStruct) | ||
doc.RegisterReceiverName("full", fullStruct) | ||
|
||
out, err := doc.Discover() | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
|
||
jsonOut, err := json.MarshalIndent(out, "", " ") | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
|
||
fmt.Println(string(jsonOut)) | ||
|
||
// fmt.Println("---- (Comments?) Out:") | ||
// // out2, groupDocs := parseApiASTInfo() | ||
// out2, _ := parseApiASTInfo() | ||
// out2JSON, _ := json.MarshalIndent(out2, "", " ") | ||
// fmt.Println(string(out2JSON)) | ||
// fmt.Println("---- (Group Comments?):") | ||
// groupDocsJSON, _ := json.MarshalIndent(groupDocs, "", " ") | ||
// fmt.Println(string(groupDocsJSON)) | ||
} |
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