[contracts] Add ContractInteractions to dagger node

This commit is contained in:
Mark Spanbroek 2022-04-13 14:15:22 +02:00 committed by markspanbroek
parent 9cbf6d0b6c
commit 0738606303
3 changed files with 10 additions and 4 deletions

View File

@ -30,6 +30,7 @@ import ./blockexchange
import ./utils/fileutils import ./utils/fileutils
import ./erasure import ./erasure
import ./discovery import ./discovery
import ./contracts
type type
DaggerServer* = ref object DaggerServer* = ref object
@ -121,7 +122,8 @@ proc new*(T: type DaggerServer, config: DaggerConf): T =
engine = BlockExcEngine.new(localStore, wallet, network, discovery) engine = BlockExcEngine.new(localStore, wallet, network, discovery)
store = NetworkStore.new(engine, localStore) store = NetworkStore.new(engine, localStore)
erasure = Erasure.new(store, leoEncoderProvider, leoDecoderProvider) erasure = Erasure.new(store, leoEncoderProvider, leoDecoderProvider)
daggerNode = DaggerNodeRef.new(switch, store, engine, erasure, discovery) contracts = ContractInteractions.new()
daggerNode = DaggerNodeRef.new(switch, store, engine, erasure, discovery, contracts)
restServer = RestServerRef.new( restServer = RestServerRef.new(
daggerNode.initRestApi(), daggerNode.initRestApi(),
initTAddress("127.0.0.1" , config.apiPort), initTAddress("127.0.0.1" , config.apiPort),

View File

@ -28,6 +28,7 @@ import ./blockexchange
import ./streams import ./streams
import ./erasure import ./erasure
import ./discovery import ./discovery
import ./contracts
logScope: logScope:
topics = "dagger node" topics = "dagger node"
@ -42,6 +43,7 @@ type
engine*: BlockExcEngine engine*: BlockExcEngine
erasure*: Erasure erasure*: Erasure
discovery*: Discovery discovery*: Discovery
contracts*: ContractInteractions
proc start*(node: DaggerNodeRef) {.async.} = proc start*(node: DaggerNodeRef) {.async.} =
await node.switch.start() await node.switch.start()
@ -235,10 +237,12 @@ proc new*(
store: BlockStore, store: BlockStore,
engine: BlockExcEngine, engine: BlockExcEngine,
erasure: Erasure, erasure: Erasure,
discovery: Discovery): T = discovery: Discovery,
contracts: ContractInteractions): T =
T( T(
switch: switch, switch: switch,
blockStore: store, blockStore: store,
engine: engine, engine: engine,
erasure: erasure, erasure: erasure,
discovery: discovery) discovery: discovery,
contracts: contracts)

View File

@ -46,7 +46,7 @@ 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) # TODO: pass `Erasure` node = DaggerNodeRef.new(switch, store, engine, nil, discovery, nil) # TODO: pass `Erasure`
await node.start() await node.start()