mirror of
https://github.com/colinear-labs/chain.git
synced 2026-03-05 03:44:26 -08:00
func to get all bids from memdb
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user