[contracts] Start contract interactions when node starts
This commit is contained in:
parent
142ddd0fd3
commit
59f75fc540
|
@ -42,3 +42,11 @@ proc new*(_: type ContractInteractions,
|
||||||
|
|
||||||
proc new*(_: type ContractInteractions): ContractInteractions =
|
proc new*(_: type ContractInteractions): ContractInteractions =
|
||||||
ContractInteractions.new("ws://localhost:8545")
|
ContractInteractions.new("ws://localhost:8545")
|
||||||
|
|
||||||
|
proc start*(interactions: ContractInteractions) {.async.} =
|
||||||
|
interactions.sales.start()
|
||||||
|
interactions.proving.start()
|
||||||
|
|
||||||
|
proc stop*(interactions: ContractInteractions) {.async.} =
|
||||||
|
interactions.sales.stop()
|
||||||
|
interactions.proving.stop()
|
||||||
|
|
|
@ -51,6 +51,9 @@ proc start*(node: DaggerNodeRef) {.async.} =
|
||||||
await node.erasure.start()
|
await node.erasure.start()
|
||||||
await node.discovery.start()
|
await node.discovery.start()
|
||||||
|
|
||||||
|
if not node.contracts.isNil:
|
||||||
|
await node.contracts.start()
|
||||||
|
|
||||||
node.networkId = node.switch.peerInfo.peerId
|
node.networkId = node.switch.peerInfo.peerId
|
||||||
notice "Started dagger node", id = $node.networkId, addrs = node.switch.peerInfo.addrs
|
notice "Started dagger node", id = $node.networkId, addrs = node.switch.peerInfo.addrs
|
||||||
|
|
||||||
|
@ -62,6 +65,9 @@ proc stop*(node: DaggerNodeRef) {.async.} =
|
||||||
await node.erasure.stop()
|
await node.erasure.stop()
|
||||||
await node.discovery.stop()
|
await node.discovery.stop()
|
||||||
|
|
||||||
|
if not node.contracts.isNil:
|
||||||
|
await node.contracts.stop()
|
||||||
|
|
||||||
proc findPeer*(
|
proc findPeer*(
|
||||||
node: DaggerNodeRef,
|
node: DaggerNodeRef,
|
||||||
peerId: PeerID): Future[?PeerRecord] {.async.} =
|
peerId: PeerID): Future[?PeerRecord] {.async.} =
|
||||||
|
|
|
@ -17,6 +17,7 @@ import pkg/dagger/node
|
||||||
import pkg/dagger/manifest
|
import pkg/dagger/manifest
|
||||||
import pkg/dagger/discovery
|
import pkg/dagger/discovery
|
||||||
import pkg/dagger/blocktype as bt
|
import pkg/dagger/blocktype as bt
|
||||||
|
import pkg/dagger/contracts
|
||||||
|
|
||||||
import ./helpers
|
import ./helpers
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ suite "Test Node":
|
||||||
store: NetworkStore
|
store: NetworkStore
|
||||||
node: DaggerNodeRef
|
node: DaggerNodeRef
|
||||||
discovery: Discovery
|
discovery: Discovery
|
||||||
|
contracts: ContractInteractions
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
file = open(path.splitFile().dir /../ "fixtures" / "test.jpg")
|
file = open(path.splitFile().dir /../ "fixtures" / "test.jpg")
|
||||||
|
@ -46,7 +48,8 @@ suite "Test Node":
|
||||||
discovery = Discovery.new(switch.peerInfo, Port(0))
|
discovery = Discovery.new(switch.peerInfo, Port(0))
|
||||||
engine = BlockExcEngine.new(localStore, wallet, network, discovery)
|
engine = BlockExcEngine.new(localStore, wallet, network, discovery)
|
||||||
store = NetworkStore.new(engine, localStore)
|
store = NetworkStore.new(engine, localStore)
|
||||||
node = DaggerNodeRef.new(switch, store, engine, nil, discovery, nil) # TODO: pass `Erasure`
|
contracts = ContractInteractions.new()
|
||||||
|
node = DaggerNodeRef.new(switch, store, engine, nil, discovery, contracts) # TODO: pass `Erasure`
|
||||||
|
|
||||||
await node.start()
|
await node.start()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue