forked from grassrootseconomics/visedriver
		
	remove redundant code
This commit is contained in:
		
							parent
							
								
									5ff06e8626
								
							
						
					
					
						commit
						4d7c584394
					
				@ -1,10 +1,7 @@
 | 
				
			|||||||
package utils
 | 
					package utils
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"context"
 | 
					 | 
				
			||||||
	"encoding/binary"
 | 
						"encoding/binary"
 | 
				
			||||||
 | 
					 | 
				
			||||||
	"git.defalsify.org/vise.git/db"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type DataTyp uint16
 | 
					type DataTyp uint16
 | 
				
			||||||
@ -37,22 +34,3 @@ func PackKey(typ DataTyp, data []byte) []byte {
 | 
				
			|||||||
	v := typToBytes(typ)
 | 
						v := typToBytes(typ)
 | 
				
			||||||
	return append(v, data...)
 | 
						return append(v, data...)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func ReadEntry(ctx context.Context, store db.Db, sessionId string, typ DataTyp) ([]byte, error) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	store.SetPrefix(db.DATATYPE_USERDATA)
 | 
					 | 
				
			||||||
	store.SetSession(sessionId)
 | 
					 | 
				
			||||||
	k := PackKey(typ, []byte(sessionId))
 | 
					 | 
				
			||||||
	b, err := store.Get(ctx, k)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return nil, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return b, nil
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func WriteEntry(ctx context.Context, store db.Db, sessionId string, typ DataTyp, value []byte) error {
 | 
					 | 
				
			||||||
	store.SetPrefix(db.DATATYPE_USERDATA)
 | 
					 | 
				
			||||||
	store.SetSession(sessionId)
 | 
					 | 
				
			||||||
	k := PackKey(typ, []byte(sessionId))
 | 
					 | 
				
			||||||
	return store.Put(ctx, k, value)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user