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

make ErisMint implement manager/types.Application

parent f0fa9c5e
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
// 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")
}
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