Example #1
0
// TouchPeer creates a peer entry if it does not exist yet
func (store Store) TouchPeer(pubkey *[ed25519.PublicKeySize]byte) {
	if !store.peersindex.Index(pubkey[:]).Exists() {
		s := structs.PeerStruct{
			AuthToken: [keyproof.ProofTokenSignedSize]byte{0x00},
		}
		store.peersindex.Index(pubkey[:]).Create(s.Encode().Fill())
	}
}
Example #2
0
// SelectPeer returns information about the peer
func (db *MessageDB) SelectPeer(pubkey *[ed25519.PublicKeySize]byte) (*structs.PeerStruct, error) {
	var authtokenT string
	r := new(structs.PeerStruct)
	err := db.peerSelectQ.QueryRow(toHex(pubkey[:])).Scan(
		&authtokenT,
		&r.LastNotifySend,
		&r.LastNotifyFrom,
		&r.LastFetch,
		&r.ErrorCount,
		&r.LastPosition,
	)
	if err != nil {
		return nil, err
	}
	r.AuthToken = *sliceToProofTokenSigned(fromHex(authtokenT))
	return r, nil
}