]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/transaction.go
Fix more filepaths
[rbdr/mobius] / hotline / transaction.go
index 04fb4b6520cb51a884ca4f7b86e9c208870d6716..077e6f3050f0a75942bbac83f25921df87831943 100644 (file)
@@ -6,7 +6,6 @@ import (
        "fmt"
        "github.com/jhalter/mobius/concat"
        "math/rand"
-       "net"
 )
 
 const (
@@ -40,7 +39,7 @@ const (
        tranGetFileInfo          = 206
        tranSetFileInfo          = 207
        tranMoveFile             = 208
-       tranMakeFileAlias        = 209 // TODO: implement file alias command
+       tranMakeFileAlias        = 209
        tranDownloadFldr         = 210
        // tranDownloadInfo         = 211 TODO: implement file transfer queue
        // tranDownloadBanner     = 212 TODO: figure out what this is used for
@@ -131,29 +130,6 @@ func ReadTransaction(buf []byte) (*Transaction, int, error) {
        }, tranLen, nil
 }
 
-func readN(conn net.Conn, n int) ([]Transaction, error) {
-       buf := make([]byte, 1400)
-       i := 0
-       for {
-               readLen, err := conn.Read(buf)
-               if err != nil {
-                       return nil, err
-               }
-
-               transactions, _, err := readTransactions(buf[:readLen])
-               //              spew.Fdump(os.Stderr, transactions)
-               if err != nil {
-                       return nil, err
-               }
-
-               i += len(transactions)
-
-               if n == i {
-                       return transactions, nil
-               }
-       }
-}
-
 func readTransactions(buf []byte) ([]Transaction, int, error) {
        var transactions []Transaction
 
@@ -214,7 +190,7 @@ func ReadFields(paramCount []byte, buf []byte) ([]Field, error) {
        return fields, nil
 }
 
-func (t Transaction) MarshalBinary() (data []byte, err error) {
+func (t *Transaction) MarshalBinary() (data []byte, err error) {
        payloadSize := t.Size()
 
        fieldCount := make([]byte, 2)
@@ -238,7 +214,7 @@ func (t Transaction) MarshalBinary() (data []byte, err error) {
 }
 
 // Size returns the total size of the transaction payload
-func (t Transaction) Size() []byte {
+func (t *Transaction) Size() []byte {
        bs := make([]byte, 4)
 
        fieldSize := 0
@@ -251,7 +227,7 @@ func (t Transaction) Size() []byte {
        return bs
 }
 
-func (t Transaction) GetField(id int) Field {
+func (t *Transaction) GetField(id int) Field {
        for _, field := range t.Fields {
                if id == int(binary.BigEndian.Uint16(field.ID)) {
                        return field