-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
34 lines (28 loc) · 720 Bytes
/
Copy pathmain.go
File metadata and controls
34 lines (28 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"log"
"github.com/girish/storage/p2p"
"github.com/girish/storage/store"
)
func main() {
tcpOpts := p2p.TCPTransportOps{
ListenAdder: ":3000",
Handshakefunc: p2p.NOPHandshakeFunc,
Decode: p2p.LengthPrefixDecoder{},
}
tr := p2p.NewTCPTransport(tcpOpts)
storeOpts := store.StoreOpts{
Root: "my_network_data",
PathTransformFunc: store.CASPathTransfromFunc,
}
localStore := store.NewStore(storeOpts)
serverOpts := FileServerOpts{
StorageRoot: "my_network_data", // This is where files will be saved later
Transport: tr,
Store: localStore,
}
server := NewFileServer(serverOpts)
if err := server.Start(); err != nil {
log.Fatal(err)
}
}