Documentation ¶
Index ¶
Constants ¶
const (
// P2PProtocolName will be used by libp2p streams
P2PProtocolName = "ipfsShareP2P"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressBook ¶
type AddressBook struct {
// contains filtered or unexported fields
}
AddressBook is a cache for fellow users' P2P contact data
func NewAddressBook ¶
func NewAddressBook(backend chequebook.Backend, app *ethapp.FileTribeDApp, ipfs ipfs.IIpfs) *AddressBook
NewAddressBook creates a new AddressBook
type Contact ¶
type Contact struct { AccountAddress ethcommon.Address EthAccountAddress ethcommon.Address Name string IpfsPeerID string Boxer tribecrypto.AnonymPublicKey // contains filtered or unexported fields }
Contact stores necessary information for P2P communication with a user
func NewContact ¶
func NewContact( address ethcommon.Address, accAddr ethcommon.Address, name string, ipfsPeerID string, boxer tribecrypto.AnonymPublicKey, ipfs ipfs.IIpfs) *Contact
NewContact creates a new contact
func (*Contact) VerifySignature ¶
VerifySignature verifies a signature if it really was made by the user this contact is representing
type GroupData ¶
type GroupData byte
GroupData is an enumeration of which group data wants to be retrieved by peers
type GroupDataMessage ¶
type GroupDataMessage struct { Group ethcommon.Address `json:"group"` Data GroupData `json:"data"` Payload []byte }
GroupDataMessage is a wrapper for transferring group data like current key, a proposed key
func DecodeGroupDataMessage ¶
func DecodeGroupDataMessage(data []byte) (*GroupDataMessage, error)
DecodeGroupDataMessage decodes a group message data
func (*GroupDataMessage) Encode ¶
func (m *GroupDataMessage) Encode() ([]byte, error)
Encode encodes the group data message
type Message ¶
type Message struct { From ethcommon.Address `json:"from"` Type MessageType `json:"type"` SessionID uint32 `json:"session_id"` Payload []byte `json:"payload"` Sig []byte `json:"sig"` }
Message is a message struct
func DecodeMessage ¶
DecodeMessage decodes a message byte stream
func NewMessage ¶
func NewMessage(from ethcommon.Address, msgType MessageType, sessionID uint32, payload []byte, signer Signer) (*Message, error)
NewMessage creates a new message
type MessageType ¶
type MessageType byte
MessageType is an enumeration of message types
const ( // GetGroupData enum value GetGroupData MessageType = 0 )
type P2PConn ¶
P2PConn is tcp connection to an IPFS p2p dial/stream endpoint
func (*P2PConn) ReadMessage ¶
func (conn *P2PConn) ReadMessage(addressBook *AddressBook) (*Message, error)
ReadMessage reads a message from the connection socket