1
1
package docgen
2
2
3
3
import (
4
- "encoding/json"
5
4
"fmt"
6
5
"go/ast"
7
6
"go/parser"
@@ -12,39 +11,22 @@ import (
12
11
"time"
13
12
"unicode"
14
13
14
+ "github.com/filecoin-project/boost/api"
15
15
"github.com/filecoin-project/boost/datatransfer"
16
- "github.com/filecoin-project/boost/retrievalmarket/types/legacyretrievaltypes"
16
+ types2 "github.com/filecoin-project/boost/storagemarket/types"
17
+ "github.com/filecoin-project/boost/storagemarket/types/dealcheckpoints"
17
18
"github.com/filecoin-project/boost/storagemarket/types/legacytypes/filestore"
18
- "github.com/filecoin-project/go-address"
19
- "github.com/filecoin-project/go-bitfield"
20
19
"github.com/filecoin-project/go-jsonrpc/auth"
21
- "github.com/google/uuid "
22
- "github.com/ipfs /go-cid "
23
- "github.com/ipfs /go-graphsync "
24
- textselector "github.com/ipld/go-ipld-selector-text-lite "
20
+ "github.com/filecoin-project/go-state-types/abi "
21
+ "github.com/filecoin-project /go-state-types/builtin/v9/verifreg "
22
+ "github.com/filecoin-project /go-state-types/crypto "
23
+ apitypes "github.com/filecoin-project/lotus/api/types "
25
24
pubsub "github.com/libp2p/go-libp2p-pubsub"
26
25
"github.com/libp2p/go-libp2p/core/metrics"
27
26
"github.com/libp2p/go-libp2p/core/network"
28
27
"github.com/libp2p/go-libp2p/core/peer"
29
28
"github.com/libp2p/go-libp2p/core/protocol"
30
29
"github.com/multiformats/go-multiaddr"
31
-
32
- "github.com/filecoin-project/go-state-types/abi"
33
- "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
34
- "github.com/filecoin-project/go-state-types/crypto"
35
- "github.com/filecoin-project/go-state-types/exitcode"
36
-
37
- "github.com/filecoin-project/boost/api"
38
- types2 "github.com/filecoin-project/boost/storagemarket/types"
39
- "github.com/filecoin-project/boost/storagemarket/types/dealcheckpoints"
40
- lapi "github.com/filecoin-project/lotus/api"
41
- apitypes "github.com/filecoin-project/lotus/api/types"
42
- "github.com/filecoin-project/lotus/build"
43
- "github.com/filecoin-project/lotus/chain/types"
44
- "github.com/filecoin-project/lotus/node/modules/dtypes"
45
- "github.com/filecoin-project/lotus/node/repo/imports"
46
- "github.com/filecoin-project/lotus/storage/sealer/sealtasks"
47
- "github.com/filecoin-project/lotus/storage/sealer/storiface"
48
30
"golang.org/x/text/cases"
49
31
"golang.org/x/text/language"
50
32
)
@@ -62,97 +44,32 @@ func addExample(v interface{}) {
62
44
}
63
45
64
46
func init () {
65
- c , err := cid .Decode ("bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" )
66
- if err != nil {
67
- panic (err )
68
- }
69
-
70
- ExampleValues [reflect .TypeOf (c )] = c
71
-
72
- c2 , err := cid .Decode ("bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" )
73
- if err != nil {
74
- panic (err )
75
- }
76
-
77
- tsk := types .NewTipSetKey (c , c2 )
78
-
79
- ExampleValues [reflect .TypeOf (tsk )] = tsk
80
-
81
- addr , err := address .NewIDAddress (1234 )
82
- if err != nil {
83
- panic (err )
84
- }
85
-
86
- ExampleValues [reflect .TypeOf (addr )] = addr
87
-
88
47
pid , err := peer .Decode ("12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf" )
89
48
if err != nil {
90
49
panic (err )
91
50
}
92
51
addExample (pid )
93
52
addExample (& pid )
94
53
95
- storeIDExample := imports .ID (50 )
96
- textSelExample := textselector .Expression ("Links/21/Hash/Links/42/Hash" )
97
- clientEvent := legacyretrievaltypes .ClientEventDealAccepted
98
-
99
- addExample (bitfield .NewFromSet ([]uint64 {5 }))
100
- addExample (abi .RegisteredSealProof_StackedDrg32GiBV1_1 )
101
- addExample (abi .RegisteredPoStProof_StackedDrgWindow32GiBV1 )
102
54
addExample (abi .ChainEpoch (10101 ))
103
55
addExample (crypto .SigTypeBLS )
104
- addExample (types .KTBLS )
105
56
addExample (int64 (9 ))
106
57
addExample (12.3 )
107
58
addExample (123 )
108
- addExample (uintptr (0 ))
109
- addExample (abi .MethodNum (1 ))
110
- addExample (exitcode .ExitCode (0 ))
111
- addExample (crypto .DomainSeparationTag_ElectionProofProduction )
112
59
addExample (true )
113
60
addExample (abi .UnpaddedPieceSize (1024 ))
114
61
addExample (abi .UnpaddedPieceSize (1024 ).Padded ())
115
62
addExample (abi .DealID (5432 ))
116
63
addExample (abi .SectorNumber (9 ))
117
- addExample (abi .SectorSize (32 * 1024 * 1024 * 1024 ))
118
- addExample (api .MpoolChange (0 ))
119
64
addExample (network .Connected )
120
- addExample (dtypes .NetworkName ("lotus" ))
121
- addExample (api .SyncStateStage (1 ))
122
- addExample (api .FullAPIVersion1 )
123
- addExample (api .PCHInbound )
124
65
addExample (time .Minute )
125
- addExample (graphsync .NewRequestID ())
126
66
addExample (datatransfer .TransferID (3 ))
127
- addExample (datatransfer .Ongoing )
128
- addExample (storeIDExample )
129
- addExample (& storeIDExample )
130
- addExample (clientEvent )
131
- addExample (& clientEvent )
132
- addExample (legacyretrievaltypes .ClientEventDealAccepted )
133
- addExample (legacyretrievaltypes .DealStatusNew )
134
- addExample (& textSelExample )
135
67
addExample (network .ReachabilityPublic )
136
- addExample (build .TestNetworkVersion )
137
68
allocationID := verifreg .AllocationId (0 )
138
69
addExample (allocationID )
139
- addExample (& allocationID )
140
70
addExample (filestore .Path ("" ))
141
71
addExample (map [string ]int {"name" : 42 })
142
72
addExample (map [string ]time.Time {"name" : time .Unix (1615243938 , 0 ).UTC ()})
143
- addExample (& types.ExecutionTrace {
144
- Msg : ExampleValue ("init" , reflect .TypeOf (types.MessageTrace {}), nil ).(types.MessageTrace ),
145
- MsgRct : ExampleValue ("init" , reflect .TypeOf (types.ReturnTrace {}), nil ).(types.ReturnTrace ),
146
- })
147
- addExample (map [string ]types.Actor {
148
- "t01236" : ExampleValue ("init" , reflect .TypeOf (types.Actor {}), nil ).(types.Actor ),
149
- })
150
- addExample (map [string ]api.MarketDeal {
151
- "t026363" : ExampleValue ("init" , reflect .TypeOf (api.MarketDeal {}), nil ).(api.MarketDeal ),
152
- })
153
- addExample (map [string ]api.MarketBalance {
154
- "t026363" : ExampleValue ("init" , reflect .TypeOf (api.MarketBalance {}), nil ).(api.MarketBalance ),
155
- })
156
73
addExample (map [string ]* pubsub.TopicScoreSnapshot {
157
74
"/blocks" : {
158
75
TimeInMesh : time .Minute ,
@@ -177,91 +94,14 @@ func init() {
177
94
TotalOut : 12500 ,
178
95
},
179
96
})
180
-
97
+ //
181
98
maddr , err := multiaddr .NewMultiaddr ("/ip4/52.36.61.156/tcp/1347/p2p/12D3KooWFETiESTf1v4PGUvtnxMAcEFMzLZbJGg4tjWfGEimYior" )
182
99
if err != nil {
183
100
panic (err )
184
101
}
185
102
186
103
// because reflect.TypeOf(maddr) returns the concrete type...
187
104
ExampleValues [reflect .TypeOf (struct { A multiaddr.Multiaddr }{}).Field (0 ).Type ] = maddr
188
-
189
- // miner specific
190
- si := uint64 (12 )
191
- addExample (& si )
192
- addExample (legacyretrievaltypes .DealID (5 ))
193
- addExample (abi .ActorID (1000 ))
194
- addExample (storiface .ID ("76f1988b-ef30-4d7e-b3ec-9a627f4ba5a8" ))
195
- addExample (storiface .FTUnsealed )
196
- addExample (storiface .PathSealing )
197
- addExample (map [storiface.ID ][]storiface.Decl {
198
- "76f1988b-ef30-4d7e-b3ec-9a627f4ba5a8" : {
199
- {
200
- SectorID : abi.SectorID {Miner : 1000 , Number : 100 },
201
- SectorFileType : storiface .FTSealed ,
202
- },
203
- },
204
- })
205
- addExample (map [storiface.ID ]string {
206
- "76f1988b-ef30-4d7e-b3ec-9a627f4ba5a8" : "/data/path" ,
207
- })
208
- addExample (map [uuid.UUID ][]storiface.WorkerJob {
209
- uuid .MustParse ("ef8d99a2-6865-4189-8ffa-9fef0f806eee" ): {
210
- {
211
- ID : storiface.CallID {
212
- Sector : abi.SectorID {Miner : 1000 , Number : 100 },
213
- ID : uuid .MustParse ("76081ba0-61bd-45a5-bc08-af05f1c26e5d" ),
214
- },
215
- Sector : abi.SectorID {Miner : 1000 , Number : 100 },
216
- Task : sealtasks .TTPreCommit2 ,
217
- RunWait : 0 ,
218
- Start : time .Unix (1605172927 , 0 ).UTC (),
219
- Hostname : "host" ,
220
- },
221
- },
222
- })
223
- addExample (map [uuid.UUID ]storiface.WorkerStats {
224
- uuid .MustParse ("ef8d99a2-6865-4189-8ffa-9fef0f806eee" ): {
225
- Info : storiface.WorkerInfo {
226
- Hostname : "host" ,
227
- Resources : storiface.WorkerResources {
228
- MemPhysical : 256 << 30 ,
229
- MemUsed : 2 << 30 ,
230
- MemSwap : 120 << 30 ,
231
- MemSwapUsed : 2 << 30 ,
232
- CPUs : 64 ,
233
- GPUs : []string {"aGPU 1337" },
234
- Resources : storiface .ResourceTable ,
235
- },
236
- },
237
- Enabled : true ,
238
- MemUsedMin : 0 ,
239
- MemUsedMax : 0 ,
240
- GpuUsed : 0 ,
241
- CpuUse : 0 ,
242
- },
243
- })
244
- addExample (storiface .ErrorCode (0 ))
245
- addExample (map [abi.SectorNumber ]string {
246
- 123 : "can't acquire read lock" ,
247
- })
248
- addExample (json .RawMessage (`"json raw message"` ))
249
- addExample ([]abi.SectorNumber {123 , 124 })
250
- addExample ([]storiface.SectorLock {
251
- {
252
- Sector : abi.SectorID {Number : 123 , Miner : 1000 },
253
- Write : [storiface .FileTypes ]uint {0 , 0 , 1 },
254
- Read : [storiface .FileTypes ]uint {2 , 3 , 0 },
255
- },
256
- })
257
-
258
- // worker specific
259
- addExample (storiface .AcquireMove )
260
- addExample (storiface .UnpaddedByteIndex (abi .PaddedPieceSize (1 << 20 ).Unpadded ()))
261
- addExample (map [sealtasks.TaskType ]struct {}{
262
- sealtasks .TTPreCommit2 : {},
263
- })
264
- addExample (sealtasks .TTCommit2 )
265
105
addExample (apitypes.OpenRPCDocument {
266
106
"openrpc" : "1.2.6" ,
267
107
"info" : map [string ]interface {}{
@@ -270,18 +110,6 @@ func init() {
270
110
},
271
111
"methods" : []interface {}{}},
272
112
)
273
-
274
- addExample (api .CheckStatusCode (0 ))
275
- addExample (map [string ]interface {}{"abc" : 123 })
276
- addExample (storiface .ResourceTable )
277
- addExample (network.ScopeStat {
278
- Memory : 123 ,
279
- NumStreamsInbound : 1 ,
280
- NumStreamsOutbound : 2 ,
281
- NumConnsInbound : 3 ,
282
- NumConnsOutbound : 4 ,
283
- NumFD : 5 ,
284
- })
285
113
addExample (map [string ]network.ScopeStat {
286
114
"abc" : {
287
115
Memory : 123 ,
@@ -292,17 +120,7 @@ func init() {
292
120
NumFD : 5 ,
293
121
}})
294
122
addExample (dealcheckpoints .Transferred )
295
- addExample (lapi .SubsystemMarkets )
296
123
addExample (types2 .DealRetryAuto )
297
- addExample (map [string ][]lapi.SealedRef {
298
- "98000" : {
299
- lapi.SealedRef {
300
- SectorID : 100 ,
301
- Offset : 10 << 20 ,
302
- Size : 1 << 20 ,
303
- },
304
- },
305
- })
306
124
}
307
125
308
126
func GetAPIType (name , pkg string ) (i interface {}, t reflect.Type , permStruct []reflect.Type ) {
0 commit comments