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
Andreas Triantafyllos
committed
Jul 23, 2019
1 parent
e3d8bea
commit 9fcd280
Showing
9 changed files
with
120 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
|
||
module TxGeneration ( | ||
handleTxGeneration | ||
) where | ||
|
||
import qualified Data.Set as Set | ||
import Data.String (fromString) | ||
|
||
import Control.Tracer | ||
|
||
import Ouroboros.Consensus.Demo.Run | ||
import qualified Ouroboros.Consensus.Ledger.Mock as Mock | ||
import Ouroboros.Consensus.Mempool | ||
import Ouroboros.Consensus.Node.ProtocolInfo | ||
import Ouroboros.Consensus.NodeId | ||
import qualified Ouroboros.Consensus.Protocol as Consensus | ||
|
||
import Topology | ||
import TxSubmission (submitTx) | ||
|
||
{------------------------------------------------------------------------------- | ||
Parsers for the generator's arguments | ||
-------------------------------------------------------------------------------} | ||
|
||
|
||
{------------------------------------------------------------------------------- | ||
Main logic | ||
-------------------------------------------------------------------------------} | ||
|
||
handleTxGeneration :: forall blk. | ||
RunDemo blk | ||
=> Consensus.Protocol blk | ||
-> TopologyInfo | ||
-> Tracer IO String | ||
-> IO () | ||
handleTxGeneration ptcl tinfo tracer = do | ||
let hashOfPreviousTx = fromString "aa" | ||
mocktx = Mock.Tx (Set.fromList [(hashOfPreviousTx, 0)]) [("a", 1000)] | ||
topoE <- readTopologyFile (topologyFile tinfo) | ||
NetworkTopology nodeSetups <- | ||
case topoE of | ||
Left e -> fail e | ||
Right t -> return t | ||
|
||
nid <- case node tinfo of | ||
CoreId nid -> return nid | ||
RelayId{} -> fail "Only core nodes are supported targets" | ||
|
||
let ProtocolInfo{pInfoConfig} = | ||
protocolInfo (NumCoreNodes (length nodeSetups)) | ||
(CoreNodeId nid) | ||
ptcl | ||
|
||
tx :: GenTx blk | ||
tx = demoMockTx pInfoConfig mocktx | ||
|
||
traceWith tracer $ "**************************************" | ||
traceWith tracer $ "Starting transaction generator" | ||
traceWith tracer $ "**************************************" | ||
|
||
submitTx pInfoConfig (node tinfo) tx tracer |
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,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
now=`date "+%Y-%m-%d 00:00:00"` | ||
CMD="stack exec --nix cardano-node -- " | ||
# CMD="cabal new-exec cardano-node -- " | ||
|
||
set -x | ||
${CMD} \ | ||
--system-start "$now" --slot-duration 2 \ | ||
--log-config configuration/log-configuration.yaml \ | ||
generate -t configuration/simple-topology.json \ | ||
$@ |
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