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
d3ce6a79
Commit
d3ce6a79
authored
8 years ago
by
Ethan Buchman
Browse files
Options
Downloads
Patches
Plain Diff
forgot new config dir
parent
c5074d92
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
config/config.go
+143
-0
143 additions, 0 deletions
config/config.go
txs/tx.go
+16
-0
16 additions, 0 deletions
txs/tx.go
with
159 additions
and
0 deletions
config/config.go
0 → 100644
+
143
−
0
View file @
d3ce6a79
package
config
import
(
"github.com/eris-ltd/eris-db/files"
"github.com/naoina/toml"
)
// Standard configuration file for the server.
type
(
ErisDBConfig
struct
{
DB
DB
`toml:"db"`
TMSP
TMSP
`toml:"tmsp"`
Tendermint
Tendermint
`toml:"tendermint"`
Server
ServerConfig
`toml":server"`
}
DB
struct
{
Backend
string
`toml:"backend"`
}
TMSP
struct
{
Listener
string
`toml:"listener"`
}
Tendermint
struct
{
Host
string
`toml:"host"`
}
ServerConfig
struct
{
Bind
Bind
`toml:"bind"`
TLS
TLS
`toml:"TLS"`
CORS
CORS
`toml:"CORS"`
HTTP
HTTP
`toml:"HTTP"`
WebSocket
WebSocket
`toml:"web_socket"`
Logging
Logging
`toml:"logging"`
}
Bind
struct
{
Address
string
`toml:"address"`
Port
uint16
`toml:"port"`
}
TLS
struct
{
TLS
bool
`toml:"tls"`
CertPath
string
`toml:"cert_path"`
KeyPath
string
`toml:"key_path"`
}
// Options stores configurations
CORS
struct
{
Enable
bool
`toml:"enable"`
AllowOrigins
[]
string
`toml:"allow_origins"`
AllowCredentials
bool
`toml:"allow_credentials"`
AllowMethods
[]
string
`toml:"allow_methods"`
AllowHeaders
[]
string
`toml:"allow_headers"`
ExposeHeaders
[]
string
`toml:"expose_headers"`
MaxAge
uint64
`toml:"max_age"`
}
HTTP
struct
{
JsonRpcEndpoint
string
`toml:"json_rpc_endpoint"`
}
WebSocket
struct
{
WebSocketEndpoint
string
`toml:"websocket_endpoint"`
MaxWebSocketSessions
uint
`toml:"max_websocket_sessions"`
ReadBufferSize
uint
`toml:"read_buffer_size"`
WriteBufferSize
uint
`toml:"write_buffer_size"`
}
Logging
struct
{
ConsoleLogLevel
string
`toml:"console_log_level"`
FileLogLevel
string
`toml:"file_log_level"`
LogFile
string
`toml:"log_file"`
VMLog
bool
`toml:"vm_log"`
}
)
func
DefaultServerConfig
()
ServerConfig
{
cp
:=
""
kp
:=
""
return
ServerConfig
{
Bind
:
Bind
{
Address
:
""
,
Port
:
1337
,
},
TLS
:
TLS
{
TLS
:
false
,
CertPath
:
cp
,
KeyPath
:
kp
,
},
CORS
:
CORS
{},
HTTP
:
HTTP
{
JsonRpcEndpoint
:
"/rpc"
},
WebSocket
:
WebSocket
{
WebSocketEndpoint
:
"/socketrpc"
,
MaxWebSocketSessions
:
50
,
ReadBufferSize
:
4096
,
WriteBufferSize
:
4096
,
},
Logging
:
Logging
{
ConsoleLogLevel
:
"info"
,
FileLogLevel
:
"warn"
,
LogFile
:
""
,
},
}
}
func
DefaultErisDBConfig
()
*
ErisDBConfig
{
return
&
ErisDBConfig
{
DB
:
DB
{
Backend
:
"leveldb"
,
},
TMSP
:
TMSP
{
Listener
:
"tcp://0.0.0.0:46658"
,
},
Tendermint
:
Tendermint
{
Host
:
"0.0.0.0:46657"
,
},
Server
:
DefaultServerConfig
(),
}
}
// Read a TOML server configuration file.
func
ReadErisDBConfig
(
filePath
string
)
(
*
ErisDBConfig
,
error
)
{
bts
,
err
:=
files
.
ReadFile
(
filePath
)
if
err
!=
nil
{
return
nil
,
err
}
cfg
:=
&
ErisDBConfig
{}
err2
:=
toml
.
Unmarshal
(
bts
,
cfg
)
if
err2
!=
nil
{
return
nil
,
err2
}
return
cfg
,
nil
}
// Write a server configuration file.
func
WriteErisDBConfig
(
filePath
string
,
cfg
*
ErisDBConfig
)
error
{
bts
,
err
:=
toml
.
Marshal
(
*
cfg
)
if
err
!=
nil
{
return
err
}
return
files
.
WriteAndBackup
(
filePath
,
bts
)
}
This diff is collapsed.
Click to expand it.
txs/tx.go
+
16
−
0
View file @
d3ce6a79
package
types
import
(
"bytes"
"encoding/json"
"errors"
"io"
...
...
@@ -366,6 +367,21 @@ func TxID(chainID string, tx Tx) []byte {
return
wire
.
BinaryRipemd160
(
signBytes
)
}
//-----------------------------------------------------------------------------
// panic on err
func
DecodeTx
(
txBytes
[]
byte
)
Tx
{
var
n
int
var
err
error
tx
:=
new
(
Tx
)
buf
:=
bytes
.
NewBuffer
(
txBytes
)
wire
.
ReadBinaryPtr
(
tx
,
buf
,
len
(
txBytes
),
&
n
,
&
err
)
if
err
!=
nil
{
panic
(
err
)
}
return
*
tx
}
//--------------------------------------------------------------------------------
// Contract: This function is deterministic and completely reversible.
...
...
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