data

package
v0.0.0-...-8ec5cd4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2023 License: GPL-3.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SystemTables = []string{
	"schema",
	"StoreMetadata",
	"Hooks",
	"NamespaceOwner",
	"InstalledModules",
	"ResourceAccess",
	"Systems",
	"FunctionSelectors",
	"SystemRegistry",
	"ResourceType",
	"KeysWithValue",
}

Functions

func AggregateKey

func AggregateKey(key [][32]byte) []byte

func BytesToFields

func BytesToFields(encoding []byte, schemaTypePair mudhelpers.SchemaTypePair, fieldnames *[]string) *[]Field

func GetBoolFromTable

func GetBoolFromTable(db *Database, w *World, rowID string, tableName string) bool

func GetInt64UsingBytes

func GetInt64UsingBytes(db *Database, w *World, rowID [32]byte, tableName string) (int64, error)

func GetInt64UsingString

func GetInt64UsingString(db *Database, w *World, rowID string, tableName string) (int64, error)

func GetRows

func GetRows(db *Database, w *World, tableName string) map[string][]Field

func SeparatorOffset

func SeparatorOffset(maxLenght int, wordLength int) int

Types

type AddressField

type AddressField struct {
	Data common.Address
}

func NewAddressField

func NewAddressField(encoding []byte) AddressField

func (AddressField) String

func (f AddressField) String() string

func (AddressField) Type

func (f AddressField) Type() string

type ArrayField

type ArrayField struct {
	Data []FieldData
}

func NewArrayField

func NewArrayField(size int) ArrayField

func (ArrayField) String

func (f ArrayField) String() string

func (ArrayField) Type

func (f ArrayField) Type() string

type BoolField

type BoolField struct {
	Data bool
}

func NewBoolField

func NewBoolField(encoding byte) BoolField

func NewBoolFromValue

func NewBoolFromValue(value bool) BoolField

func (BoolField) String

func (f BoolField) String() string

func (BoolField) Type

func (f BoolField) Type() string

type BytesField

type BytesField struct {
	Data []byte
}

func NewBytesField

func NewBytesField(data []byte) BytesField

func (BytesField) String

func (f BytesField) String() string

func (BytesField) Type

func (f BytesField) Type() string

type Database

type Database struct {
	Worlds                  map[string]*World
	Events                  []Event
	LastUpdate              time.Time
	LastHeight              uint64
	ChainID                 string
	UnconfirmedTransactions []UnconfirmedTransaction
	// contains filtered or unexported fields
}

func NewDatabase

func NewDatabase() *Database

func (*Database) AddEvent

func (db *Database) AddEvent(tableName string, key string, fields *[]Field)

func (*Database) AddRow

func (db *Database) AddRow(table *Table, key []byte, fields *[]Field) MudEvent

func (*Database) AddTxSent

func (db *Database) AddTxSent(tx UnconfirmedTransaction)

func (*Database) DeleteRow

func (db *Database) DeleteRow(table *Table, key []byte) MudEvent

func (*Database) GetDefaultWorld

func (db *Database) GetDefaultWorld() *World

func (*Database) GetRow

func (db *Database) GetRow(table *Table, key string) ([]Field, error)

func (*Database) GetRowNoMempool

func (db *Database) GetRowNoMempool(table *Table, key string) ([]Field, error)

func (*Database) GetRowUsingBytes

func (db *Database) GetRowUsingBytes(table *Table, key []byte) ([]Field, error)

func (*Database) GetRows

func (db *Database) GetRows(table *Table) map[string][]Field

func (*Database) GetTable

func (db *Database) GetTable(worldID string, tableID string) *Table

func (*Database) GetWorld

func (db *Database) GetWorld(worldID string) *World

func (*Database) SetDefaultWorld

func (db *Database) SetDefaultWorld(worldID string)

func (*Database) SetField

func (db *Database) SetField(table *Table, key []byte, event *mudhelpers.StorecoreStoreSetField) MudEvent

func (*Database) SetUpdateHandler

