mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-10 18:16:07 +00:00
Refactor Tx, Validator, and Account structure
This commit is contained in:
+2
-2
@@ -59,14 +59,14 @@ func (mem *Mempool) ResetForBlockAndState(block *Block, state *state.State) {
|
||||
// First, create a lookup map of txns in new block.
|
||||
blockTxsMap := make(map[string]struct{})
|
||||
for _, tx := range block.Data.Txs {
|
||||
txHash := BinaryHash(tx)
|
||||
txHash := BinarySha256(tx)
|
||||
blockTxsMap[string(txHash)] = struct{}{}
|
||||
}
|
||||
|
||||
// Next, filter all txs from mem.txs that are in blockTxsMap
|
||||
txs := []Tx{}
|
||||
for _, tx := range mem.txs {
|
||||
txHash := BinaryHash(tx)
|
||||
txHash := BinarySha256(tx)
|
||||
if _, ok := blockTxsMap[string(txHash)]; ok {
|
||||
continue
|
||||
} else {
|
||||
|
||||
+2
-15
@@ -3,7 +3,6 @@ package mempool
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"sync/atomic"
|
||||
|
||||
. "github.com/tendermint/tendermint/binary"
|
||||
@@ -119,12 +118,10 @@ const (
|
||||
// TODO: check for unnecessary extra bytes at the end.
|
||||
func decodeMessage(bz []byte) (msgType byte, msg interface{}) {
|
||||
n, err := new(int64), new(error)
|
||||
// log.Debug("decoding msg bytes: %X", bz)
|
||||
msgType = bz[0]
|
||||
switch msgType {
|
||||
case msgTypeTx:
|
||||
msg = readTxMessage(bytes.NewReader(bz[1:]), n, err)
|
||||
// case ...:
|
||||
msg = ReadBinary(&TxMessage{}, bytes.NewReader(bz[1:]), n, err)
|
||||
default:
|
||||
msg = nil
|
||||
}
|
||||
@@ -137,17 +134,7 @@ type TxMessage struct {
|
||||
Tx Tx
|
||||
}
|
||||
|
||||
func readTxMessage(r io.Reader, n *int64, err *error) *TxMessage {
|
||||
return &TxMessage{
|
||||
Tx: ReadTx(r, n, err),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *TxMessage) WriteTo(w io.Writer) (n int64, err error) {
|
||||
WriteByte(w, msgTypeTx, &n, &err)
|
||||
WriteBinary(w, m.Tx, &n, &err)
|
||||
return
|
||||
}
|
||||
func (m *TxMessage) TypeByte() byte { return msgTypeTx }
|
||||
|
||||
func (m *TxMessage) String() string {
|
||||
return fmt.Sprintf("[TxMessage %v]", m.Tx)
|
||||
|
||||
Reference in New Issue
Block a user