You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 18, 2020. It is now read-only.
In `switchToFork` we _add_ / _remove_ the relevant pending transactions to/from the submission layer (which corresponds with the Wallet Spec on possibly adding pendings during `rollback` and removing pendings during `applyBlock`):
1313
+
1314
+
```haskell
1315
+
switchToFork::PassiveWallet
1316
+
->Int--^ Number of blocks to roll back
1317
+
-> [ResolvedBlock] --^ Blocks in the new fork
1318
+
->IO (EitherRollbackDuringRestoration())
1319
+
switchToFork pw@PassiveWallet{..} n bs =do
1320
+
k <-Node.getSecurityParameter _walletNode
1321
+
blocksAndMeta <-mapM (prefilterBlock' pw) bs
1322
+
let (blockssByAccount, metas) =unzip blocksAndMeta
1323
+
res <- update' _wallets $SwitchToFork k n blockssByAccount
1324
+
case res of
1325
+
Left err ->return$Left err
1326
+
Right changes ->domapM_ (putTxMeta _walletMeta) $concat metas
* "must be a thread that periodically calls tick, to give the submission layer a chance to resubmit transactions that haven’t made it into the blockchain yet. The set of transactions returned by tick ... the wallet should remove such transactions from its pending set"
1311
1338
1312
-
The submission layer resource is managed in `bracketActiveWallet`.
1313
-
The resubmission function `tickFunction` calls `tick` and cancels any pending transactions returned:
1339
+
The submission layer resource is managed in `bracketActiveWallet` and is initialised with `tickFunction`, which calls `tick` and cancels any pending transactions returned:
1314
1340
1315
1341
```haskell
1316
1342
tickFunction::MVarWalletSubmission->IO()
@@ -1328,6 +1354,12 @@ tickFunction submissionLayer = do
1328
1354
#### cancelPending
1329
1355
1330
1356
```haskell
1357
+
--| Cancel a pending transaction
1358
+
--
1359
+
-- NOTE: This gets called in response to events /from/ the wallet submission
1360
+
-- layer, so we shouldn't be notifying the submission in return here.
1361
+
--
1362
+
-- This removes the transaction from either pending or foreign.
--| All the events we can schedule for a given 'Slot', partitioned into
1391
+
-- 'ScheduleSend' and 'ScheduleEvictIfNotConfirmed'.
1392
+
dataScheduleEvents=ScheduleEvents{
1393
+
_seToSend:: [ScheduleSend]
1394
+
--^ A list of transactions which we need to send.
1395
+
, _seToConfirm:: [ScheduleEvictIfNotConfirmed]
1396
+
--^ A list of transactions which we need to check if they have been
1397
+
-- confirmed (i.e. adopted) by the blockchain.
1398
+
}
1399
+
1400
+
```
1401
+
1402
+
*"When the submission layer is notified of new pending transactions, it adds those to its pending set and schedules them to be submitted in the next slot, recording an initial submission count of 0"
1403
+
1404
+
```haskell
1405
+
--| Schedule the full list of pending transactions.
1406
+
-- The transactions will be scheduled immediately in the next 'Slot'.
1407
+
schedulePending::HdAccountId
1408
+
->Pending
1409
+
->WalletSubmission
1410
+
->WalletSubmission
1411
+
schedulePending accId pending ws =
1412
+
let currentSlot = ws ^. wsState . wssCurrentSlot
1413
+
in addToSchedule ws (mapSlot succ currentSlot) toSend mempty
* "The state of the submission layer does not need to be persisted. If the wallet is shutdown for some period of time, the submission layer can simply be re-initialised from the state of the wallet, starting the submission process afresh for any transactions that the wallet still reports as pending."
0 commit comments