Documentation ¶
Index ¶
- Variables
- func AddJSONToIPFS(json []byte) (string, error)
- func CountLeadingZeroes(b [32]byte) int
- func InitIPFS() *ipfs.Shell
- type Message
- type Messages
- func (m *Messages) Add(msg *Message)
- func (m *Messages) AddMany(msgs *Messages)
- func (m *Messages) AddToIPFS() (string, error)
- func (m *Messages) Each(f func(msg *Message))
- func (m *Messages) JSON() ([]byte, error)
- func (m *Messages) MessageList() []*Message
- func (m *Messages) Remove(stamp string)
- func (m *Messages) Trim(n int)
Constants ¶
This section is empty.
Variables ¶
var IPFSGateway = "http://localhost:5001" // IPFS Gateway used to connect to the IPFS daemon
Functions ¶
func AddJSONToIPFS ¶
func CountLeadingZeroes ¶
Bitwise count leading zeroes in a byte slice
Types ¶
type Message ¶
Messages on Infodump use a "stamp" using the hashcash algorithm to prevent spam and enable storing messages by importance The Message type contains the message itself and a nonce that is used to verify the stamp
func (*Message) Hash ¶
Get the SHA256 hash of a message plus the timestamp plus the nonce as a byte slice
func (*Message) Lead ¶
Lead is a method that returns the number of leading zeroes in the hash of a message plus its nonce
func (*Message) ProofOfWork ¶
Proof of Work: Find the nonce for a message by hashing the message and checking for at least n initial zeroes in the binary representation of the resulting hash If it takes too long, return an error
func (*Message) SortNum ¶
SortNum of a Message returns a number that can be used to sort messages by importance The number is calculated by taking the timestamp of the message and adding an importance factor of 2^(leading zeros of hash / 8) to it If the timestamp is in the future, return 0 instead so the message will be discarded unless there are almost no messages
type Messages ¶
type Messages struct {
// contains filtered or unexported fields
}
Map Messages maps the stamp of the message to the message itself
func MessagesFromIPFS ¶
MessagesFromIPFS takes a CID and returns a Messages map
func (*Messages) MessageList ¶
MessageList returns a slice of Messages sorted by importance The slice is sorted by the SortNum method of the Message type It can be created from a Messages map by calling the Messages.Sorted method