Changed peer schema and added additional tests

This commit is contained in:
cpb8010
2013-09-07 20:22:30 -04:00
parent cd6e4abec0
commit 42f9427c01
6 changed files with 541 additions and 232 deletions
+5 -12
View File
@@ -7,7 +7,6 @@
package cache
import (
"errors"
"fmt"
"github.com/pushrax/chihaya/config"
@@ -15,9 +14,7 @@ import (
)
var (
drivers = make(map[string]Driver)
ErrTxDone = errors.New("cache: Transaction has already been committed or rolled back")
ErrTxConflict = errors.New("cache: Commit interrupted, update transaction and repeat")
drivers = make(map[string]Driver)
)
type Driver interface {
@@ -57,15 +54,9 @@ type Pool interface {
Get() (Tx, error)
}
// Tx represents an in-progress data store transaction.
// A transaction must end with a call to Commit or Rollback.
//
// After a call to Commit or Rollback, all operations on the
// transaction must fail with ErrTxDone.
// The transmit object is the interface to add, remove and modify
// data in the cache
type Tx interface {
Commit() error
Rollback() error
// Reads
FindUser(passkey string) (*models.User, bool, error)
FindTorrent(infohash string) (*models.Torrent, bool, error)
@@ -86,4 +77,6 @@ type Tx interface {
RemoveTorrent(t *models.Torrent) error
AddUser(u *models.User) error
RemoveUser(u *models.User) error
WhitelistClient(peerID string) error
UnWhitelistClient(peerID string) error
}