package Users import ( "github.com/nspcc-dev/neo-go/pkg/interop" "github.com/nspcc-dev/neo-go/pkg/interop/native/std" "github.com/nspcc-dev/neo-go/pkg/interop/storage" ) type User struct { name string surname string login string password string ownerHash interop.Hash160 } func NewUser(name string, surname string, login string, password string, owner interop.Hash160) { ctx := storage.GetContext() existing_login := storage.Get(ctx, login) if existing_login != nil { panic("this login is taken by someone else") } user := User{ name: name, surname: surname, login: login, password: password, ownerHash: owner, } saveUser(ctx, login, user) } func GetUser(ctx storage.Context, login string) User { data := storage.Get(ctx, login) if data == nil { panic("User does not exist") } return std.Deserialize(data.([]byte)).(User) } func saveUser(ctx storage.Context, userLogin string, user User) { storage.Put(ctx, user.ownerHash, std.Serialize(user)) storage.Put(ctx, string(user.ownerHash)+"LastPost", -1) storage.Put(ctx, string(user.ownerHash)+"LastCom", -1) }