-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
172 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import Blockchain | ||
import Utils | ||
|
||
struct BlockchainServices { | ||
let config: ProtocolConfigRef | ||
let timeProvider: MockTimeProvider | ||
let dataProvider: BlockchainDataProvider | ||
let eventBus: EventBus | ||
let scheduler: MockScheduler | ||
let keystore: KeyStore | ||
let storeMiddleware: StoreMiddleware | ||
let blockchain: Blockchain | ||
let genesisBlock: BlockRef | ||
let genesisState: StateRef | ||
|
||
init( | ||
config: ProtocolConfigRef = .dev, | ||
timeProvider: MockTimeProvider = MockTimeProvider(time: 988) | ||
) async throws { | ||
self.config = config | ||
self.timeProvider = timeProvider | ||
|
||
let (genesisState, genesisBlock) = try State.devGenesis(config: config) | ||
self.genesisBlock = genesisBlock | ||
self.genesisState = genesisState | ||
dataProvider = try await BlockchainDataProvider(InMemoryDataProvider(genesisState: genesisState, genesisBlock: genesisBlock)) | ||
|
||
storeMiddleware = StoreMiddleware() | ||
eventBus = EventBus(eventMiddleware: .serial(Middleware(storeMiddleware), .noError), handlerMiddleware: .noError) | ||
|
||
scheduler = MockScheduler(timeProvider: timeProvider) | ||
|
||
keystore = try await DevKeyStore() | ||
|
||
blockchain = try await Blockchain( | ||
config: config, | ||
dataProvider: dataProvider, | ||
timeProvider: timeProvider, | ||
eventBus: eventBus | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.