Skip to content
Snippets Groups Projects
Commit 1d741294 authored by Benjamin Bollen's avatar Benjamin Bollen
Browse files

Define CompatibleConsensus for ErisMint

Implement Pipe explicitly for ErisMint (placeholder);


Signed-off-by: default avatarBenjamin Bollen <ben@erisindustries.com>
parent 9b57e250
No related branches found
No related tags found
No related merge requests found
......@@ -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
// 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))
}
}
// 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{}
}
......@@ -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
}
......@@ -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")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment