func to get all bids from memdb
parent
1105b49c6e
commit
a2f5ce1fc1
|
@ -113,6 +113,27 @@ func (b *bidDB) GetHighestBid(auctionId string) (*types.Bid, error) {
|
|||
return bid, err
|
||||
}
|
||||
|
||||
func (b *bidDB) GetBids(auctionId string) ([]*types.Bid, error) {
|
||||
k := []byte(auctionId)
|
||||
|
||||
var bids []*types.Bid
|
||||
err := b.db.View(func(txn *badger.Txn) error {
|
||||
res, err := txn.Get(k)
|
||||
if err != nil {
|
||||
} else {
|
||||
err := res.Value(func(val []byte) error {
|
||||
dec := gob.NewDecoder(bytes.NewReader(val))
|
||||
err := dec.Decode(&bids)
|
||||
return err
|
||||
})
|
||||
return err
|
||||
}
|
||||
return err
|
||||
})
|
||||
|
||||
return bids, err
|
||||
}
|
||||
|
||||
func (b *bidDB) ClearAuction(auctionId string) error {
|
||||
k := []byte(auctionId)
|
||||
|
||||
|
|
Loading…
Reference in New Issue