diff --git a/manager/eris-mint/eris-mint.go b/manager/eris-mint/eris-mint.go index 8eb514b44bc863b09cc8e5d6f94ecc2a1d9061d9..a3e9c46d805ff2a3f7f8480ce28dde07e93e4836 100644 --- a/manager/eris-mint/eris-mint.go +++ b/manager/eris-mint/eris-mint.go @@ -30,8 +30,9 @@ import ( log "github.com/eris-ltd/eris-logger" - sm "github.com/eris-ltd/eris-db/manager/eris-mint/state" - types "github.com/eris-ltd/eris-db/txs" + manager_types "github.com/eris-ltd/eris-db/manager/types" + sm "github.com/eris-ltd/eris-db/manager/eris-mint/state" + types "github.com/eris-ltd/eris-db/txs" ) //-------------------------------------------------------------------------------- @@ -56,6 +57,14 @@ type ErisMint struct { nTxs int // count txs in a block } +// NOTE [ben] Compiler check to ensure ErisMint successfully implements +// eris-db/manager/types.Application +var _ manager_types.Application = (*ErisMint)(nil) +// NOTE: [ben] also automatically implements tmsp.Application, +// undesired but unharmful +// var _ tmsp.Application = (*ErisMint)(nil) + + func (app *ErisMint) GetState() *sm.State { app.mtx.Lock() defer app.mtx.Unlock() @@ -104,17 +113,17 @@ func NewErisMint(s *sm.State, evsw *events.EventSwitch) *ErisMint { } } -// Implements tmsp.Application +// Implements manager/types.Application func (app *ErisMint) Info() (info string) { return "ErisDB" } -// Implements tmsp.Application +// Implements manager/types.Application func (app *ErisMint) SetOption(key string, value string) (log string) { return "" } -// Implements tmsp.Application +// Implements manager/types.Application func (app *ErisMint) AppendTx(txBytes []byte) (res tmsp.Result) { app.nTxs += 1 @@ -139,7 +148,7 @@ func (app *ErisMint) AppendTx(txBytes []byte) (res tmsp.Result) { return tmsp.NewResultOK(nil, "Success") } -// Implements tmsp.Application +// Implements manager/types.Application func (app *ErisMint) CheckTx(txBytes []byte) (res tmsp.Result) { var n int var err error @@ -162,7 +171,7 @@ func (app *ErisMint) CheckTx(txBytes []byte) (res tmsp.Result) { return tmsp.NewResultOK(nil, "Success") } -// Implements tmsp.Application +// Implements manager/types.Application // Commit the state (called at end of block) // NOTE: CheckTx/AppendTx must not run concurrently with Commit - // the mempool should run during AppendTxs, but lock for Commit and Update diff --git a/manager/manager.go b/manager/manager.go new file mode 100644 index 0000000000000000000000000000000000000000..e525321c7c50dcddc7a58efac4c71c474019b775 --- /dev/null +++ b/manager/manager.go @@ -0,0 +1,50 @@ +// 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/>. + +// version provides the current Eris-DB version and a VersionIdentifier +// for the modules to identify their version with. + +package manager + +import ( + "fmt" + + config "github.com/eris-ltd/eris-db/config" + erismint "github.com/eris-ltd/eris-db/manager/eris-mint" + types "github.com/eris-ltd/eris-db/manager/types" +) + +// NewApplication returns an initialised application interface +// based on the loaded module configuration file. +// 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, + error) { + switch moduleConfig.Name { + case "erismint" : + return newErisMintPH(moduleConfig) + } + return nil, fmt.Errorf("PLACEHOLDER") +} + +//------------------------------------------------------------------------------ +// Eris-Mint + +func newErisMintPH(moduleConfig *config.ModuleConfig) (*erismint.ErisMint, + error) { + return nil, fmt.Errorf("PLACEHOLDER") +}