mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-07 13:55:17 +00:00
int64 height
uint64 is considered dangerous. the details will follow in a blog post.
This commit is contained in:
@@ -61,12 +61,12 @@ type Mempool struct {
|
||||
proxyAppConn proxy.AppConnMempool
|
||||
txs *clist.CList // concurrent linked-list of good txs
|
||||
counter int64 // simple incrementing counter
|
||||
height uint64 // the last block Update()'d to
|
||||
height int64 // the last block Update()'d to
|
||||
rechecking int32 // for re-checking filtered txs on Update()
|
||||
recheckCursor *clist.CElement // next expected response
|
||||
recheckEnd *clist.CElement // re-checking stops here
|
||||
notifiedTxsAvailable bool // true if fired on txsAvailable for this height
|
||||
txsAvailable chan uint64 // fires the next height once for each height, when the mempool is not empty
|
||||
txsAvailable chan int64 // fires the next height once for each height, when the mempool is not empty
|
||||
|
||||
// Keep a cache of already-seen txs.
|
||||
// This reduces the pressure on the proxyApp.
|
||||
@@ -80,7 +80,7 @@ type Mempool struct {
|
||||
|
||||
// NewMempool returns a new Mempool with the given configuration and connection to an application.
|
||||
// TODO: Extract logger into arguments.
|
||||
func NewMempool(config *cfg.MempoolConfig, proxyAppConn proxy.AppConnMempool, height uint64) *Mempool {
|
||||
func NewMempool(config *cfg.MempoolConfig, proxyAppConn proxy.AppConnMempool, height int64) *Mempool {
|
||||
mempool := &Mempool{
|
||||
config: config,
|
||||
proxyAppConn: proxyAppConn,
|
||||
@@ -102,7 +102,7 @@ func NewMempool(config *cfg.MempoolConfig, proxyAppConn proxy.AppConnMempool, he
|
||||
// ensuring it will trigger once every height when transactions are available.
|
||||
// NOTE: not thread safe - should only be called once, on startup
|
||||
func (mem *Mempool) EnableTxsAvailable() {
|
||||
mem.txsAvailable = make(chan uint64, 1)
|
||||
mem.txsAvailable = make(chan int64, 1)
|
||||
}
|
||||
|
||||
// SetLogger sets the Logger.
|
||||
@@ -310,7 +310,7 @@ func (mem *Mempool) resCbRecheck(req *abci.Request, res *abci.Response) {
|
||||
// TxsAvailable returns a channel which fires once for every height,
|
||||
// and only when transactions are available in the mempool.
|
||||
// NOTE: the returned channel may be nil if EnableTxsAvailable was not called.
|
||||
func (mem *Mempool) TxsAvailable() <-chan uint64 {
|
||||
func (mem *Mempool) TxsAvailable() <-chan int64 {
|
||||
return mem.txsAvailable
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ func (mem *Mempool) collectTxs(maxTxs int) types.Txs {
|
||||
// Update informs the mempool that the given txs were committed and can be discarded.
|
||||
// NOTE: this should be called *after* block is committed by consensus.
|
||||
// NOTE: unsafe; Lock/Unlock must be managed by caller
|
||||
func (mem *Mempool) Update(height uint64, txs types.Txs) error {
|
||||
func (mem *Mempool) Update(height int64, txs types.Txs) error {
|
||||
if err := mem.proxyAppConn.FlushSync(); err != nil { // To flush async resCb calls e.g. from CheckTx
|
||||
return err
|
||||
}
|
||||
@@ -427,13 +427,13 @@ func (mem *Mempool) recheckTxs(goodTxs []types.Tx) {
|
||||
// mempoolTx is a transaction that successfully ran
|
||||
type mempoolTx struct {
|
||||
counter int64 // a simple incrementing counter
|
||||
height uint64 // height that this tx had been validated in
|
||||
height int64 // height that this tx had been validated in
|
||||
tx types.Tx //
|
||||
}
|
||||
|
||||
// Height returns the height for this transaction
|
||||
func (memTx *mempoolTx) Height() uint64 {
|
||||
return atomic.LoadUint64(&memTx.height)
|
||||
func (memTx *mempoolTx) Height() int64 {
|
||||
return atomic.LoadInt64(&memTx.height)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
@@ -37,7 +37,7 @@ func newMempoolWithApp(cc proxy.ClientCreator) *Mempool {
|
||||
return mempool
|
||||
}
|
||||
|
||||
func ensureNoFire(t *testing.T, ch <-chan uint64, timeoutMS int) {
|
||||
func ensureNoFire(t *testing.T, ch <-chan int64, timeoutMS int) {
|
||||
timer := time.NewTimer(time.Duration(timeoutMS) * time.Millisecond)
|
||||
select {
|
||||
case <-ch:
|
||||
@@ -46,7 +46,7 @@ func ensureNoFire(t *testing.T, ch <-chan uint64, timeoutMS int) {
|
||||
}
|
||||
}
|
||||
|
||||
func ensureFire(t *testing.T, ch <-chan uint64, timeoutMS int) {
|
||||
func ensureFire(t *testing.T, ch <-chan int64, timeoutMS int) {
|
||||
timer := time.NewTimer(time.Duration(timeoutMS) * time.Millisecond)
|
||||
select {
|
||||
case <-ch:
|
||||
|
||||
@@ -97,7 +97,7 @@ func (memR *MempoolReactor) BroadcastTx(tx types.Tx, cb func(*abci.Response)) er
|
||||
|
||||
// PeerState describes the state of a peer.
|
||||
type PeerState interface {
|
||||
GetHeight() uint64
|
||||
GetHeight() int64
|
||||
}
|
||||
|
||||
// Peer describes a peer.
|
||||
|
||||
Reference in New Issue
Block a user