Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
burrow
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hang Yu
burrow
Commits
9db3ea02
Commit
9db3ea02
authored
8 years ago
by
Benjamin Bollen
Browse files
Options
Downloads
Patches
Plain Diff
make ErisMint implement manager/types.Application
parent
f0fa9c5e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
manager/eris-mint/eris-mint.go
+16
-7
16 additions, 7 deletions
manager/eris-mint/eris-mint.go
manager/manager.go
+50
-0
50 additions, 0 deletions
manager/manager.go
with
66 additions
and
7 deletions
manager/eris-mint/eris-mint.go
+
16
−
7
View file @
9db3ea02
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
manager/manager.go
0 → 100644
+
50
−
0
View file @
9db3ea02
// 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"
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment