Skip to content

Commit

Permalink
api: add NetDisconnect api
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode committed Jul 7, 2022
1 parent 56fa2ae commit a4ac2e5
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/submodule/network/network_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,8 @@ func (na *networkAPI) NetAddrsListen(context.Context) (peer.AddrInfo, error) {
Addrs: na.network.Host.Addrs(),
}, nil
}

// NetDisconnect disconnect to peer at the given address
func (na *networkAPI) NetDisconnect(_ context.Context, p peer.ID) error {
return na.network.Network.Disconnect(p)
}
5 changes: 5 additions & 0 deletions pkg/net/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,8 @@ func (network *Network) Peers(ctx context.Context, verbose, latency, streams boo
sort.Sort(&out)
return &out, nil
}

// Disconnect disconnect to peer at the given address
func (network *Network) Disconnect(p peer.ID) error {
return network.host.Network().ClosePeer(p)
}
15 changes: 15 additions & 0 deletions venus-shared/api/chain/v0/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
* [MsigSwapPropose](#MsigSwapPropose)
* [Network](#Network)
* [NetAddrsListen](#NetAddrsListen)
* [NetDisconnect](#NetDisconnect)
* [NetworkConnect](#NetworkConnect)
* [NetworkFindPeer](#NetworkFindPeer)
* [NetworkFindProvidersAsync](#NetworkFindProvidersAsync)
Expand Down Expand Up @@ -4018,6 +4019,20 @@ Response:
}
```

### NetDisconnect


Perms: write

Inputs:
```json
[
"12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf"
]
```

Response: `{}`

### NetworkConnect


Expand Down
14 changes: 14 additions & 0 deletions venus-shared/api/chain/v0/mock/mock_fullnode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions venus-shared/api/chain/v0/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ type INetwork interface {
NetworkPing(context.Context, peer.ID) (time.Duration, error) //perm:read
Version(context.Context) (types.Version, error) //perm:read
NetAddrsListen(context.Context) (peer.AddrInfo, error) //perm:read
NetDisconnect(context.Context, peer.ID) error //perm:write
}
4 changes: 4 additions & 0 deletions venus-shared/api/chain/v0/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions venus-shared/api/chain/v1/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
* [MsigSwapPropose](#MsigSwapPropose)
* [Network](#Network)
* [NetAddrsListen](#NetAddrsListen)
* [NetDisconnect](#NetDisconnect)
* [NetworkConnect](#NetworkConnect)
* [NetworkFindPeer](#NetworkFindPeer)
* [NetworkFindProvidersAsync](#NetworkFindProvidersAsync)
Expand Down Expand Up @@ -4409,6 +4410,20 @@ Response:
}
```

### NetDisconnect


Perms: write

Inputs:
```json
[
"12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf"
]
```

Response: `{}`

### NetworkConnect


Expand Down
14 changes: 14 additions & 0 deletions venus-shared/api/chain/v1/mock/mock_fullnode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions venus-shared/api/chain/v1/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ type INetwork interface {
NetworkPing(context.Context, peer.ID) (time.Duration, error) //perm:read
Version(context.Context) (types.Version, error) //perm:read
NetAddrsListen(context.Context) (peer.AddrInfo, error) //perm:read
NetDisconnect(context.Context, peer.ID) error //perm:write
}
4 changes: 4 additions & 0 deletions venus-shared/api/chain/v1/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions venus-shared/compatible-checks/api-diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v0.FullNode <> github.c
- NetBlockRemove
- NetConnect
- NetConnectedness
- NetDisconnect
- NetFindPeer
- NetLimit
- NetPeerInfo
Expand Down Expand Up @@ -296,7 +295,6 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.c
- NetBlockRemove
- NetConnect
- NetConnectedness
- NetDisconnect
- NetFindPeer
- NetLimit
- NetPeerInfo
Expand Down
1 change: 1 addition & 0 deletions venus-shared/compatible-checks/api-perm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ v0: github.com/filecoin-project/venus/venus-shared/api/chain/v0 <> github.com/fi
- IMessagePool.MpoolSelects
- IMultiSig.MsigCancelTxnHash
- INetwork.NetAddrsListen
- INetwork.NetDisconnect
- INetwork.NetworkConnect
- INetwork.NetworkFindPeer
- INetwork.NetworkFindProvidersAsync
Expand Down

0 comments on commit a4ac2e5

Please sign in to comment.