@@ -31,6 +31,7 @@ import (
3131 "github.com/hyperledger/firefly-cli/internal/blockchain/ethereum/connector"
3232 "github.com/hyperledger/firefly-cli/internal/blockchain/ethereum/connector/ethconnect"
3333 "github.com/hyperledger/firefly-cli/internal/blockchain/ethereum/connector/evmconnect"
34+ "github.com/hyperledger/firefly-cli/internal/blockchain/ethereum/tessera"
3435 "github.com/hyperledger/firefly-cli/internal/docker"
3536 "github.com/hyperledger/firefly-cli/internal/log"
3637 "github.com/hyperledger/firefly-cli/pkg/types"
@@ -78,10 +79,10 @@ func (p *QuorumProvider) WriteConfig(options *types.InitOptions) error {
7879 }
7980
8081 // Generate tessera docker-entrypoint for each member
81- if ! p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerNone ) {
82+ if p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerTessera ) {
8283 l .Info (fmt .Sprintf ("generating tessera docker-entrypoint file for member %d" , i ))
8384 tesseraEntrypointOutputDirectory := filepath .Join (initDir , "tessera" , fmt .Sprintf ("tessera_%d" , i ))
84- if err := CreateTesseraEntrypoint (p .ctx , tesseraEntrypointOutputDirectory , p .stack .Name , len (p .stack .Members )); err != nil {
85+ if err := tessera . CreateTesseraEntrypoint (p .ctx , tesseraEntrypointOutputDirectory , p .stack .Name , len (p .stack .Members )); err != nil {
8586 return err
8687 }
8788 }
@@ -143,7 +144,7 @@ func (p *QuorumProvider) FirstTimeSetup() error {
143144 return err
144145 }
145146
146- if ! p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerNone ) {
147+ if p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerTessera ) {
147148 // Copy member specific tessera key files
148149 if err := p .dockerMgr .MkdirInVolume (p .ctx , tesseraVolumeNameMember , rootDir ); err != nil {
149150 return err
@@ -153,14 +154,14 @@ func (p *QuorumProvider) FirstTimeSetup() error {
153154 return err
154155 }
155156 // Copy tessera docker-entrypoint file
156- tmEntrypointPath := filepath .Join (tesseraDir , fmt .Sprintf ("tessera_%d" , i ), DockerEntrypoint )
157+ tmEntrypointPath := filepath .Join (tesseraDir , fmt .Sprintf ("tessera_%d" , i ), tessera . DockerEntrypoint )
157158 if err := p .dockerMgr .CopyFileToVolume (p .ctx , tesseraVolumeNameMember , tmEntrypointPath , rootDir ); err != nil {
158159 return err
159160 }
160161 }
161162
162163 // Copy quorum docker-entrypoint file
163- quorumEntrypointPath := filepath .Join (blockchainDir , fmt .Sprintf ("quorum_%d" , i ), DockerEntrypoint )
164+ quorumEntrypointPath := filepath .Join (blockchainDir , fmt .Sprintf ("quorum_%d" , i ), tessera . DockerEntrypoint )
164165 if err := p .dockerMgr .CopyFileToVolume (p .ctx , quorumVolumeNameMember , quorumEntrypointPath , rootDir ); err != nil {
165166 return err
166167 }
@@ -236,43 +237,46 @@ func (p *QuorumProvider) DeployFireFlyContract() (*types.ContractDeploymentResul
236237 return p .connector .DeployContract (contract , "FireFly" , p .stack .Members [0 ], nil )
237238}
238239
240+ func (p * QuorumProvider ) buildTesseraServiceDefinition (memberIdx int ) * docker.ServiceDefinition {
241+ return & docker.ServiceDefinition {
242+ ServiceName : fmt .Sprintf ("tessera_%d" , memberIdx ),
243+ Service : & docker.Service {
244+ Image : tesseraImage ,
245+ ContainerName : fmt .Sprintf ("%s_member%dtessera" , p .stack .Name , memberIdx ),
246+ Volumes : []string {fmt .Sprintf ("tessera_%d:/data" , memberIdx )},
247+ Logging : docker .StandardLogOptions ,
248+ Ports : []string {fmt .Sprintf ("%d:%s" , p .stack .ExposedPtmPort + (memberIdx * ExposedBlockchainPortMultiplier ), tessera .TmTpPort )}, // defaults 4100, 4110, 4120, 4130
249+ Environment : p .stack .EnvironmentVars ,
250+ EntryPoint : []string {"/bin/sh" , "-c" , "/data/docker-entrypoint.sh" },
251+ Deploy : map [string ]interface {}{"restart_policy" : map [string ]interface {}{"condition" : "on-failure" , "max_attempts" : int64 (3 )}},
252+ HealthCheck : & docker.HealthCheck {
253+ Test : []string {
254+ "CMD" ,
255+ "curl" ,
256+ "--fail" ,
257+ fmt .Sprintf ("http://localhost:%s/upcheck" , tessera .TmTpPort ),
258+ },
259+ Interval : "15s" , // 6000 requests in a day
260+ Retries : 30 ,
261+ },
262+ },
263+ VolumeNames : []string {fmt .Sprintf ("tessera_%d" , memberIdx )},
264+ }
265+ }
266+
239267func (p * QuorumProvider ) GetDockerServiceDefinitions () []* docker.ServiceDefinition {
240268 memberCount := len (p .stack .Members )
241269 serviceDefinitionsCount := memberCount
242- if ! p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerNone ) {
270+ if p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerTessera ) {
243271 serviceDefinitionsCount *= 2
244272 }
245273 serviceDefinitions := make ([]* docker.ServiceDefinition , serviceDefinitionsCount )
246274 connectorDependents := map [string ]string {}
247275 for i := 0 ; i < memberCount ; i ++ {
248276 var quorumDependsOn map [string ]map [string ]string
249- if ! p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerNone ) {
277+ if p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerTessera ) {
250278 quorumDependsOn = map [string ]map [string ]string {fmt .Sprintf ("tessera_%d" , i ): {"condition" : "service_healthy" }}
251- serviceDefinitions [i + memberCount ] = & docker.ServiceDefinition {
252- ServiceName : fmt .Sprintf ("tessera_%d" , i ),
253- Service : & docker.Service {
254- Image : tesseraImage ,
255- ContainerName : fmt .Sprintf ("%s_member%dtessera" , p .stack .Name , i ),
256- Volumes : []string {fmt .Sprintf ("tessera_%d:/data" , i )},
257- Logging : docker .StandardLogOptions ,
258- Ports : []string {fmt .Sprintf ("%d:%s" , p .stack .ExposedPtmPort + (i * ExposedBlockchainPortMultiplier ), TmTpPort )}, // defaults 4100, 4110, 4120, 4130
259- Environment : p .stack .EnvironmentVars ,
260- EntryPoint : []string {"/bin/sh" , "-c" , "/data/docker-entrypoint.sh" },
261- Deploy : map [string ]interface {}{"restart_policy" : map [string ]interface {}{"condition" : "on-failure" , "max_attempts" : int64 (3 )}},
262- HealthCheck : & docker.HealthCheck {
263- Test : []string {
264- "CMD" ,
265- "curl" ,
266- "--fail" ,
267- fmt .Sprintf ("http://localhost:%s/upcheck" , TmTpPort ),
268- },
269- Interval : "15s" , // 6000 requests in a day
270- Retries : 30 ,
271- },
272- },
273- VolumeNames : []string {fmt .Sprintf ("tessera_%d" , i )},
274- }
275-
279+ serviceDefinitions [i + memberCount ] = p .buildTesseraServiceDefinition (i )
276280 // No arm64 images for Tessera
277281 if runtime .GOARCH == "arm64" {
278282 serviceDefinitions [i + memberCount ].Service .Platform = "linux/amd64"
@@ -377,9 +381,9 @@ func (p *QuorumProvider) CreateAccount(args []string) (interface{}, error) {
377381
378382 // Tessera is an optional add-on to the quorum blockchain node provider
379383 var tesseraPubKey , tesseraKeysPath string
380- if ! p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerNone ) {
384+ if p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerTessera ) {
381385 tesseraKeysOutputDirectory := filepath .Join (directory , "tessera" , fmt .Sprintf ("tessera_%s" , memberIndex ), "keystore" )
382- _ , tesseraPubKey , tesseraKeysPath , err = CreateTesseraKeys (p .ctx , tesseraImage , tesseraKeysOutputDirectory , "" , "tm" )
386+ _ , tesseraPubKey , tesseraKeysPath , err = tessera . CreateTesseraKeys (p .ctx , tesseraImage , tesseraKeysOutputDirectory , "" , "tm" )
383387 if err != nil {
384388 return nil , err
385389 }
0 commit comments