diff --git a/core/core.go b/core/core.go index 7f422e82825deb6766051ed5ea5fe54b9cf37a85..495addb58b08fbafd127afc72cb5bdadd5589041 100644 --- a/core/core.go +++ b/core/core.go @@ -17,19 +17,28 @@ package core import ( + // TODO: [ben] swap out go-events with eris-db/event (currently unused) + events "github.com/tendermint/go-events" + config "github.com/eris-ltd/eris-db/config" consensus "github.com/eris-ltd/eris-db/consensus" + // manager "github.com/eris-ltd/eris-db/manager" ) // Core is the high-level structure type Core struct { chainId string + evsw *events.EventSwitch // pipe Pipe } func NewCore(chainId string, consensusConfig *config.ModuleConfig, managerConfig *config.ModuleConfig) *Core { + // start new event switch, TODO: [ben] replace with eris-db/event + evsw := events.NewEventSwitch() + evsw.Start() + consensus.NewConsensusEngine(consensusConfig) // create state @@ -42,3 +51,10 @@ func NewCore(chainId string, consensusConfig *config.ModuleConfig, // create servers return &Core{} } + +//------------------------------------------------------------------------------ +// Explicit switch that can later be abstracted into an `Engine` definition +// where the Engine defines the explicit interaction of a specific application +// manager with a consensus engine. +// TODO: [ben] before such Engine abstraction, +// think about many-manager-to-one-consensus diff --git a/manager/eris-mint/eris-mint_test.go b/manager/eris-mint/eris-mint_test.go new file mode 100644 index 0000000000000000000000000000000000000000..51633878f0b638a7ee6cd3445fd1828aa0415a66 --- /dev/null +++ b/manager/eris-mint/eris-mint_test.go @@ -0,0 +1,35 @@ +// Copyright 2015, 2016 Eris Industries (UK) Ltd. +// This file is part of Eris-RT + +// Eris-RT is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Eris-RT is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Eris-RT. If not, see <http://www.gnu.org/licenses/>. + +package erismint + +import ( + "fmt" + "testing" + + assert "github.com/stretchr/testify/assert" +) + +func TestCompatibleConsensus(t *testing.T) { + // TODO: [ben] expand by constructing and elemetary testing for each listed + // compatible consensus engine + + for _, listedConsensus := range compatibleConsensus { + assert.Equal(t, IsCompatibleConsensus(listedConsensus), true, + fmt.Sprintf("ErisMint (%s) failed compatibility test with consensus %s", + GetErisMintVersion(), listedConsensus)) + } +} diff --git a/manager/eris-mint/pipe.go b/manager/eris-mint/pipe.go new file mode 100644 index 0000000000000000000000000000000000000000..5fb7f499feef2972f80a81cf21e8df6119fed077 --- /dev/null +++ b/manager/eris-mint/pipe.go @@ -0,0 +1,25 @@ +// Copyright 2015, 2016 Eris Industries (UK) Ltd. +// This file is part of Eris-RT + +// Eris-RT is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Eris-RT is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Eris-RT. If not, see <http://www.gnu.org/licenses/>. + +package erismint + +type ErisMintPipe struct { + +} + +func NewErisMintPipe() *ErisMintPipe { + return &ErisMintPipe{} +} diff --git a/manager/eris-mint/version.go b/manager/eris-mint/version.go index bfc3b18c18c8335f686e0a3ffa56436c80594969..96f42c5f60791b85a0a74c8f674d39fb3753ab80 100644 --- a/manager/eris-mint/version.go +++ b/manager/eris-mint/version.go @@ -31,7 +31,23 @@ const ( erisMintVersionPatch = 0 ) +// Define the compatible consensus engines this application manager +// is compatible and has been tested with. +var compatibleConsensus = [...]string { + "tendermint-0.6", + "tmsp-0.6", +} + func GetErisMintVersion() *version.VersionIdentifier { return version.New(erisMintClientIdentifier, erisMintVersionMajor, erisMintVersionMinor, erisMintVersionPatch) } + +func IsCompatibleConsensus(consensusMinorVersion string) bool { + for _, supported := range compatibleConsensus { + if consensusMinorVersion == supported { + return true + } + } + return false +} diff --git a/manager/manager.go b/manager/manager.go index e525321c7c50dcddc7a58efac4c71c474019b775..77e0d9b8b835d196150b099b7c0519b9ff227d3b 100644 --- a/manager/manager.go +++ b/manager/manager.go @@ -14,9 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Eris-RT. If not, see <http://www.gnu.org/licenses/>. -// version provides the current Eris-DB version and a VersionIdentifier -// for the modules to identify their version with. - package manager import ( @@ -32,10 +29,12 @@ import ( // NOTE: [ben] Currently we only have a single `generic` definition // of an application. It is feasible this will be insufficient to support // different types of applications later down the line. -func NewApplication(moduleConfig *config.ModuleConfig) (types.Application, +func NewApplication(moduleConfig *config.ModuleConfig, + consensusMinorVersion string) (types.Application, error) { switch moduleConfig.Name { case "erismint" : + return newErisMintPH(moduleConfig) } return nil, fmt.Errorf("PLACEHOLDER")