Skip to content

Commit

Permalink
update GetTxns to return empty list
Browse files Browse the repository at this point in the history
  • Loading branch information
chadlagore committed Jun 17, 2017
1 parent 17eeffd commit cc92388
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,15 @@ func (p *Pool) Update(b *blockchain.Block, bc *blockchain.BlockChain) bool {
// GetTxns returns the the largest of l or size of pool transactions.
// It selects the highest priority transactions.
func (p *Pool) GetTxns(l int) []*blockchain.Transaction {
var txns []*blockchain.Transaction
if p.Len() == 0 {
return txns
return make([]*blockchain.Transaction, 0)
}
if p.Len() < l {
l = p.Len()
}
i := 0
for i < l {
txns = append(txns, p.GetN(i))
i++
txns := make([]*blockchain.Transaction, l)
for i := 0; i < l; i++ {
txns[i] = p.GetN(i)
}
return txns
}
2 changes: 1 addition & 1 deletion pool/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestGetTxns(t *testing.T) {
func TestGetNewBlockEmpty(t *testing.T) {
p := New()
txns := p.GetTxns(305)
if txns != nil {
if len(txns) != 0 {
t.FailNow()
}
}

0 comments on commit cc92388

Please sign in to comment.