2022-07-01 20:19:57 +02:00
|
|
|
# Nim-LibP2P
|
2023-01-20 15:47:40 +01:00
|
|
|
# Copyright (c) 2023 Status Research & Development GmbH
|
2022-07-01 20:19:57 +02:00
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
|
|
|
# at your option.
|
|
|
|
# This file may not be copied, modified, or distributed except according to
|
|
|
|
# those terms.
|
2021-03-18 09:20:36 -06:00
|
|
|
|
2023-06-07 13:12:49 +02:00
|
|
|
{.push raises: [].}
|
2021-05-24 11:55:33 -06:00
|
|
|
|
2021-03-18 09:20:36 -06:00
|
|
|
import chronos
|
2022-09-22 21:55:59 +02:00
|
|
|
import stew/results
|
2021-03-18 09:20:36 -06:00
|
|
|
import peerid,
|
2022-05-18 10:19:37 +02:00
|
|
|
stream/connection,
|
|
|
|
transports/transport
|
2021-03-18 09:20:36 -06:00
|
|
|
|
2022-09-22 21:55:59 +02:00
|
|
|
export results
|
|
|
|
|
2021-03-18 09:20:36 -06:00
|
|
|
type
|
|
|
|
Dial* = ref object of RootObj
|
|
|
|
|
|
|
|
method connect*(
|
|
|
|
self: Dial,
|
2021-12-16 11:05:20 +01:00
|
|
|
peerId: PeerId,
|
2022-02-24 17:31:47 +01:00
|
|
|
addrs: seq[MultiAddress],
|
2023-01-25 11:19:03 +01:00
|
|
|
forceDial = false,
|
2023-04-14 16:23:19 +02:00
|
|
|
reuseConnection = true,
|
2023-11-29 17:38:47 +01:00
|
|
|
dir = Direction.Out) {.async, base.} =
|
2021-03-18 09:20:36 -06:00
|
|
|
## connect remote peer without negotiating
|
|
|
|
## a protocol
|
|
|
|
##
|
|
|
|
|
|
|
|
doAssert(false, "Not implemented!")
|
|
|
|
|
2022-09-05 14:31:14 +02:00
|
|
|
method connect*(
|
|
|
|
self: Dial,
|
2022-12-08 17:11:55 +01:00
|
|
|
address: MultiAddress,
|
|
|
|
allowUnknownPeerId = false): Future[PeerId] {.async, base.} =
|
2022-09-05 14:31:14 +02:00
|
|
|
## Connects to a peer and retrieve its PeerId
|
|
|
|
|
|
|
|
doAssert(false, "Not implemented!")
|
|
|
|
|
2021-03-18 09:20:36 -06:00
|
|
|
method dial*(
|
|
|
|
self: Dial,
|
2021-12-16 11:05:20 +01:00
|
|
|
peerId: PeerId,
|
2022-02-24 17:31:47 +01:00
|
|
|
protos: seq[string],
|
|
|
|
): Future[Connection] {.async, base.} =
|
2021-03-18 09:20:36 -06:00
|
|
|
## create a protocol stream over an
|
|
|
|
## existing connection
|
|
|
|
##
|
|
|
|
|
|
|
|
doAssert(false, "Not implemented!")
|
|
|
|
|
|
|
|
method dial*(
|
|
|
|
self: Dial,
|
2021-12-16 11:05:20 +01:00
|
|
|
peerId: PeerId,
|
2021-03-18 09:20:36 -06:00
|
|
|
addrs: seq[MultiAddress],
|
2022-02-24 17:31:47 +01:00
|
|
|
protos: seq[string],
|
|
|
|
forceDial = false): Future[Connection] {.async, base.} =
|
2021-03-18 09:20:36 -06:00
|
|
|
## create a protocol stream and establish
|
|
|
|
## a connection if one doesn't exist already
|
|
|
|
##
|
|
|
|
|
|
|
|
doAssert(false, "Not implemented!")
|
2022-05-18 10:19:37 +02:00
|
|
|
|
|
|
|
method addTransport*(
|
|
|
|
self: Dial,
|
|
|
|
transport: Transport) {.base.} =
|
|
|
|
doAssert(false, "Not implemented!")
|
2022-08-23 17:49:07 +02:00
|
|
|
|
|
|
|
method tryDial*(
|
|
|
|
self: Dial,
|
|
|
|
peerId: PeerId,
|
2022-09-22 21:55:59 +02:00
|
|
|
addrs: seq[MultiAddress]): Future[Opt[MultiAddress]] {.async, base.} =
|
2022-08-23 17:49:07 +02:00
|
|
|
doAssert(false, "Not implemented!")
|