Skip to content

Commit

Permalink
all: fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Oct 7, 2023
1 parent ad1119c commit 896eee7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
10 changes: 2 additions & 8 deletions cmd/fsd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"syscall"

"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/peer"
"go.sia.tech/fsd/build"
"go.sia.tech/fsd/config"
shttp "go.sia.tech/fsd/http"
Expand Down Expand Up @@ -99,7 +98,7 @@ func main() {
}
defer ds.Close()

privateKey, publicKey, _ := crypto.GenerateEd25519Key(frand.Reader)
privateKey, _, _ := crypto.GenerateEd25519Key(frand.Reader)
store := ipfs.NewRenterdBlockStore(ds, cfg.Renterd)

node, err := ipfs.NewNode(ctx, privateKey, cfg.IPFS, store)
Expand Down Expand Up @@ -142,13 +141,8 @@ func main() {
}
}()

peerID, err := peer.IDFromPublicKey(publicKey)
if err != nil {
log.Fatal("failed to get peer id", zap.Error(err))
}

log.Info("fsd started",
zap.Stringer("peerID", peerID),
zap.Stringer("peerID", node.PeerID()),
zap.String("apiAddress", apiListener.Addr().String()),
zap.String("gatewayAddress", gatewayListener.Addr().String()),
zap.String("version", build.Version()),
Expand Down
3 changes: 3 additions & 0 deletions ipfs/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var bootstrapPeers = []peer.AddrInfo{
mustParsePeer("/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"),
}

// A Node is a minimal IPFS node
type Node struct {
dht *kdht.IpfsDHT
host host.Host
Expand All @@ -42,6 +43,7 @@ type Node struct {
bitswap *bitswap.Bitswap
}

// Close closes the node
func (n *Node) Close() error {
n.dht.Close()
n.bitswap.Close()
Expand Down Expand Up @@ -80,6 +82,7 @@ func mustParsePeer(s string) peer.AddrInfo {
return *info
}

// NewNode creates a new IPFS node
func NewNode(ctx context.Context, privateKey crypto.PrivKey, cfg config.IPFS, blockstore blockstore.Blockstore) (*Node, error) {
cmgr, err := connmgr.NewConnManager(600, 900)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions ipfs/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ func TestTest(t *testing.T) {
downloadCtx, cancel := context.WithTimeout(ctx, 15*time.Second)
defer cancel()

// note: this currently only downloads the root CID. Need to walk the DAG
r, err := node.DownloadCID(downloadCtx, c)
if err != nil {
t.Fatal(err)
Expand Down
7 changes: 6 additions & 1 deletion ipfs/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ import (
"go.uber.org/zap"
)

// A Store implements the IPFS blockstore interface
type (
// A Store is a persistent store for IPFS blocks
Store interface {
GetBlock(ctx context.Context, c cid.Cid) (Block, error)
HasBlock(ctx context.Context, c cid.Cid) (bool, error)
AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
}

// A RenterdBlockStore is a blockstore backed by a renterd node IPFS blocks
// are stored in a local database and backed by a renterd node. The primary
// difference between this and a normal IPFS blockstore is that an object is
// stored on the renterd node in one piece and the offsets for each block
// are stored in the database.
RenterdBlockStore struct {
store Store
log *zap.Logger
Expand Down

0 comments on commit 896eee7

Please sign in to comment.