Simple Node Mode

The default node deployed by BTFS is a mining node, which needs to recharge the vault contract on the BTTC chain. You can also upload files from the local nodes. These are relatively heavy functions and operations.

Sometimes, you want to have a relatively simple model that does not participate in the above operations, and only provides basic file upload, file download, and node p2p interconnection. One applications scenario is the gateway of BTFS, which is also a common BTFS node, which mainly provides queries and downloads of files in the BTFS network.

In addition, the default mining mode and simple node mode can be quickly switched, modify the configuration file, restart the node, you can switch to different modes.

1.Deploy a new node in simple node mode

Initialize a BTFS Daemon

./btfs init --simple-mode=true

Generating TRON key with BIP39 seed phrase...
Master public key:  xpub661MyMwAqRbcEjAyPSw5jg8dLuSjsx9H531g5K3eygpRBpNtk4PTVELXNCnar6CRXu3ajZpCkrxXgXQ7yFy4K4ssyf3M3T5MEVdbGdnGZXj
initializing BTFS node at /Users/xxx/.btfs
generating btfs node keypair with TRON key...done
peer identity: 16Uiu2HAkws1oLCzm7FJ6B8rbgcS6U6ezB2GcBnjdV3bfRsJGpNRK
to get started, enter:

	btfs cat /btfs/QmZjrLVdUpqVU6Pnc8pBnyQxVdpn9J8tfcsycP84W6N93C/readme

Start the Daemon

$ ./btfs  daemon    

Initializing daemon...
go-btfs version: 2.3.2
Repo version: 10
System version: amd64/darwin
Golang version: go1.18.3
Repo location: /Users/xxx/.btfs
Peer identity: 16Uiu2HAkws1oLCzm7FJ6B8rbgcS6U6ezB2GcBnjdV3bfRsJGpNRK
the address of Bttc format is:  0xf713Ce4bE8498782765abb35fe7B5785AAAFe30A
the address of Tron format is:  TYVddaKuN8fAqgoegvDm28dZCeY8DvRVcv
Swarm listening on /ip4/
Swarm listening on /ip4/
Swarm listening on /ip4/
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/
Swarm announcing /ip4/
Swarm announcing /ip6/::1/tcp/4001
API server listening on /ip4/
Gateway server listening on /ip4/
Remote API server listening on /ip4/
Daemon is ready

2.Upload files and download files

Upload file

$ ./btfs add t.txt 
added QmWEkNNf7XUJ2aS6BhNs9UNRnusVVyFfbmD7L9HmPFWnQP t.txt
 4 B / 4 B [=======================================================================================================================================] 100.00

download file

$ ./btfs get QmWEkNNf7XUJ2aS6BhNs9UNRnusVVyFfbmD7L9HmPFWnQP
Saving file(s) to QmWEkNNf7XUJ2aS6BhNs9UNRnusVVyFfbmD7L9HmPFWnQP
 4 B / 4 B [====================================================================================================================================] 100.00% 0s

3.Switch between simple node mode and default mode

a. If the node is in simple node after deployment, and switches to the default miner mode for the first time, it needs to recharge BTT deployment vault contract and other operations.

b. If you switch from the default miner mode to simple node mode, you can directly modify the configuration and restart the node.

c. Modify the configuration to switch to simple node mode

Open the BTFS_PATH config to modify it, and restart the BTFS node.

#1.kill BTFS node

#2.modify config file
$ vim ~/.btfs/config 
"SimpleMode": true

#3.restart btfs node
$ ./btfs  daemon 

d. use commands to switch to simple node mode

#1.kill BTFS node

#2.modify config file
$ ./btfs config sync-simple-mode true 
set simple mode = true 
    please restart the node to use it!
#3.restart btfs node
$ ./btfs  daemon