blob: b4a0f20152e8e0efec394ff640e96a5eeb77d90e (
plain)
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
35
36
37
|
// Infodump is a commandline social network that works over IPFS and communicates through PubSub
package main
import (
"fmt"
"os"
"strconv"
"strings"
"git.kiefte.eu/lapingvino/infodump/message"
)
// pubsub "github.com/libp2p/go-libp2p-pubsub"
// ipfs "github.com/ipfs/go-ipfs-api"
// Main function: get the minimal Proof of Work for a message as the first argument, the message as the rest of the argument and return the stamp
func main() {
// Check if the user provided a number and a message
if len(os.Args) < 3 {
fmt.Println("Please provide a number and a message")
os.Exit(1)
}
// Get the number of initial zeroes from the user
n, err := strconv.Atoi(os.Args[1])
if err != nil {
fmt.Println("Please provide a number")
os.Exit(1)
}
// Get the message from the user
msg := strings.Join(os.Args[2:], " ")
// Create a new message
m := message.New(msg, n)
// Print the stamp
fmt.Println(m.Stamp())
// Print the message, nonce and number of leading zeroes
fmt.Println(m.Message, m.Nonce, m.Lead())
}
|