mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 22:44:24 +00:00
Config is passed into each module. Remove tendermint/confer
This commit is contained in:
+1
-2
@@ -11,7 +11,6 @@ import (
|
||||
"github.com/tendermint/tendermint/account"
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
"github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/merkle"
|
||||
)
|
||||
|
||||
@@ -24,7 +23,7 @@ type Block struct {
|
||||
// Basic validation that doesn't involve state data.
|
||||
func (b *Block) ValidateBasic(lastBlockHeight uint, lastBlockHash []byte,
|
||||
lastBlockParts PartSetHeader, lastBlockTime time.Time) error {
|
||||
if b.Network != config.App().GetString("network") {
|
||||
if b.Network != config.GetString("network") {
|
||||
return errors.New("Wrong Block.Header.Network")
|
||||
}
|
||||
if b.Height != lastBlockHeight+1 {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
cfg "github.com/tendermint/tendermint/config"
|
||||
)
|
||||
|
||||
var config cfg.Config = nil
|
||||
|
||||
func init() {
|
||||
cfg.OnConfig(func(newConfig cfg.Config) {
|
||||
config = newConfig
|
||||
})
|
||||
}
|
||||
+5
-6
@@ -7,7 +7,6 @@ import (
|
||||
"github.com/tendermint/tendermint/account"
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
"github.com/tendermint/tendermint/config"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -132,7 +131,7 @@ type SendTx struct {
|
||||
|
||||
func (tx *SendTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
// We hex encode the network name so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("network"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.GetString("network"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"inputs":[`, TxTypeSend)), w, n, err)
|
||||
for i, in := range tx.Inputs {
|
||||
in.WriteSignBytes(w, n, err)
|
||||
@@ -166,7 +165,7 @@ type CallTx struct {
|
||||
|
||||
func (tx *CallTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
// We hex encode the network name so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("network"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.GetString("network"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"address":"%X","data":"%X"`, TxTypeCall, tx.Address, tx.Data)), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`,"fee":%v,"gas_limit":%v,"input":`, tx.Fee, tx.GasLimit)), w, n, err)
|
||||
tx.Input.WriteSignBytes(w, n, err)
|
||||
@@ -187,7 +186,7 @@ type BondTx struct {
|
||||
|
||||
func (tx *BondTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
// We hex encode the network name so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("network"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.GetString("network"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"inputs":[`, TxTypeBond)), w, n, err)
|
||||
for i, in := range tx.Inputs {
|
||||
in.WriteSignBytes(w, n, err)
|
||||
@@ -221,7 +220,7 @@ type UnbondTx struct {
|
||||
|
||||
func (tx *UnbondTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
// We hex encode the network name so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("network"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.GetString("network"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"address":"%X","height":%v}]}`, TxTypeUnbond, tx.Address, tx.Height)), w, n, err)
|
||||
}
|
||||
|
||||
@@ -239,7 +238,7 @@ type RebondTx struct {
|
||||
|
||||
func (tx *RebondTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
// We hex encode the network name so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("network"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.GetString("network"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"address":"%X","height":%v}]}`, TxTypeRebond, tx.Address, tx.Height)), w, n, err)
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/tendermint/tendermint/account"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
"github.com/tendermint/tendermint/config"
|
||||
_ "github.com/tendermint/tendermint/test"
|
||||
)
|
||||
|
||||
func TestSendTxSignable(t *testing.T) {
|
||||
@@ -36,7 +36,7 @@ func TestSendTxSignable(t *testing.T) {
|
||||
signBytes := account.SignBytes(sendTx)
|
||||
signStr := string(signBytes)
|
||||
expected := Fmt(`{"network":"%X","tx":[1,{"inputs":[{"address":"696E70757431","amount":12345,"sequence":67890},{"address":"696E70757432","amount":111,"sequence":222}],"outputs":[{"address":"6F757470757431","amount":333},{"address":"6F757470757432","amount":444}]}]}`,
|
||||
config.App().GetString("network"))
|
||||
config.GetString("network"))
|
||||
if signStr != expected {
|
||||
t.Errorf("Got unexpected sign string for SendTx. Expected:\n%v\nGot:\n%v", expected, signStr)
|
||||
}
|
||||
@@ -57,7 +57,7 @@ func TestCallTxSignable(t *testing.T) {
|
||||
signBytes := account.SignBytes(callTx)
|
||||
signStr := string(signBytes)
|
||||
expected := Fmt(`{"network":"%X","tx":[2,{"address":"636F6E747261637431","data":"6461746131","fee":222,"gas_limit":111,"input":{"address":"696E70757431","amount":12345,"sequence":67890}}]}`,
|
||||
config.App().GetString("network"))
|
||||
config.GetString("network"))
|
||||
if signStr != expected {
|
||||
t.Errorf("Got unexpected sign string for CallTx. Expected:\n%v\nGot:\n%v", expected, signStr)
|
||||
}
|
||||
@@ -93,7 +93,7 @@ func TestBondTxSignable(t *testing.T) {
|
||||
signBytes := account.SignBytes(bondTx)
|
||||
signStr := string(signBytes)
|
||||
expected := Fmt(`{"network":"%X","tx":[17,{"inputs":[{"address":"696E70757431","amount":12345,"sequence":67890},{"address":"696E70757432","amount":111,"sequence":222}],"pub_key":[1,"3B6A27BCCEB6A42D62A3A8D02A6F0D73653215771DE243A63AC048A18B59DA29"],"unbond_to":[{"address":"6F757470757431","amount":333},{"address":"6F757470757432","amount":444}]}]}`,
|
||||
config.App().GetString("network"))
|
||||
config.GetString("network"))
|
||||
if signStr != expected {
|
||||
t.Errorf("Got unexpected sign string for BondTx")
|
||||
}
|
||||
@@ -107,7 +107,7 @@ func TestUnbondTxSignable(t *testing.T) {
|
||||
signBytes := account.SignBytes(unbondTx)
|
||||
signStr := string(signBytes)
|
||||
expected := Fmt(`{"network":"%X","tx":[18,{"address":"6164647265737331","height":111}]}`,
|
||||
config.App().GetString("network"))
|
||||
config.GetString("network"))
|
||||
if signStr != expected {
|
||||
t.Errorf("Got unexpected sign string for UnbondTx")
|
||||
}
|
||||
@@ -121,7 +121,7 @@ func TestRebondTxSignable(t *testing.T) {
|
||||
signBytes := account.SignBytes(rebondTx)
|
||||
signStr := string(signBytes)
|
||||
expected := Fmt(`{"network":"%X","tx":[19,{"address":"6164647265737331","height":111}]}`,
|
||||
config.App().GetString("network"))
|
||||
config.GetString("network"))
|
||||
if signStr != expected {
|
||||
t.Errorf("Got unexpected sign string for RebondTx")
|
||||
}
|
||||
|
||||
+1
-2
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/tendermint/tendermint/account"
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
"github.com/tendermint/tendermint/config"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -48,7 +47,7 @@ const (
|
||||
|
||||
func (vote *Vote) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
// We hex encode the network name so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("network"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.GetString("network"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`,"vote":{"block_hash":"%X","block_parts":%v`, vote.BlockHash, vote.BlockParts)), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`,"height":%v,"round":%v,"type":%v}}`, vote.Height, vote.Round, vote.Type)), w, n, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user