Skip to content

Commit 926d924

Browse files
authored
feat: add Agent to Filecoin.Version ! (#12953)
feat: add Agent to `Filecoin.Version`
1 parent c1e5f5d commit 926d924

File tree

9 files changed

+21
-5
lines changed

9 files changed

+21
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- chore: upgrade drand client
2424
- chore: upgrade go-state-types with big.Int{} change that means an empty big.Int is now treated as zero for all operations ([filecoin-project/lotus#12936](https://github.com/filecoin-project/lotus/pull/12936))
2525
- feat: expose `ChainGetMessagesInTipset` in the Lotus Gateway API ([filecoin-project/lotus#12947](https://github.com/filecoin-project/lotus/pull/12947))
26+
- feat: add `Agent` to the `Filecoin.Version` response ([#12904](https://github.com/filecoin-project/lotus/issues/12904)) that will be used to identify the node type.
2627

2728
# UNRELEASED v.1.32.0
2829

api/api_common.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ type APIVersion struct {
7373

7474
// Seconds
7575
BlockDelay uint64
76+
77+
// Agent type, as reported to other nodes, e.g. "lotus"
78+
Agent string
7679
}
7780

7881
func (v APIVersion) String() string {

build/buildconstants/params.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ func BuildTypeString() string {
3838

3939
var Devnet = true
4040

41+
// The agent string used by the node and reported to other nodes in the network.
42+
const UserAgent = "lotus"
43+
4144
// Used by tests and some obscure tooling
4245
/* inline-gen template
4346
const TestNetworkVersion = network.Version{{.latestNetworkVersion}}

build/openrpc/gateway.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12117,7 +12117,8 @@
1211712117
{
1211812118
"Version": "string value",
1211912119
"APIVersion": 131840,
12120-
"BlockDelay": 42
12120+
"BlockDelay": 42,
12121+
"Agent": "string value"
1212112122
}
1212212123
],
1212312124
"additionalProperties": false,
@@ -12126,6 +12127,9 @@
1212612127
"title": "number",
1212712128
"type": "number"
1212812129
},
12130+
"Agent": {
12131+
"type": "string"
12132+
},
1212912133
"BlockDelay": {
1213012134
"title": "number",
1213112135
"type": "number"

documentation/en/api-v0-methods-miner.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ Response:
179179
{
180180
"Version": "string value",
181181
"APIVersion": 131840,
182-
"BlockDelay": 42
182+
"BlockDelay": 42,
183+
"Agent": "string value"
183184
}
184185
```
185186

documentation/en/api-v0-methods.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ Response:
276276
{
277277
"Version": "string value",
278278
"APIVersion": 131840,
279-
"BlockDelay": 42
279+
"BlockDelay": 42,
280+
"Agent": "string value"
280281
}
281282
```
282283

documentation/en/api-v1-unstable-methods.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ Response:
360360
{
361361
"Version": "string value",
362362
"APIVersion": 131840,
363-
"BlockDelay": 42
363+
"BlockDelay": 42,
364+
"Agent": "string value"
364365
}
365366
```
366367

node/impl/common/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ func (a *CommonAPI) Version(context.Context) (api.APIVersion, error) {
7070
APIVersion: v,
7171

7272
BlockDelay: buildconstants.BlockDelaySecs,
73+
Agent: buildconstants.UserAgent,
7374
}, nil
7475
}
7576

node/modules/lp2p/host.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"go.uber.org/fx"
2020

2121
"github.com/filecoin-project/lotus/build"
22+
"github.com/filecoin-project/lotus/build/buildconstants"
2223
"github.com/filecoin-project/lotus/node/modules/dtypes"
2324
"github.com/filecoin-project/lotus/node/modules/helpers"
2425
)
@@ -51,7 +52,7 @@ func Host(mctx helpers.MetricsCtx, buildVersion build.BuildVersion, lc fx.Lifecy
5152
libp2p.Peerstore(params.Peerstore),
5253
libp2p.NoListenAddrs,
5354
libp2p.Ping(true),
54-
libp2p.UserAgent("lotus-" + string(buildVersion)),
55+
libp2p.UserAgent(buildconstants.UserAgent + "-" + string(buildVersion)),
5556
}
5657
for _, o := range params.Opts {
5758
opts = append(opts, o...)

0 commit comments

Comments
 (0)