diff --git a/gql.go b/gql.go index b338cd5..3ab9651 100644 --- a/gql.go +++ b/gql.go @@ -196,34 +196,6 @@ func AuthHandler(ctx *Context, server *Node, gql_ext *GQLExt) func(http.Response ctx.Log.Logf("gql", "GQL_AUTH_RESP_BAD_LENGTH: %d/%d", wrote, len(ser)) return } - - /*if exists { - ctx.Log.Logf("gql", "REFRESHING AUTH FOR %s", key_id) - } else { - ctx.Log.Logf("gql", "AUTHORIZING NEW USER %s - %s", key_id, shared) - - new_user := NewUser(fmt.Sprintf("GQL_USER %s", key_id.String()), time.Now(), remote_id, shared) - context := NewWriteContext(ctx) - err := UpdateStates(context, server, ACLMap{ - server.ID: ACLInfo{ - Node: server, - Resources: []string{"users"}, - }, - new_user.ID: ACLInfo{ - Node: &new_user, - Resources: nil, - }, - }, func(context *StateContext) error { - server.Users[key_id] = &new_user - return nil - }) - if err != nil { - ctx.Log.Logf("gql", "GQL_AUTH_UPDATE_ERR: %s", err) - return - } - }*/ - - } } func GraphiQLHandler() func(http.ResponseWriter, *http.Request) { diff --git a/node.go b/node.go index 36365db..bbbe4cd 100644 --- a/node.go +++ b/node.go @@ -469,47 +469,6 @@ func WriteNode(ctx *Context, node *Node) error { return txn.Set(id_bytes, bytes) }) } -func WriteNodes(context *StateContext) error { - err := ValidateStateContext(context, "write", true) - if err != nil { - return err - } - - context.Graph.Log.Logf("db", "DB_WRITES: %d", len(context.Locked)) - - serialized_bytes := make([][]byte, len(context.Locked)) - serialized_ids := make([][]byte, len(context.Locked)) - i := 0 - // TODO, just write states from the context, and store the current states in the context - for id, _ := range(context.Locked) { - node, _ := context.Graph.Nodes[id] - if node == nil { - return fmt.Errorf("DB_SERIALIZE_ERROR: cannot serialize nil node(%s), maybe node isn't in the context", id) - } - - ser, err := node.Serialize() - if err != nil { - return fmt.Errorf("DB_SERIALIZE_ERROR: %s", err) - } - - id_ser := node.ID.Serialize() - - serialized_bytes[i] = ser - serialized_ids[i] = id_ser - - i++ - } - - return context.Graph.DB.Update(func(txn *badger.Txn) error { - for i, id := range(serialized_ids) { - err := txn.Set(id, serialized_bytes[i]) - if err != nil { - return err - } - } - return nil - }) -} // Recursively load a node from the database. func LoadNode(ctx * Context, id NodeID) (*Node, error) {