diff --git a/app/app.go b/app/app.go index 5fd96b7..7a62299 100644 --- a/app/app.go +++ b/app/app.go @@ -234,7 +234,7 @@ func (a *App) HandleWork() { // HandleTransaction handles new instance of TransactionWork. func (a *App) HandleTransaction(txn *blockchain.Transaction) { - validTransaction := a.Pool.Set(txn, a.Chain) + validTransaction := a.Pool.Push(txn, a.Chain) if validTransaction { log.Debug("added transaction to pool from address: " + txn.Sender.Repr()) } else { diff --git a/app/app_test.go b/app/app_test.go index 534b406..5d1d355 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -126,7 +126,7 @@ func TestHandleBlockOK(t *testing.T) { // TODO: Start miner. for i < 1000 { - a.Pool.SetUnsafe(blockchain.NewTestTransaction()) + a.Pool.PushUnsafe(blockchain.NewTestTransaction()) i++ } @@ -145,7 +145,7 @@ func TestHandleBlockNotOK(t *testing.T) { // TODO: Start miner. for i < 1000 { - a.Pool.SetUnsafe(blockchain.NewTestTransaction()) + a.Pool.PushUnsafe(blockchain.NewTestTransaction()) i++ } diff --git a/pool/pool.go b/pool/pool.go index 6ba7ac9..f799f7f 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -70,7 +70,7 @@ func getIndex(a []*PooledTransaction, target time.Time, low, high int) int { // Set inserts a transaction into the pool, returning // true if the Transaction was inserted (was valid). -func (p *Pool) Set(t *blockchain.Transaction, bc *blockchain.BlockChain) bool { +func (p *Pool) Push(t *blockchain.Transaction, bc *blockchain.BlockChain) bool { if ok, err := bc.ValidTransaction(t); ok { p.set(t) return true @@ -80,8 +80,8 @@ func (p *Pool) Set(t *blockchain.Transaction, bc *blockchain.BlockChain) bool { } } -// SetUnsafe adds a transaction to the pool without validation. -func (p *Pool) SetUnsafe(t *blockchain.Transaction) { +// PushUnsafe adds a transaction to the pool without validation. +func (p *Pool) PushUnsafe(t *blockchain.Transaction) { p.set(t) } diff --git a/pool/pool_test.go b/pool/pool_test.go index 5a9740f..f0d8d6f 100644 --- a/pool/pool_test.go +++ b/pool/pool_test.go @@ -14,7 +14,7 @@ func TestGetAndSetTransaction(t *testing.T) { t.FailNow() } tr := b.Transactions[1] - if !p.Set(tr, bc) { + if !p.Push(tr, bc) { t.FailNow() } @@ -36,7 +36,7 @@ func TestGetAndSetTransaction(t *testing.T) { func TestSetBadTransaction(t *testing.T) { p := New() bc := blockchain.NewTestBlockChain() - if p.Set(blockchain.NewTestTransaction(), bc) { + if p.Push(blockchain.NewTestTransaction(), bc) { t.FailNow() } } @@ -50,7 +50,7 @@ func TestUpdatePool(t *testing.T) { } for _, tr := range legitBlk.Transactions[1:] { - p.Set(tr, bc) + p.Push(tr, bc) } if p.Len() == 0 { t.FailNow() @@ -77,9 +77,9 @@ func TestGetIndex(t *testing.T) { p := New() numTxns := 1000 tr := blockchain.NewTestTransaction() - p.SetUnsafe(tr) + p.PushUnsafe(tr) for i := 0; i < numTxns; i++ { - p.SetUnsafe(blockchain.NewTestTransaction()) + p.PushUnsafe(blockchain.NewTestTransaction()) } if p.GetIndex(tr) != 0 { t.FailNow() @@ -98,7 +98,7 @@ func TestNextBlock(t *testing.T) { lastBlk := chain.Blocks[nBlks-1] numTxns := 1000 for i := 0; i < numTxns; i++ { - p.SetUnsafe(blockchain.NewTestTransaction()) + p.PushUnsafe(blockchain.NewTestTransaction()) } b := p.NextBlock(chain, blockchain.NewWallet().Public(), 1<<18) assert.NotNil(t, b) @@ -127,8 +127,8 @@ func TestSetDedupes(t *testing.T) { t1 := blockchain.NewTestTransaction() t2 := blockchain.NewTestTransaction() t1.Input.Hash = t2.Input.Hash - p.SetUnsafe(t1) - p.SetUnsafe(t2) + p.PushUnsafe(t1) + p.PushUnsafe(t2) assert.Equal(t, p.Peek(), t2) assert.Equal(t, p.Len(), 1) }