diff --git a/x/indexer/data/database.go b/x/indexer/data/database.go index 66ef7d3..11d9262 100644 --- a/x/indexer/data/database.go +++ b/x/indexer/data/database.go @@ -81,6 +81,8 @@ type Database struct { ChainID string UnconfirmedTransactions []UnconfirmedTransaction txSentMutex *sync.Mutex + + defaultWorld string } func NewDatabase() *Database { @@ -93,6 +95,8 @@ func NewDatabase() *Database { // TODO: use a list instead of array UnconfirmedTransactions: []UnconfirmedTransaction{}, txSentMutex: &sync.Mutex{}, + // Helper for games + defaultWorld: "", } } @@ -118,6 +122,17 @@ func (db *Database) AddEvent(tableName string, key string, fields *[]Field) { db.LastUpdate = time.Now() } +func (db *Database) SetDefaultWorld(worldID string) { + db.defaultWorld = worldID +} + +func (db *Database) GetDefaultWorld() *World { + if db.defaultWorld == "" { + return nil + } + return db.GetWorld(db.defaultWorld) +} + func (db *Database) GetWorld(worldID string) *World { if world, ok := db.Worlds[worldID]; ok { return world