mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-20 15:04:22 +00:00
Dot import -> named import
Changed modulename_ to short module names Also removed Unreader, replaced with PrefixdReader in select locations
This commit is contained in:
+4
-4
@@ -8,8 +8,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
. "github.com/tendermint/tendermint/account"
|
||||
. "github.com/tendermint/tendermint/binary"
|
||||
"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"
|
||||
@@ -125,7 +125,7 @@ type Header struct {
|
||||
func (h *Header) Hash() []byte {
|
||||
if h.hash == nil {
|
||||
hasher, n, err := sha256.New(), new(int64), new(error)
|
||||
WriteBinary(h, hasher, n, err)
|
||||
binary.WriteBinary(h, hasher, n, err)
|
||||
if *err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -161,7 +161,7 @@ func (h *Header) StringIndented(indent string) string {
|
||||
type Commit struct {
|
||||
Address []byte
|
||||
Round uint
|
||||
Signature SignatureEd25519
|
||||
Signature account.SignatureEd25519
|
||||
}
|
||||
|
||||
func (commit Commit) IsZero() bool {
|
||||
|
||||
+2
-2
@@ -5,10 +5,10 @@ import (
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
. "github.com/tendermint/tendermint/binary"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
"github.com/tendermint/tendermint/merkle"
|
||||
)
|
||||
@@ -227,7 +227,7 @@ func (ps *PartSet) IsComplete() bool {
|
||||
return ps.count == ps.total
|
||||
}
|
||||
|
||||
func (ps *PartSet) GetReader() Unreader {
|
||||
func (ps *PartSet) GetReader() io.Reader {
|
||||
if !ps.IsComplete() {
|
||||
panic("Cannot GetReader() on incomplete PartSet")
|
||||
}
|
||||
|
||||
+18
-17
@@ -4,10 +4,11 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
. "github.com/tendermint/tendermint/binary"
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
db_ "github.com/tendermint/tendermint/db"
|
||||
dbm "github.com/tendermint/tendermint/db"
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -24,10 +25,10 @@ the Validation data outside the Block.
|
||||
*/
|
||||
type BlockStore struct {
|
||||
height uint
|
||||
db db_.DB
|
||||
db dbm.DB
|
||||
}
|
||||
|
||||
func NewBlockStore(db db_.DB) *BlockStore {
|
||||
func NewBlockStore(db dbm.DB) *BlockStore {
|
||||
bsjson := LoadBlockStoreStateJSON(db)
|
||||
return &BlockStore{
|
||||
height: bsjson.Height,
|
||||
@@ -40,7 +41,7 @@ func (bs *BlockStore) Height() uint {
|
||||
return bs.height
|
||||
}
|
||||
|
||||
func (bs *BlockStore) GetReader(key []byte) Unreader {
|
||||
func (bs *BlockStore) GetReader(key []byte) io.Reader {
|
||||
bytez := bs.db.Get(key)
|
||||
if bytez == nil {
|
||||
return nil
|
||||
@@ -55,7 +56,7 @@ func (bs *BlockStore) LoadBlock(height uint) *Block {
|
||||
if r == nil {
|
||||
panic(Fmt("Block does not exist at height %v", height))
|
||||
}
|
||||
meta := ReadBinary(&BlockMeta{}, r, &n, &err).(*BlockMeta)
|
||||
meta := binary.ReadBinary(&BlockMeta{}, r, &n, &err).(*BlockMeta)
|
||||
if err != nil {
|
||||
panic(Fmt("Error reading block meta: %v", err))
|
||||
}
|
||||
@@ -64,7 +65,7 @@ func (bs *BlockStore) LoadBlock(height uint) *Block {
|
||||
part := bs.LoadBlockPart(height, i)
|
||||
bytez = append(bytez, part.Bytes...)
|
||||
}
|
||||
block := ReadBinary(&Block{}, bytes.NewReader(bytez), &n, &err).(*Block)
|
||||
block := binary.ReadBinary(&Block{}, bytes.NewReader(bytez), &n, &err).(*Block)
|
||||
if err != nil {
|
||||
panic(Fmt("Error reading block: %v", err))
|
||||
}
|
||||
@@ -78,7 +79,7 @@ func (bs *BlockStore) LoadBlockPart(height uint, index uint) *Part {
|
||||
if r == nil {
|
||||
panic(Fmt("BlockPart does not exist for height %v index %v", height, index))
|
||||
}
|
||||
part := ReadBinary(&Part{}, r, &n, &err).(*Part)
|
||||
part := binary.ReadBinary(&Part{}, r, &n, &err).(*Part)
|
||||
if err != nil {
|
||||
panic(Fmt("Error reading block part: %v", err))
|
||||
}
|
||||
@@ -92,7 +93,7 @@ func (bs *BlockStore) LoadBlockMeta(height uint) *BlockMeta {
|
||||
if r == nil {
|
||||
panic(Fmt("BlockMeta does not exist for height %v", height))
|
||||
}
|
||||
meta := ReadBinary(&BlockMeta{}, r, &n, &err).(*BlockMeta)
|
||||
meta := binary.ReadBinary(&BlockMeta{}, r, &n, &err).(*BlockMeta)
|
||||
if err != nil {
|
||||
panic(Fmt("Error reading block meta: %v", err))
|
||||
}
|
||||
@@ -109,7 +110,7 @@ func (bs *BlockStore) LoadBlockValidation(height uint) *Validation {
|
||||
if r == nil {
|
||||
panic(Fmt("BlockValidation does not exist for height %v", height))
|
||||
}
|
||||
validation := ReadBinary(&Validation{}, r, &n, &err).(*Validation)
|
||||
validation := binary.ReadBinary(&Validation{}, r, &n, &err).(*Validation)
|
||||
if err != nil {
|
||||
panic(Fmt("Error reading validation: %v", err))
|
||||
}
|
||||
@@ -124,7 +125,7 @@ func (bs *BlockStore) LoadSeenValidation(height uint) *Validation {
|
||||
if r == nil {
|
||||
panic(Fmt("SeenValidation does not exist for height %v", height))
|
||||
}
|
||||
validation := ReadBinary(&Validation{}, r, &n, &err).(*Validation)
|
||||
validation := binary.ReadBinary(&Validation{}, r, &n, &err).(*Validation)
|
||||
if err != nil {
|
||||
panic(Fmt("Error reading validation: %v", err))
|
||||
}
|
||||
@@ -149,7 +150,7 @@ func (bs *BlockStore) SaveBlock(block *Block, blockParts *PartSet, seenValidatio
|
||||
|
||||
// Save block meta
|
||||
meta := makeBlockMeta(block, blockParts)
|
||||
metaBytes := BinaryBytes(meta)
|
||||
metaBytes := binary.BinaryBytes(meta)
|
||||
bs.db.Set(calcBlockMetaKey(height), metaBytes)
|
||||
|
||||
// Save block parts
|
||||
@@ -158,11 +159,11 @@ func (bs *BlockStore) SaveBlock(block *Block, blockParts *PartSet, seenValidatio
|
||||
}
|
||||
|
||||
// Save block validation (duplicate and separate from the Block)
|
||||
blockValidationBytes := BinaryBytes(block.Validation)
|
||||
blockValidationBytes := binary.BinaryBytes(block.Validation)
|
||||
bs.db.Set(calcBlockValidationKey(height), blockValidationBytes)
|
||||
|
||||
// Save seen validation (seen +2/3 commits)
|
||||
seenValidationBytes := BinaryBytes(seenValidation)
|
||||
seenValidationBytes := binary.BinaryBytes(seenValidation)
|
||||
bs.db.Set(calcSeenValidationKey(height), seenValidationBytes)
|
||||
|
||||
// Save new BlockStoreStateJSON descriptor
|
||||
@@ -176,7 +177,7 @@ func (bs *BlockStore) saveBlockPart(height uint, index uint, part *Part) {
|
||||
if height != bs.height+1 {
|
||||
panic(Fmt("BlockStore can only save contiguous blocks. Wanted %v, got %v", bs.height+1, height))
|
||||
}
|
||||
partBytes := BinaryBytes(part)
|
||||
partBytes := binary.BinaryBytes(part)
|
||||
bs.db.Set(calcBlockPartKey(height, index), partBytes)
|
||||
}
|
||||
|
||||
@@ -222,7 +223,7 @@ type BlockStoreStateJSON struct {
|
||||
Height uint
|
||||
}
|
||||
|
||||
func (bsj BlockStoreStateJSON) Save(db db_.DB) {
|
||||
func (bsj BlockStoreStateJSON) Save(db dbm.DB) {
|
||||
bytes, err := json.Marshal(bsj)
|
||||
if err != nil {
|
||||
panic(Fmt("Could not marshal state bytes: %v", err))
|
||||
@@ -230,7 +231,7 @@ func (bsj BlockStoreStateJSON) Save(db db_.DB) {
|
||||
db.Set(blockStoreKey, bytes)
|
||||
}
|
||||
|
||||
func LoadBlockStoreStateJSON(db db_.DB) BlockStoreStateJSON {
|
||||
func LoadBlockStoreStateJSON(db dbm.DB) BlockStoreStateJSON {
|
||||
bytes := db.Get(blockStoreKey)
|
||||
if bytes == nil {
|
||||
return BlockStoreStateJSON{
|
||||
|
||||
+30
-30
@@ -4,8 +4,8 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
. "github.com/tendermint/tendermint/account"
|
||||
. "github.com/tendermint/tendermint/binary"
|
||||
"github.com/tendermint/tendermint/account"
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -47,23 +47,23 @@ const (
|
||||
)
|
||||
|
||||
// for binary.readReflect
|
||||
var _ = RegisterInterface(
|
||||
var _ = binary.RegisterInterface(
|
||||
struct{ Tx }{},
|
||||
ConcreteType{&SendTx{}},
|
||||
ConcreteType{&BondTx{}},
|
||||
ConcreteType{&UnbondTx{}},
|
||||
ConcreteType{&RebondTx{}},
|
||||
ConcreteType{&DupeoutTx{}},
|
||||
binary.ConcreteType{&SendTx{}},
|
||||
binary.ConcreteType{&BondTx{}},
|
||||
binary.ConcreteType{&UnbondTx{}},
|
||||
binary.ConcreteType{&RebondTx{}},
|
||||
binary.ConcreteType{&DupeoutTx{}},
|
||||
)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
type TxInput struct {
|
||||
Address []byte // Hash of the PubKey
|
||||
Amount uint64 // Must not exceed account balance
|
||||
Sequence uint // Must be 1 greater than the last committed TxInput
|
||||
Signature Signature // Depends on the PubKey type and the whole Tx
|
||||
PubKey PubKey // Must not be nil, may be PubKeyNil.
|
||||
Address []byte // Hash of the PubKey
|
||||
Amount uint64 // Must not exceed account balance
|
||||
Sequence uint // Must be 1 greater than the last committed TxInput
|
||||
Signature account.Signature // Depends on the PubKey type and the whole Tx
|
||||
PubKey account.PubKey // Must not be nil, may be PubKeyNil.
|
||||
}
|
||||
|
||||
func (txIn *TxInput) ValidateBasic() error {
|
||||
@@ -77,9 +77,9 @@ func (txIn *TxInput) ValidateBasic() error {
|
||||
}
|
||||
|
||||
func (txIn *TxInput) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
WriteByteSlice(txIn.Address, w, n, err)
|
||||
WriteUint64(txIn.Amount, w, n, err)
|
||||
WriteUvarint(txIn.Sequence, w, n, err)
|
||||
binary.WriteByteSlice(txIn.Address, w, n, err)
|
||||
binary.WriteUint64(txIn.Amount, w, n, err)
|
||||
binary.WriteUvarint(txIn.Sequence, w, n, err)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -100,8 +100,8 @@ func (txOut *TxOutput) ValidateBasic() error {
|
||||
}
|
||||
|
||||
func (txOut *TxOutput) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
WriteByteSlice(txOut.Address, w, n, err)
|
||||
WriteUint64(txOut.Amount, w, n, err)
|
||||
binary.WriteByteSlice(txOut.Address, w, n, err)
|
||||
binary.WriteUint64(txOut.Amount, w, n, err)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -114,11 +114,11 @@ type SendTx struct {
|
||||
func (tx *SendTx) TypeByte() byte { return TxTypeSend }
|
||||
|
||||
func (tx *SendTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
WriteUvarint(uint(len(tx.Inputs)), w, n, err)
|
||||
binary.WriteUvarint(uint(len(tx.Inputs)), w, n, err)
|
||||
for _, in := range tx.Inputs {
|
||||
in.WriteSignBytes(w, n, err)
|
||||
}
|
||||
WriteUvarint(uint(len(tx.Outputs)), w, n, err)
|
||||
binary.WriteUvarint(uint(len(tx.Outputs)), w, n, err)
|
||||
for _, out := range tx.Outputs {
|
||||
out.WriteSignBytes(w, n, err)
|
||||
}
|
||||
@@ -127,7 +127,7 @@ func (tx *SendTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
type BondTx struct {
|
||||
PubKey PubKeyEd25519
|
||||
PubKey account.PubKeyEd25519
|
||||
Inputs []*TxInput
|
||||
UnbondTo []*TxOutput
|
||||
}
|
||||
@@ -135,12 +135,12 @@ type BondTx struct {
|
||||
func (tx *BondTx) TypeByte() byte { return TxTypeBond }
|
||||
|
||||
func (tx *BondTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
WriteBinary(tx.PubKey, w, n, err)
|
||||
WriteUvarint(uint(len(tx.Inputs)), w, n, err)
|
||||
binary.WriteBinary(tx.PubKey, w, n, err)
|
||||
binary.WriteUvarint(uint(len(tx.Inputs)), w, n, err)
|
||||
for _, in := range tx.Inputs {
|
||||
in.WriteSignBytes(w, n, err)
|
||||
}
|
||||
WriteUvarint(uint(len(tx.UnbondTo)), w, n, err)
|
||||
binary.WriteUvarint(uint(len(tx.UnbondTo)), w, n, err)
|
||||
for _, out := range tx.UnbondTo {
|
||||
out.WriteSignBytes(w, n, err)
|
||||
}
|
||||
@@ -151,14 +151,14 @@ func (tx *BondTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
type UnbondTx struct {
|
||||
Address []byte
|
||||
Height uint
|
||||
Signature SignatureEd25519
|
||||
Signature account.SignatureEd25519
|
||||
}
|
||||
|
||||
func (tx *UnbondTx) TypeByte() byte { return TxTypeUnbond }
|
||||
|
||||
func (tx *UnbondTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
WriteByteSlice(tx.Address, w, n, err)
|
||||
WriteUvarint(tx.Height, w, n, err)
|
||||
binary.WriteByteSlice(tx.Address, w, n, err)
|
||||
binary.WriteUvarint(tx.Height, w, n, err)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -166,14 +166,14 @@ func (tx *UnbondTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
type RebondTx struct {
|
||||
Address []byte
|
||||
Height uint
|
||||
Signature SignatureEd25519
|
||||
Signature account.SignatureEd25519
|
||||
}
|
||||
|
||||
func (tx *RebondTx) TypeByte() byte { return TxTypeRebond }
|
||||
|
||||
func (tx *RebondTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
WriteByteSlice(tx.Address, w, n, err)
|
||||
WriteUvarint(tx.Height, w, n, err)
|
||||
binary.WriteByteSlice(tx.Address, w, n, err)
|
||||
binary.WriteUvarint(tx.Height, w, n, err)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+8
-8
@@ -5,8 +5,8 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
. "github.com/tendermint/tendermint/account"
|
||||
. "github.com/tendermint/tendermint/binary"
|
||||
"github.com/tendermint/tendermint/account"
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
)
|
||||
|
||||
@@ -27,7 +27,7 @@ type Vote struct {
|
||||
Type byte
|
||||
BlockHash []byte // empty if vote is nil.
|
||||
BlockParts PartSetHeader // zero if vote is nil.
|
||||
Signature SignatureEd25519
|
||||
Signature account.SignatureEd25519
|
||||
}
|
||||
|
||||
// Types of votes
|
||||
@@ -38,11 +38,11 @@ const (
|
||||
)
|
||||
|
||||
func (vote *Vote) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
WriteUvarint(vote.Height, w, n, err)
|
||||
WriteUvarint(vote.Round, w, n, err)
|
||||
WriteByte(vote.Type, w, n, err)
|
||||
WriteByteSlice(vote.BlockHash, w, n, err)
|
||||
WriteBinary(vote.BlockParts, w, n, err)
|
||||
binary.WriteUvarint(vote.Height, w, n, err)
|
||||
binary.WriteUvarint(vote.Round, w, n, err)
|
||||
binary.WriteByte(vote.Type, w, n, err)
|
||||
binary.WriteByteSlice(vote.BlockHash, w, n, err)
|
||||
binary.WriteBinary(vote.BlockParts, w, n, err)
|
||||
}
|
||||
|
||||
func (vote *Vote) Copy() *Vote {
|
||||
|
||||
Reference in New Issue
Block a user