func (db *Database) SetUpdateHandler(handler func(table string, key string, fields *[]Field))

func (Database) ToStringList

func (db Database) ToStringList(maxLenght int) []string

type Event

type Event struct {
	// TODO: add world here
	// World string `json:"world"`
	Table string `json:"table"`
	Row   string `json:"row"`
	Value string `json:"value"`
}

type Field

type Field struct {
	Key  string
	Data FieldData
}

func BytesToFieldWithDefaults

func BytesToFieldWithDefaults(encoding []byte, schemaTypePair mudhelpers.SchemaTypePair, index uint8, fieldnames *[]string) (*[]Field, Field)

func GetRowFieldsUsingBytes

func GetRowFieldsUsingBytes(db *Database, w *World, rowID [32]byte, tableName string) ([]Field, error)

func GetRowFieldsUsingString

func GetRowFieldsUsingString(db *Database, w *World, rowID string, tableName string) ([]Field, error)

func GetRowFromIDUsingBytes

func GetRowFromIDUsingBytes(db *Database, w *World, rowID [32]byte, tableName string) (Field, string, error)

func GetRowFromIDUsingString

func GetRowFromIDUsingString(db *Database, w *World, rowID string, tableName string) (Field, string, error)

func (Field) String

func (f Field) String() string

func (Field) Type

func (f Field) Type() string

type FieldData

type FieldData interface {
	String() string
	Type() string
}

func BytesToDynamicField

func BytesToDynamicField(schemaType mudhelpers.SchemaType, encodingSlice []byte) FieldData

func BytesToStaticField

func BytesToStaticField(schemaType mudhelpers.SchemaType, encoding []byte, bytesOffset uint64) FieldData

func FieldWithDefautValue

func FieldWithDefautValue(schemaType mudhelpers.SchemaType) FieldData

type IntField

type IntField struct {
	Data big.Int
}

func NewIntField

func NewIntField(data []byte) IntField

func NewIntFieldFromNumber

func NewIntFieldFromNumber(value int64) IntField

func (IntField) String

func (f IntField) String() string

func (IntField) Type

func (f IntField) Type() string

type MudEvent

type MudEvent struct {
	Table  string
	Key    string
	Fields []Field
}

func CreateUint32Event

func CreateUint32Event(table string, rowID string, value int64) MudEvent

func NewMudEvent

func NewMudEvent(table *Table, row []byte, fields []Field) MudEvent

func NewMudEventStringEncoded

func NewMudEventStringEncoded(table string, rowID string, fields []Field) MudEvent

type StringField

type StringField struct {
	Data string
}

func NewStringField

func NewStringField(data []byte) StringField

func NewStringFieldFromValue

func NewStringFieldFromValue(value string) StringField

func (StringField) String

func (f StringField) String() string

func (StringField) Type

func (f StringField) Type() string

type Table

type Table struct {
	Metadata *TableMetadata
	Schema   *TableSchema
	Rows     *map[string][]Field
}

type TableMetadata

type TableMetadata struct {
	TableID          string
	TableName        string
	OnChainTableName string
	WorldAddress     string
}

type TableSchema

type TableSchema struct {
	FieldNames  *[]string
	KeyNames    *[]string
	Schema      *mudhelpers.SchemaTypeKV
	NamedFields *map[string]mudhelpers.SchemaType
}

type UintField

type UintField struct {
	Data big.Int
}

func NewUintField

func NewUintField(data []byte) UintField

func NewUintFieldFromNumber

func NewUintFieldFromNumber(value int64) UintField

func (UintField) String

func (f UintField) String() string

func (UintField) Type

func (f UintField) Type() string

type UnconfirmedTransaction

type UnconfirmedTransaction struct {
	Txhash string
	Events []MudEvent
}

type World

type World struct {
	Address string
	Tables  map[string]*Table
}

func (*World) GetTable

func (w *World) GetTable(tableID string) *Table

func (*World) GetTableByName

func (w *World) GetTableByName(tableName string) *Table

TODO: add a cache layer here to avoid the loop

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL