File Sharing MVP #384
|
@ -7,10 +7,8 @@ import (
|
|||
"cwtch.im/cwtch/protocol/groups"
|
||||
model3 "cwtch.im/cwtch/protocol/model"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.openprivacy.ca/cwtch.im/tapir"
|
||||
"git.openprivacy.ca/cwtch.im/tapir/applications"
|
||||
"git.openprivacy.ca/cwtch.im/tapir/networks/tor"
|
||||
|
@ -21,7 +19,6 @@ import (
|
|||
"github.com/gtank/ristretto255"
|
||||
"golang.org/x/crypto/ed25519"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
@ -214,31 +211,6 @@ func (e *engine) eventHandler() {
|
|||
}
|
||||
}
|
||||
|
||||
func (e *engine) fetchManifest(handle string, fileKey string, manifestSize uint64) {
|
||||
// Store a blank manifest
|
||||
e.manifests.Store(fileKey, strings.Repeat("\"", int(manifestSize*files.DefaultChunkSize)))
|
||||
conn, err := e.service.WaitForCapabilityOrClose(handle, cwtchCapability)
|
||||
if err == nil {
|
||||
peerApp, ok := (conn.App()).(*PeerApp)
|
||||
if ok {
|
||||
peerApp.FetchManifestChunks(fileKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (e *engine) sendManifestChunk(handle string, fileKey string, id uint64, chunk []byte) {
|
||||
conn, err := e.service.WaitForCapabilityOrClose(handle, cwtchCapability)
|
||||
if err == nil {
|
||||
peerApp, ok := (conn.App()).(*PeerApp)
|
||||
if ok {
|
||||
peerApp.SendMessage(PeerMessage{
|
||||
Context: event.ContextSendManifest,
|
||||
ID: fmt.Sprintf("%s.%d", fileKey, id),
|
||||
Data: chunk,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (e *engine) isBlocked(onion string) bool {
|
||||
authorization, known := e.authorizations.Load(onion)
|
||||
|
|
|
@ -117,17 +117,4 @@ func (pa *PeerApp) SendMessage(message model2.PeerMessage) {
|
|||
}
|
||||
serialized, _ := json.Marshal(message)
|
||||
pa.connection.Send(serialized)
|
||||
}
|
||||
|
||||
func (pa *PeerApp) FetchManifestChunks(key string) {
|
||||
|
||||
message := PeerMessage{
|
||||
Context: event.ContextRequestManifest,
|
||||
ID: key,
|
||||
Data: []byte{},
|
||||
}
|
||||
|
||||
serialized, _ := json.Marshal(message)
|
||||
pa.connection.Send(serialized)
|
||||
|
||||
}
|
Loading…
Reference in New Issue