mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-13 12:33:25 +02:00
Revert changes to use natural primary keys
This commit is contained in:
parent
254c348882
commit
aaf6ae975d
50 changed files with 558 additions and 605 deletions
|
|
@ -40,12 +40,12 @@ export default function BuyOfferDetailItem({
|
|||
|
||||
const onPeerClick = (event) => {
|
||||
event.preventDefault();
|
||||
const peerHash = getPeerHash();
|
||||
if (peerHash == null) {
|
||||
const peerId = getPeerId();
|
||||
if (peerId == null) {
|
||||
return;
|
||||
}
|
||||
console.log("Handling peer click for peerHash: " + peerHash);
|
||||
goToPeerPage(history, peerHash);
|
||||
console.log("Handling peer click for peerId: " + peerId);
|
||||
goToPeerPage(history, peerId);
|
||||
}
|
||||
|
||||
const onLightningNodeClick = (event) => {
|
||||
|
|
@ -58,12 +58,12 @@ export default function BuyOfferDetailItem({
|
|||
)
|
||||
}
|
||||
|
||||
const getPeerHash = () => {
|
||||
const getPeerId = () => {
|
||||
if (!offer.getHasPeer()) {
|
||||
return null;
|
||||
}
|
||||
const peer = offer.getPeer();
|
||||
return peer.getPeerHash();
|
||||
return peer.getPeerId();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -96,9 +96,9 @@ export default function BuyOfferDetailItem({
|
|||
}
|
||||
|
||||
function HasPeerDisplay(peer) {
|
||||
const peerHash = peer.getPeerHash();
|
||||
const peerId = peer.getPeerId();
|
||||
const peerName = peer.getPeerName();
|
||||
const peerDisplayName = peerName ? peerName : peerHash;
|
||||
const peerDisplayName = peerName ? peerName : peerId;
|
||||
return (
|
||||
<Link href="#"
|
||||
onClick={onPeerClick}
|
||||
|
|
|
|||
|
|
@ -62,17 +62,15 @@ export default function ConfigureProfileDialog({
|
|||
};
|
||||
|
||||
const handleSettingsFollowingChange = (event) => {
|
||||
const profileAddress = squeakProfile.getAddress();
|
||||
console.log("Following changed for profile with address: " + profileAddress);
|
||||
console.log("Following changed for profile id: " + squeakProfile.getProfileId());
|
||||
console.log("Following changed to: " + event.target.checked);
|
||||
setFollowing(profileAddress, event.target.checked);
|
||||
setFollowing(squeakProfile.getProfileId(), event.target.checked);
|
||||
};
|
||||
|
||||
const handleSettingsSharingChange = (event) => {
|
||||
const profileAddress = squeakProfile.getAddress();
|
||||
console.log("Sharing changed for profile with address: " + profileAddress);
|
||||
console.log("Sharing changed for profile id: " + squeakProfile.getProfileId());
|
||||
console.log("Sharing changed to: " + event.target.checked);
|
||||
setSharing(profileAddress, event.target.checked);
|
||||
setSharing(squeakProfile.getProfileId(), event.target.checked);
|
||||
};
|
||||
|
||||
function MakeCancelButton() {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export default function CreateContactProfileDialog({
|
|||
};
|
||||
|
||||
const handleResponse = (response) => {
|
||||
goToProfilePage(history, response.getAddress());
|
||||
goToProfilePage(history, response.getProfileId());
|
||||
};
|
||||
|
||||
const handleErr = (err) => {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ export default function CreatePeerDialog({
|
|||
|
||||
const createPeer = (peerName, host, port) => {
|
||||
createPeerRequest(peerName, host, port, (response) => {
|
||||
goToPeerPage(history, response.getPeerHash());
|
||||
goToPeerPage(history, response.getPeerId());
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ export default function CreateSigningProfileDialog({
|
|||
};
|
||||
|
||||
const handleResponse = (response) => {
|
||||
goToProfilePage(history, response.getAddress());
|
||||
goToProfilePage(history, response.getProfileId());
|
||||
};
|
||||
|
||||
const handleErr = (err) => {
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ export default function DeletePeerDialog({
|
|||
var classes = useStyles();
|
||||
const history = useHistory();
|
||||
|
||||
const deletePeer = (peerHash) => {
|
||||
deletePeerRequest(peerHash, (response) => {
|
||||
const deletePeer = (peerId) => {
|
||||
deletePeerRequest(peerId, (response) => {
|
||||
reloadRoute(history);
|
||||
});
|
||||
};
|
||||
|
|
@ -54,9 +54,9 @@ export default function DeletePeerDialog({
|
|||
function handleSubmit(event) {
|
||||
event.preventDefault();
|
||||
console.log( 'peer:', peer);
|
||||
var peerHash = peer.getPeerHash();
|
||||
console.log( 'peerHash:', peerHash);
|
||||
deletePeer(peerHash);
|
||||
var peerId = peer.getPeerId();
|
||||
console.log( 'peerId:', peerId);
|
||||
deletePeer(peerId);
|
||||
handleClose();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,9 +54,9 @@ export default function DeleteProfileDialog({
|
|||
function handleSubmit(event) {
|
||||
event.preventDefault();
|
||||
console.log( 'profile:', profile);
|
||||
var squeakAddress = profile.getAddress();
|
||||
console.log( 'squeakAddress:', squeakAddress);
|
||||
deleteProfile(squeakAddress);
|
||||
var profileId = profile.getProfileId();
|
||||
console.log( 'profileId:', profileId);
|
||||
deleteProfile(profileId);
|
||||
handleClose();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,8 +55,8 @@ export default function ExportPrivateKeyDialog({
|
|||
};
|
||||
|
||||
const getPrivateKey = () => {
|
||||
var profileAddress = profile.getAddress();
|
||||
getSqueakProfilePrivateKey(profileAddress, (response) => {
|
||||
var profileId = profile.getProfileId();
|
||||
getSqueakProfilePrivateKey(profileId, (response) => {
|
||||
setPrivateKey(response.getPrivateKey());
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -61,8 +61,7 @@ export default function ImportSigningProfileDialog({
|
|||
};
|
||||
|
||||
const handleResponse = (response) => {
|
||||
const profileAddress = response.getAddress();
|
||||
goToProfilePage(history, profileAddress);
|
||||
goToProfilePage(history, response.getProfileId());
|
||||
};
|
||||
|
||||
const handleErr = (err) => {
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ function Layout(props) {
|
|||
<Route path="/app/lightningnode/:pubkey" component={LightningNode} />
|
||||
<Route path="/app/channel/:txId/:outputIndex" component={Channel} />
|
||||
<Route path="/app/peers" component={Peers} />
|
||||
<Route path="/app/peer/:hash" component={Peer} />
|
||||
<Route path="/app/peer/:id" component={Peer} />
|
||||
<Route path="/app/notifications" component={Notifications} />
|
||||
<Route
|
||||
exact
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ export default function MakeSqueakDialog({
|
|||
onChange={handleChange}
|
||||
>
|
||||
{signingProfiles.map(p =>
|
||||
<MenuItem key={p.getAddress()} value={p.getAddress()}>{p.getProfileName()}</MenuItem>
|
||||
<MenuItem key={p.getProfileId()} value={p.getProfileId()}>{p.getProfileName()}</MenuItem>
|
||||
)}
|
||||
</Select>
|
||||
</FormControl>
|
||||
|
|
|
|||
|
|
@ -47,12 +47,12 @@ export default function SentPayment({
|
|||
|
||||
const onPeerClick = (event) => {
|
||||
event.preventDefault();
|
||||
const peerHash = getPeerHash();
|
||||
if (peerHash == null) {
|
||||
const peerId = getPeerId();
|
||||
if (peerId == null) {
|
||||
return;
|
||||
}
|
||||
console.log("Handling peer click for peerHash: " + peerHash);
|
||||
goToPeerPage(history, peerHash);
|
||||
console.log("Handling peer click for peerId: " + peerId);
|
||||
goToPeerPage(history, peerId);
|
||||
}
|
||||
|
||||
const onLightningNodeClick = (event) => {
|
||||
|
|
@ -62,12 +62,12 @@ export default function SentPayment({
|
|||
goToLightningNodePage(history, nodePubkey);
|
||||
}
|
||||
|
||||
const getPeerHash = () => {
|
||||
const getPeerId = () => {
|
||||
if (!sentPayment.getHasPeer()) {
|
||||
return null;
|
||||
}
|
||||
const peer = sentPayment.getPeer();
|
||||
return peer.getPeerHash();
|
||||
return peer.getPeerId();
|
||||
}
|
||||
|
||||
const getPeerDisplay = () => {
|
||||
|
|
@ -76,8 +76,8 @@ export default function SentPayment({
|
|||
}
|
||||
const peer = sentPayment.getPeer();
|
||||
const peerName = peer.getPeerName();
|
||||
const peerHash = peer.getPeerHash();
|
||||
return peerName ? peerName : peerHash;
|
||||
const peerId = peer.getPeerId();
|
||||
return peerName ? peerName : peerId;
|
||||
}
|
||||
|
||||
function PeerDisplay() {
|
||||
|
|
@ -89,9 +89,9 @@ export default function SentPayment({
|
|||
}
|
||||
|
||||
function HasPeerDisplay(peer) {
|
||||
const peerHash = peer.getPeerHash();
|
||||
const peerId = peer.getPeerId();
|
||||
const peerName = peer.getPeerName();
|
||||
const peerDisplayName = peerName ? peerName : peerHash;
|
||||
const peerDisplayName = peerName ? peerName : peerId;
|
||||
return (
|
||||
<Link href="#"
|
||||
onClick={onPeerClick}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ export default function UpdateProfileImageDialog({
|
|||
|
||||
const updateProfileImage = (imageStr) => {
|
||||
setSqueakProfileImageRequest(
|
||||
squeakProfile.getAddress(),
|
||||
squeakProfile.getProfileId(),
|
||||
imageStr,
|
||||
handleResponse,
|
||||
handleErr,
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ export const reloadRoute = (history) => {
|
|||
history.go(0);
|
||||
};
|
||||
|
||||
export const goToPeerPage = (history, peerHash) => {
|
||||
history.push("/app/peer/" + peerHash);
|
||||
export const goToPeerPage = (history, peerId) => {
|
||||
history.push("/app/peer/" + peerId);
|
||||
};
|
||||
|
||||
export const goToLightningNodePage = (history, pubkey, host, port) => {
|
||||
|
|
@ -29,8 +29,8 @@ export const goToChannelPage = (history, txId, outputIndex) => {
|
|||
history.push("/app/channel/" + txId + "/" + outputIndex);
|
||||
};
|
||||
|
||||
export const goToProfilePage = (history, squeakAddress) => {
|
||||
history.push("/app/profile/" + squeakAddress);
|
||||
export const goToProfilePage = (history, profileId) => {
|
||||
history.push("/app/profile/" + profileId);
|
||||
};
|
||||
|
||||
export const goToWalletPage = (history) => {
|
||||
|
|
|
|||
|
|
@ -29,27 +29,27 @@ import {
|
|||
|
||||
export default function PeerPage() {
|
||||
var classes = useStyles();
|
||||
const { hash } = useParams();
|
||||
const { id } = useParams();
|
||||
const [peer, setPeer] = useState(null);
|
||||
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
||||
|
||||
const getSqueakPeer = (hash) => {
|
||||
getPeerRequest(hash, setPeer);
|
||||
const getSqueakPeer = (id) => {
|
||||
getPeerRequest(id, setPeer);
|
||||
};
|
||||
const setDownloading = (hash, downloading) => {
|
||||
setPeerDownloadingRequest(hash, downloading, () => {
|
||||
getSqueakPeer(hash);
|
||||
const setDownloading = (id, downloading) => {
|
||||
setPeerDownloadingRequest(id, downloading, () => {
|
||||
getSqueakPeer(id);
|
||||
});
|
||||
};
|
||||
const setUploading = (hash, uploading) => {
|
||||
setPeerUploadingRequest(hash, uploading, () => {
|
||||
getSqueakPeer(hash);
|
||||
const setUploading = (id, uploading) => {
|
||||
setPeerUploadingRequest(id, uploading, () => {
|
||||
getSqueakPeer(id);
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(()=>{
|
||||
getSqueakPeer(hash)
|
||||
},[hash]);
|
||||
getSqueakPeer(id)
|
||||
},[id]);
|
||||
|
||||
const handleClickOpenDeleteDialog = () => {
|
||||
setDeleteDialogOpen(true);
|
||||
|
|
@ -61,15 +61,15 @@ export default function PeerPage() {
|
|||
};
|
||||
|
||||
const handleSettingsDownloadingChange = (event) => {
|
||||
console.log("Downloading changed for peer hash: " + hash);
|
||||
console.log("Downloading changed for peer id: " + id);
|
||||
console.log("Downloading changed to: " + event.target.checked);
|
||||
setDownloading(hash, event.target.checked);
|
||||
setDownloading(id, event.target.checked);
|
||||
};
|
||||
|
||||
const handleSettingsUploadingChange = (event) => {
|
||||
console.log("Uploading changed for peer hash: " + hash);
|
||||
console.log("Uploading changed for peer id: " + id);
|
||||
console.log("Uploading changed to: " + event.target.checked);
|
||||
setUploading(hash, event.target.checked);
|
||||
setUploading(id, event.target.checked);
|
||||
};
|
||||
|
||||
function NoPeerContent() {
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ export default function Peers() {
|
|||
title="Peers"
|
||||
data={peers.map(s =>
|
||||
[
|
||||
s.getPeerHash(),
|
||||
s.getPeerId(),
|
||||
s.getPeerName(),
|
||||
s.getHost(),
|
||||
s.getPort(),
|
||||
|
|
|
|||
|
|
@ -230,14 +230,21 @@ export default function Profiles() {
|
|||
title={title}
|
||||
data={profiles.map(p =>
|
||||
[
|
||||
p.getAddress(),
|
||||
p.getProfileId(),
|
||||
p.getProfileName(),
|
||||
p.getAddress(),
|
||||
p.getFollowing().toString(),
|
||||
p.getSharing().toString(),
|
||||
]
|
||||
)}
|
||||
columns={[
|
||||
"Address", "Name", "Following", "Sharing"
|
||||
{
|
||||
name: "Id",
|
||||
options: {
|
||||
display: false,
|
||||
}
|
||||
},
|
||||
"Name", "Address", "Following", "Sharing"
|
||||
]}
|
||||
options={{
|
||||
filter: false,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import TimelineDot from '@material-ui/lab/TimelineDot';
|
|||
import FaceIcon from '@material-ui/icons/Face';
|
||||
|
||||
import {
|
||||
getSqueakProfileRequest,
|
||||
getSqueakProfileByAddressRequest,
|
||||
getAddressSqueakDisplaysRequest,
|
||||
getNetworkRequest,
|
||||
} from "../../squeakclient/requests"
|
||||
|
|
@ -48,7 +48,7 @@ export default function SqueakAddressPage() {
|
|||
const [network, setNetwork] = useState("");
|
||||
|
||||
const getSqueakProfile = (address) => {
|
||||
getSqueakProfileRequest(address, setSqueakProfile);
|
||||
getSqueakProfileByAddressRequest(address, setSqueakProfile);
|
||||
};
|
||||
const getSqueaks = (address) => {
|
||||
getAddressSqueakDisplaysRequest(address, setSqueaks);
|
||||
|
|
@ -91,7 +91,7 @@ export default function SqueakAddressPage() {
|
|||
<div className={classes.root}>
|
||||
Profile:
|
||||
<Button variant="contained" onClick={() => {
|
||||
goToProfilePage(history, squeakProfile.getAddress());
|
||||
goToProfilePage(history, squeakProfile.getProfileId());
|
||||
}}>{squeakProfile.getProfileName()}</Button>
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import {
|
|||
GetSqueakDisplayRequest,
|
||||
GetAncestorSqueakDisplaysRequest,
|
||||
GetReplySqueakDisplaysRequest,
|
||||
GetSqueakProfileByAddressRequest,
|
||||
GetAddressSqueakDisplaysRequest,
|
||||
CreateContactProfileRequest,
|
||||
CreateSigningProfileRequest,
|
||||
|
|
@ -68,6 +69,7 @@ import {
|
|||
GetSqueakDisplayReply,
|
||||
GetAncestorSqueakDisplaysReply,
|
||||
GetReplySqueakDisplaysReply,
|
||||
GetSqueakProfileByAddressReply,
|
||||
GetAddressSqueakDisplaysReply,
|
||||
CreateContactProfileReply,
|
||||
CreateSigningProfileReply,
|
||||
|
|
@ -236,9 +238,9 @@ export function lndPendingChannelsRequest(handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function getSqueakProfileRequest(address, handleResponse) {
|
||||
export function getSqueakProfileRequest(id, handleResponse) {
|
||||
var request = new GetSqueakProfileRequest();
|
||||
request.setAddress(address);
|
||||
request.setProfileId(id);
|
||||
makeRequest(
|
||||
'getsqueakprofile',
|
||||
request,
|
||||
|
|
@ -249,9 +251,9 @@ export function getSqueakProfileRequest(address, handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function setSqueakProfileFollowingRequest(squeakAddress, following, handleResponse) {
|
||||
export function setSqueakProfileFollowingRequest(id, following, handleResponse) {
|
||||
var request = new SetSqueakProfileFollowingRequest();
|
||||
request.setAddress(squeakAddress);
|
||||
request.setProfileId(id);
|
||||
request.setFollowing(following);
|
||||
makeRequest(
|
||||
'setsqueakprofilefollowing',
|
||||
|
|
@ -261,9 +263,9 @@ export function setSqueakProfileFollowingRequest(squeakAddress, following, handl
|
|||
);
|
||||
}
|
||||
|
||||
export function setSqueakProfileSharingRequest(squeakAddress, sharing, handleResponse) {
|
||||
export function setSqueakProfileSharingRequest(id, sharing, handleResponse) {
|
||||
var request = new SetSqueakProfileSharingRequest();
|
||||
request.setAddress(squeakAddress);
|
||||
request.setProfileId(id);
|
||||
request.setSharing(sharing);
|
||||
makeRequest(
|
||||
'setsqueakprofilesharing',
|
||||
|
|
@ -273,9 +275,9 @@ export function setSqueakProfileSharingRequest(squeakAddress, sharing, handleRes
|
|||
);
|
||||
}
|
||||
|
||||
export function renameSqueakProfileRequest(squeakAddress, profileName, handleResponse) {
|
||||
export function renameSqueakProfileRequest(id, profileName, handleResponse) {
|
||||
var request = new RenameSqueakProfileRequest();
|
||||
request.setAddress(squeakAddress);
|
||||
request.setProfileId(id);
|
||||
request.setProfileName(profileName);
|
||||
makeRequest(
|
||||
'renamesqueakprofile',
|
||||
|
|
@ -285,9 +287,9 @@ export function renameSqueakProfileRequest(squeakAddress, profileName, handleRes
|
|||
);
|
||||
}
|
||||
|
||||
export function setSqueakProfileImageRequest(squeakAddress, profileImage, handleResponse) {
|
||||
export function setSqueakProfileImageRequest(id, profileImage, handleResponse) {
|
||||
var request = new SetSqueakProfileImageRequest();
|
||||
request.setAddress(squeakAddress);
|
||||
request.setProfileId(id);
|
||||
request.setProfileImage(profileImage);
|
||||
makeRequest(
|
||||
'setsqueakprofileimage',
|
||||
|
|
@ -297,9 +299,9 @@ export function setSqueakProfileImageRequest(squeakAddress, profileImage, handle
|
|||
);
|
||||
}
|
||||
|
||||
export function clearSqueakProfileImageRequest(squeakAddress, handleResponse) {
|
||||
export function clearSqueakProfileImageRequest(id, handleResponse) {
|
||||
var request = new ClearSqueakProfileImageRequest();
|
||||
request.setAddress(squeakAddress);
|
||||
request.setProfileId(id);
|
||||
makeRequest(
|
||||
'clearsqueakprofileimage',
|
||||
request,
|
||||
|
|
@ -412,9 +414,9 @@ export function getBuyOfferRequest(offerId, handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function getPeerRequest(peerHash, handleResponse) {
|
||||
export function getPeerRequest(id, handleResponse) {
|
||||
var request = new GetPeerRequest();
|
||||
request.setPeerHash(peerHash);
|
||||
request.setPeerId(id);
|
||||
makeRequest(
|
||||
'getpeer',
|
||||
request,
|
||||
|
|
@ -425,9 +427,9 @@ export function getPeerRequest(peerHash, handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function setPeerDownloadingRequest(peerHash, downloading, handleResponse) {
|
||||
export function setPeerDownloadingRequest(id, downloading, handleResponse) {
|
||||
var request = new SetPeerDownloadingRequest();
|
||||
request.setPeerHash(peerHash);
|
||||
request.setPeerId(id);
|
||||
request.setDownloading(downloading);
|
||||
makeRequest(
|
||||
'setpeerdownloading',
|
||||
|
|
@ -437,9 +439,9 @@ export function setPeerDownloadingRequest(peerHash, downloading, handleResponse)
|
|||
);
|
||||
}
|
||||
|
||||
export function setPeerUploadingRequest(peerHash, uploading, handleResponse) {
|
||||
export function setPeerUploadingRequest(id, uploading, handleResponse) {
|
||||
var request = new SetPeerUploadingRequest();
|
||||
request.setPeerHash(peerHash);
|
||||
request.setPeerId(id);
|
||||
request.setUploading(uploading);
|
||||
makeRequest(
|
||||
'setpeeruploading',
|
||||
|
|
@ -473,9 +475,9 @@ export function getContactProfilesRequest(handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function makeSqueakRequest(squeakAddress, content, replyto, handleResponse, handleErr) {
|
||||
export function makeSqueakRequest(profileId, content, replyto, handleResponse, handleErr) {
|
||||
var request = new MakeSqueakRequest();
|
||||
request.setAddress(squeakAddress);
|
||||
request.setProfileId(profileId);
|
||||
request.setContent(content);
|
||||
request.setReplyto(replyto);
|
||||
makeRequest(
|
||||
|
|
@ -526,6 +528,19 @@ export function getReplySqueakDisplaysRequest(hash, handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function getSqueakProfileByAddressRequest(address, handleResponse) {
|
||||
var request = new GetSqueakProfileByAddressRequest();
|
||||
request.setAddress(address);
|
||||
makeRequest(
|
||||
'getsqueakprofilebyaddress',
|
||||
request,
|
||||
GetSqueakProfileByAddressReply.deserializeBinary,
|
||||
(response) => {
|
||||
handleResponse(response.getSqueakProfile());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function getAddressSqueakDisplaysRequest(address, handleResponse) {
|
||||
var request = new GetAddressSqueakDisplaysRequest();
|
||||
request.setAddress(address);
|
||||
|
|
@ -590,9 +605,9 @@ export function createPeerRequest(peerName, host, port, handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function deletePeerRequest(peerHash, handleResponse) {
|
||||
export function deletePeerRequest(peerId, handleResponse) {
|
||||
var request = new DeletePeerRequest();
|
||||
request.setPeerHash(peerHash);
|
||||
request.setPeerId(peerId);
|
||||
makeRequest(
|
||||
'deletepeer',
|
||||
request,
|
||||
|
|
@ -601,9 +616,9 @@ export function deletePeerRequest(peerHash, handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function deleteProfileRequest(squeakAddress, handleResponse) {
|
||||
export function deleteProfileRequest(profileId, handleResponse) {
|
||||
var request = new DeleteSqueakProfileRequest();
|
||||
request.setAddress(squeakAddress);
|
||||
request.setProfileId(profileId);
|
||||
makeRequest(
|
||||
'deleteprofile',
|
||||
request,
|
||||
|
|
@ -717,9 +732,9 @@ export function getNetworkRequest(handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function getSqueakProfilePrivateKey(squeakAddress, handleResponse) {
|
||||
export function getSqueakProfilePrivateKey(id, handleResponse) {
|
||||
var request = new GetSqueakProfilePrivateKeyRequest();
|
||||
request.setAddress(squeakAddress);
|
||||
request.setProfileId(id);
|
||||
makeRequest(
|
||||
'getsqueakprofileprivatekey',
|
||||
request,
|
||||
|
|
|
|||
|
|
@ -63,12 +63,12 @@ def following_signing_key(server_stub, admin_stub):
|
|||
address=profile_address,
|
||||
)
|
||||
)
|
||||
contact_profile_address = create_contact_profile_response.address
|
||||
contact_profile_id = create_contact_profile_response.profile_id
|
||||
|
||||
# Set the profile to be following
|
||||
admin_stub.SetSqueakProfileFollowing(
|
||||
squeak_admin_pb2.SetSqueakProfileFollowingRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
following=True,
|
||||
)
|
||||
)
|
||||
|
|
@ -87,7 +87,7 @@ def nonfollowing_signing_key(server_stub, admin_stub):
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def signing_profile_address(server_stub, admin_stub):
|
||||
def signing_profile_id(server_stub, admin_stub):
|
||||
# Create a new signing profile
|
||||
profile_name = "fake_signing_profile_{}".format(uuid.uuid1())
|
||||
create_signing_profile_response = admin_stub.CreateSigningProfile(
|
||||
|
|
@ -95,12 +95,12 @@ def signing_profile_address(server_stub, admin_stub):
|
|||
profile_name=profile_name,
|
||||
)
|
||||
)
|
||||
profile_address = create_signing_profile_response.address
|
||||
yield profile_address
|
||||
profile_id = create_signing_profile_response.profile_id
|
||||
yield profile_id
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def contact_profile_address(server_stub, admin_stub):
|
||||
def contact_profile_id(server_stub, admin_stub):
|
||||
# Create a new contact profile
|
||||
contact_name = "fake_contact_profile_{}".format(uuid.uuid1())
|
||||
contact_signing_key = generate_signing_key()
|
||||
|
|
@ -111,17 +111,17 @@ def contact_profile_address(server_stub, admin_stub):
|
|||
address=contact_address,
|
||||
)
|
||||
)
|
||||
contact_profile_address = create_contact_profile_response.address
|
||||
yield contact_profile_address
|
||||
contact_profile_id = create_contact_profile_response.profile_id
|
||||
yield contact_profile_id
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def saved_squeak_hash(server_stub, admin_stub, signing_profile_address):
|
||||
def saved_squeak_hash(server_stub, admin_stub, signing_profile_id):
|
||||
# Create a new squeak using the new profile
|
||||
make_squeak_content = "Hello from the profile on the server!"
|
||||
make_squeak_response = admin_stub.MakeSqueak(
|
||||
squeak_admin_pb2.MakeSqueakRequest(
|
||||
address=signing_profile_address,
|
||||
profile_id=signing_profile_id,
|
||||
content=make_squeak_content,
|
||||
)
|
||||
)
|
||||
|
|
@ -130,49 +130,17 @@ def saved_squeak_hash(server_stub, admin_stub, signing_profile_address):
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def random_peer_host():
|
||||
yield "random_host_name_{}".format(uuid.uuid1())
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def random_peer_hash(server_stub, admin_stub, random_peer_host):
|
||||
def peer_id(server_stub, admin_stub):
|
||||
# Create a new peer
|
||||
create_peer_response = admin_stub.CreatePeer(
|
||||
squeak_admin_pb2.CreatePeerRequest(
|
||||
peer_name=random_peer_host,
|
||||
host=random_peer_host,
|
||||
peer_name="fake_peer_name",
|
||||
host="fake_host",
|
||||
port=1234,
|
||||
)
|
||||
)
|
||||
peer_hash = create_peer_response.peer_hash
|
||||
yield peer_hash
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def connected_peer_hash(other_admin_stub, admin_stub):
|
||||
# Add the main node as a peer
|
||||
create_peer_response = other_admin_stub.CreatePeer(
|
||||
squeak_admin_pb2.CreatePeerRequest(
|
||||
peer_name="test_peer",
|
||||
host="squeaknode",
|
||||
port=8774,
|
||||
)
|
||||
)
|
||||
peer_hash = create_peer_response.peer_hash
|
||||
# Set the peer to be downloading
|
||||
other_admin_stub.SetPeerDownloading(
|
||||
squeak_admin_pb2.SetPeerDownloadingRequest(
|
||||
peer_hash=peer_hash,
|
||||
downloading=True,
|
||||
)
|
||||
)
|
||||
yield peer_hash
|
||||
# Delete the peer
|
||||
other_admin_stub.DeletePeer(
|
||||
squeak_admin_pb2.DeletePeerRequest(
|
||||
peer_hash=peer_hash,
|
||||
)
|
||||
)
|
||||
peer_id = create_peer_response.peer_id
|
||||
yield peer_id
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
|||
|
|
@ -33,19 +33,19 @@ def test_get_network(admin_stub):
|
|||
assert network == "simnet"
|
||||
|
||||
|
||||
def test_get_profile(server_stub, admin_stub, signing_profile_address):
|
||||
def test_get_profile(server_stub, admin_stub, signing_profile_id):
|
||||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=signing_profile_address,
|
||||
profile_id=signing_profile_id,
|
||||
)
|
||||
)
|
||||
address = get_squeak_profile_response.squeak_profile.address
|
||||
name = get_squeak_profile_response.squeak_profile.profile_name
|
||||
|
||||
# Get the same squeak profile by address
|
||||
get_squeak_profile_by_address_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
get_squeak_profile_by_address_response = admin_stub.GetSqueakProfileByAddress(
|
||||
squeak_admin_pb2.GetSqueakProfileByAddressRequest(
|
||||
address=address,
|
||||
)
|
||||
)
|
||||
|
|
@ -104,11 +104,11 @@ def test_post_squeak_not_following(
|
|||
squeak_server_pb2.UploadSqueakRequest(squeak=squeak_msg))
|
||||
|
||||
|
||||
def test_lookup_squeaks(server_stub, admin_stub, signing_profile_address, saved_squeak_hash):
|
||||
def test_lookup_squeaks(server_stub, admin_stub, signing_profile_id, saved_squeak_hash):
|
||||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=signing_profile_address,
|
||||
profile_id=signing_profile_id,
|
||||
)
|
||||
)
|
||||
squeak_profile_address = get_squeak_profile_response.squeak_profile.address
|
||||
|
|
@ -145,12 +145,12 @@ def test_lookup_squeaks_empty_result_addresses(server_stub, admin_stub):
|
|||
|
||||
|
||||
def test_lookup_squeaks_empty_result_block_ranges(
|
||||
server_stub, admin_stub, signing_profile_address
|
||||
server_stub, admin_stub, signing_profile_id
|
||||
):
|
||||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=signing_profile_address,
|
||||
profile_id=signing_profile_id,
|
||||
)
|
||||
)
|
||||
squeak_profile_address = get_squeak_profile_response.squeak_profile.address
|
||||
|
|
@ -168,11 +168,11 @@ def test_lookup_squeaks_empty_result_block_ranges(
|
|||
assert len(lookup_response.hashes) == 0
|
||||
|
||||
|
||||
def test_lookup_squeaks_to_upload(server_stub, admin_stub, signing_profile_address, saved_squeak_hash):
|
||||
def test_lookup_squeaks_to_upload(server_stub, admin_stub, signing_profile_id, saved_squeak_hash):
|
||||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=signing_profile_address,
|
||||
profile_id=signing_profile_id,
|
||||
)
|
||||
)
|
||||
squeak_profile_address = get_squeak_profile_response.squeak_profile.address
|
||||
|
|
@ -249,12 +249,12 @@ def test_sell_squeak(server_stub, admin_stub, lightning_client, saved_squeak_has
|
|||
assert final_server_balance - initial_server_balance == 1000
|
||||
|
||||
|
||||
def test_make_squeak(server_stub, admin_stub, signing_profile_address):
|
||||
def test_make_squeak(server_stub, admin_stub, signing_profile_id):
|
||||
# Create a new squeak using the new profile
|
||||
make_squeak_content = "Hello from the profile on the server!"
|
||||
make_squeak_response = admin_stub.MakeSqueak(
|
||||
squeak_admin_pb2.MakeSqueakRequest(
|
||||
address=signing_profile_address,
|
||||
profile_id=signing_profile_id,
|
||||
content=make_squeak_content,
|
||||
)
|
||||
)
|
||||
|
|
@ -289,7 +289,7 @@ def test_make_squeak(server_stub, admin_stub, signing_profile_address):
|
|||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=signing_profile_address,
|
||||
profile_id=signing_profile_id,
|
||||
)
|
||||
)
|
||||
squeak_profile_address = get_squeak_profile_response.squeak_profile.address
|
||||
|
|
@ -309,12 +309,12 @@ def test_make_squeak(server_stub, admin_stub, signing_profile_address):
|
|||
|
||||
|
||||
def test_make_reply_squeak(
|
||||
server_stub, admin_stub, saved_squeak_hash, signing_profile_address
|
||||
server_stub, admin_stub, saved_squeak_hash, signing_profile_id
|
||||
):
|
||||
# Make another squeak as a reply
|
||||
reply_1_squeak_response = admin_stub.MakeSqueak(
|
||||
squeak_admin_pb2.MakeSqueakRequest(
|
||||
address=signing_profile_address,
|
||||
profile_id=signing_profile_id,
|
||||
content="Reply #1",
|
||||
replyto=saved_squeak_hash,
|
||||
)
|
||||
|
|
@ -324,7 +324,7 @@ def test_make_reply_squeak(
|
|||
# Make a second squeak as a reply
|
||||
reply_2_squeak_response = admin_stub.MakeSqueak(
|
||||
squeak_admin_pb2.MakeSqueakRequest(
|
||||
address=signing_profile_address,
|
||||
profile_id=signing_profile_id,
|
||||
content="Reply #2",
|
||||
replyto=reply_1_squeak_hash,
|
||||
)
|
||||
|
|
@ -393,12 +393,12 @@ def test_make_signing_profile(server_stub, admin_stub):
|
|||
profile_name=profile_name,
|
||||
)
|
||||
)
|
||||
profile_address = create_signing_profile_response.address
|
||||
profile_id = create_signing_profile_response.profile_id
|
||||
|
||||
# Get the new squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=profile_address,
|
||||
profile_id=profile_id,
|
||||
)
|
||||
)
|
||||
assert get_squeak_profile_response.squeak_profile.profile_name == profile_name
|
||||
|
|
@ -415,8 +415,8 @@ def test_make_signing_profile(server_stub, admin_stub):
|
|||
assert profile_name in signing_profile_names
|
||||
|
||||
# Get squeak profile by address
|
||||
get_profile_by_address_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
get_profile_by_address_response = admin_stub.GetSqueakProfileByAddress(
|
||||
squeak_admin_pb2.GetSqueakProfileByAddressRequest(
|
||||
address=squeak_profile_address
|
||||
)
|
||||
)
|
||||
|
|
@ -425,13 +425,13 @@ def test_make_signing_profile(server_stub, admin_stub):
|
|||
# Export the private key, delete the profile, and re-import it.
|
||||
get_private_key_response = admin_stub.GetSqueakProfilePrivateKey(
|
||||
squeak_admin_pb2.GetSqueakProfilePrivateKeyRequest(
|
||||
address=profile_address,
|
||||
profile_id=profile_id,
|
||||
)
|
||||
)
|
||||
private_key = get_private_key_response.private_key
|
||||
admin_stub.DeleteSqueakProfile(
|
||||
squeak_admin_pb2.DeleteSqueakProfileRequest(
|
||||
address=profile_address,
|
||||
profile_id=profile_id,
|
||||
)
|
||||
)
|
||||
import_response = admin_stub.ImportSigningProfile(
|
||||
|
|
@ -440,12 +440,12 @@ def test_make_signing_profile(server_stub, admin_stub):
|
|||
private_key=private_key,
|
||||
)
|
||||
)
|
||||
new_profile_address = import_response.address
|
||||
new_profile_id = import_response.profile_id
|
||||
|
||||
# Get the new imported profile
|
||||
get_imported_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=new_profile_address,
|
||||
profile_id=new_profile_id,
|
||||
)
|
||||
)
|
||||
assert get_imported_squeak_profile_response.squeak_profile.profile_name == "imported_profile_name"
|
||||
|
|
@ -463,7 +463,7 @@ def test_make_contact_profile(server_stub, admin_stub):
|
|||
address=contact_address,
|
||||
)
|
||||
)
|
||||
contact_profile_address = create_contact_profile_response.address
|
||||
contact_profile_id = create_contact_profile_response.profile_id
|
||||
|
||||
# Get all contact profiles
|
||||
get_contact_profiles_response = admin_stub.GetContactProfiles(
|
||||
|
|
@ -473,12 +473,12 @@ def test_make_contact_profile(server_stub, admin_stub):
|
|||
profile.profile_name
|
||||
for profile in get_contact_profiles_response.squeak_profiles
|
||||
]
|
||||
contact_profile_addresss = [
|
||||
profile.address
|
||||
contact_profile_ids = [
|
||||
profile.profile_id
|
||||
for profile in get_contact_profiles_response.squeak_profiles
|
||||
]
|
||||
assert contact_name in contact_profile_names
|
||||
assert contact_profile_address in contact_profile_addresss
|
||||
assert contact_profile_id in contact_profile_ids
|
||||
|
||||
|
||||
def test_make_signing_profile_empty_name(server_stub, admin_stub):
|
||||
|
|
@ -506,11 +506,11 @@ def test_make_contact_profile_empty_name(server_stub, admin_stub):
|
|||
assert "Profile name cannot be empty." in str(excinfo.value)
|
||||
|
||||
|
||||
def test_set_profile_following(server_stub, admin_stub, contact_profile_address):
|
||||
def test_set_profile_following(server_stub, admin_stub, contact_profile_id):
|
||||
# Set the profile to be following
|
||||
admin_stub.SetSqueakProfileFollowing(
|
||||
squeak_admin_pb2.SetSqueakProfileFollowingRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
following=True,
|
||||
)
|
||||
)
|
||||
|
|
@ -518,7 +518,7 @@ def test_set_profile_following(server_stub, admin_stub, contact_profile_address)
|
|||
# Get the squeak profile again
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
)
|
||||
)
|
||||
assert get_squeak_profile_response.squeak_profile.following
|
||||
|
|
@ -526,7 +526,7 @@ def test_set_profile_following(server_stub, admin_stub, contact_profile_address)
|
|||
# Set the profile to be not following
|
||||
admin_stub.SetSqueakProfileFollowing(
|
||||
squeak_admin_pb2.SetSqueakProfileFollowingRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
following=False,
|
||||
)
|
||||
)
|
||||
|
|
@ -534,17 +534,17 @@ def test_set_profile_following(server_stub, admin_stub, contact_profile_address)
|
|||
# Get the squeak profile again
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
)
|
||||
)
|
||||
assert not get_squeak_profile_response.squeak_profile.following
|
||||
|
||||
|
||||
def test_set_profile_sharing(server_stub, admin_stub, contact_profile_address):
|
||||
def test_set_profile_sharing(server_stub, admin_stub, contact_profile_id):
|
||||
# Set the profile to be sharing
|
||||
admin_stub.SetSqueakProfileSharing(
|
||||
squeak_admin_pb2.SetSqueakProfileSharingRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
sharing=True,
|
||||
)
|
||||
)
|
||||
|
|
@ -552,7 +552,7 @@ def test_set_profile_sharing(server_stub, admin_stub, contact_profile_address):
|
|||
# Get the squeak profile again
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
)
|
||||
)
|
||||
assert get_squeak_profile_response.squeak_profile.sharing
|
||||
|
|
@ -560,7 +560,7 @@ def test_set_profile_sharing(server_stub, admin_stub, contact_profile_address):
|
|||
# Set the profile to be not sharing
|
||||
admin_stub.SetSqueakProfileSharing(
|
||||
squeak_admin_pb2.SetSqueakProfileSharingRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
sharing=False,
|
||||
)
|
||||
)
|
||||
|
|
@ -568,17 +568,17 @@ def test_set_profile_sharing(server_stub, admin_stub, contact_profile_address):
|
|||
# Get the squeak profile again
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
)
|
||||
)
|
||||
assert not get_squeak_profile_response.squeak_profile.sharing
|
||||
|
||||
|
||||
def test_rename_profile(server_stub, admin_stub, contact_profile_address, random_name):
|
||||
def test_rename_profile(server_stub, admin_stub, contact_profile_id, random_name):
|
||||
# Rename the profile to something new
|
||||
admin_stub.RenameSqueakProfile(
|
||||
squeak_admin_pb2.RenameSqueakProfileRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
profile_name=random_name,
|
||||
)
|
||||
)
|
||||
|
|
@ -586,19 +586,19 @@ def test_rename_profile(server_stub, admin_stub, contact_profile_address, random
|
|||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
)
|
||||
)
|
||||
assert get_squeak_profile_response.squeak_profile.profile_name == random_name
|
||||
|
||||
|
||||
def test_set_profile_image(server_stub, admin_stub, contact_profile_address, random_image, random_image_base64_string):
|
||||
def test_set_profile_image(server_stub, admin_stub, contact_profile_id, random_image, random_image_base64_string):
|
||||
print("random_image: {}".format(random_image))
|
||||
print("random_image_base64_string: {}".format(random_image_base64_string))
|
||||
# Set the profile image to something new
|
||||
admin_stub.SetSqueakProfileImage(
|
||||
squeak_admin_pb2.SetSqueakProfileImageRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
profile_image=random_image_base64_string,
|
||||
)
|
||||
)
|
||||
|
|
@ -606,7 +606,7 @@ def test_set_profile_image(server_stub, admin_stub, contact_profile_address, ran
|
|||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
)
|
||||
)
|
||||
print("get_squeak_profile_response.squeak_profile.profile_image: {}".format(
|
||||
|
|
@ -618,14 +618,14 @@ def test_set_profile_image(server_stub, admin_stub, contact_profile_address, ran
|
|||
# Clear the profile image
|
||||
admin_stub.ClearSqueakProfileImage(
|
||||
squeak_admin_pb2.ClearSqueakProfileImageRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
)
|
||||
)
|
||||
|
||||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
)
|
||||
)
|
||||
print("get_squeak_profile_response.squeak_profile.profile_image: {}".format(
|
||||
|
|
@ -635,11 +635,11 @@ def test_set_profile_image(server_stub, admin_stub, contact_profile_address, ran
|
|||
assert not get_squeak_profile_response.squeak_profile.has_custom_profile_image
|
||||
|
||||
|
||||
def test_delete_profile(server_stub, admin_stub, contact_profile_address):
|
||||
def test_delete_profile(server_stub, admin_stub, contact_profile_id):
|
||||
# Delete the profile
|
||||
admin_stub.DeleteSqueakProfile(
|
||||
squeak_admin_pb2.DeleteSqueakProfileRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -647,17 +647,17 @@ def test_delete_profile(server_stub, admin_stub, contact_profile_address):
|
|||
with pytest.raises(Exception) as excinfo:
|
||||
admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
)
|
||||
)
|
||||
assert "Profile not found." in str(excinfo.value)
|
||||
|
||||
|
||||
def test_get_profile_private_key(server_stub, admin_stub, signing_profile_address):
|
||||
def test_get_profile_private_key(server_stub, admin_stub, signing_profile_id):
|
||||
# Get the private key
|
||||
private_key_response = admin_stub.GetSqueakProfilePrivateKey(
|
||||
squeak_admin_pb2.GetSqueakProfilePrivateKeyRequest(
|
||||
address=signing_profile_address,
|
||||
profile_id=signing_profile_id,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -666,12 +666,12 @@ def test_get_profile_private_key(server_stub, admin_stub, signing_profile_addres
|
|||
|
||||
|
||||
def test_get_following_squeaks(
|
||||
server_stub, admin_stub, saved_squeak_hash, signing_profile_address
|
||||
server_stub, admin_stub, saved_squeak_hash, signing_profile_id
|
||||
):
|
||||
# Set the profile to be following
|
||||
admin_stub.SetSqueakProfileFollowing(
|
||||
squeak_admin_pb2.SetSqueakProfileFollowingRequest(
|
||||
address=signing_profile_address,
|
||||
profile_id=signing_profile_id,
|
||||
following=True,
|
||||
)
|
||||
)
|
||||
|
|
@ -685,7 +685,7 @@ def test_get_following_squeaks(
|
|||
squeak_display_entry
|
||||
) in get_timeline_squeak_display_response.squeak_display_entries:
|
||||
# TODO: check the profile id of the squeak display entry
|
||||
# assert squeak_display_entry.address == signing_profile_address
|
||||
# assert squeak_display_entry.profile_id == signing_profile_id
|
||||
pass
|
||||
|
||||
|
||||
|
|
@ -713,12 +713,12 @@ def test_create_peer(server_stub, admin_stub):
|
|||
port=1234,
|
||||
)
|
||||
)
|
||||
peer_hash = create_peer_response.peer_hash
|
||||
peer_id = create_peer_response.peer_id
|
||||
|
||||
# Get the new peer
|
||||
get_peer_response = admin_stub.GetPeer(
|
||||
squeak_admin_pb2.GetPeerRequest(
|
||||
peer_hash=peer_hash,
|
||||
peer_id=peer_id,
|
||||
)
|
||||
)
|
||||
assert get_peer_response.squeak_peer.host == "fake_host"
|
||||
|
|
@ -745,11 +745,11 @@ def test_create_peer_empty_name(server_stub, admin_stub):
|
|||
assert "Peer name cannot be empty." in str(excinfo.value)
|
||||
|
||||
|
||||
def test_set_peer_downloading(server_stub, admin_stub, random_peer_hash):
|
||||
def test_set_peer_downloading(server_stub, admin_stub, peer_id):
|
||||
# Get the peer
|
||||
get_peer_response = admin_stub.GetPeer(
|
||||
squeak_admin_pb2.GetPeerRequest(
|
||||
peer_hash=random_peer_hash,
|
||||
peer_id=peer_id,
|
||||
)
|
||||
)
|
||||
assert not get_peer_response.squeak_peer.downloading
|
||||
|
|
@ -757,7 +757,7 @@ def test_set_peer_downloading(server_stub, admin_stub, random_peer_hash):
|
|||
# Set the peer to be downloading
|
||||
admin_stub.SetPeerDownloading(
|
||||
squeak_admin_pb2.SetPeerDownloadingRequest(
|
||||
peer_hash=random_peer_hash,
|
||||
peer_id=peer_id,
|
||||
downloading=True,
|
||||
)
|
||||
)
|
||||
|
|
@ -765,17 +765,17 @@ def test_set_peer_downloading(server_stub, admin_stub, random_peer_hash):
|
|||
# Get the peer again
|
||||
get_peer_response = admin_stub.GetPeer(
|
||||
squeak_admin_pb2.GetPeerRequest(
|
||||
peer_hash=random_peer_hash,
|
||||
peer_id=peer_id,
|
||||
)
|
||||
)
|
||||
assert get_peer_response.squeak_peer.downloading
|
||||
|
||||
|
||||
def test_set_peer_uploading(server_stub, admin_stub, random_peer_hash):
|
||||
def test_set_peer_uploading(server_stub, admin_stub, peer_id):
|
||||
# Get the peer
|
||||
get_peer_response = admin_stub.GetPeer(
|
||||
squeak_admin_pb2.GetPeerRequest(
|
||||
peer_hash=random_peer_hash,
|
||||
peer_id=peer_id,
|
||||
)
|
||||
)
|
||||
assert not get_peer_response.squeak_peer.uploading
|
||||
|
|
@ -783,7 +783,7 @@ def test_set_peer_uploading(server_stub, admin_stub, random_peer_hash):
|
|||
# Set the peer to be uploading
|
||||
admin_stub.SetPeerUploading(
|
||||
squeak_admin_pb2.SetPeerUploadingRequest(
|
||||
peer_hash=random_peer_hash,
|
||||
peer_id=peer_id,
|
||||
uploading=True,
|
||||
)
|
||||
)
|
||||
|
|
@ -791,17 +791,17 @@ def test_set_peer_uploading(server_stub, admin_stub, random_peer_hash):
|
|||
# Get the peer again
|
||||
get_peer_response = admin_stub.GetPeer(
|
||||
squeak_admin_pb2.GetPeerRequest(
|
||||
peer_hash=random_peer_hash,
|
||||
peer_id=peer_id,
|
||||
)
|
||||
)
|
||||
assert get_peer_response.squeak_peer.uploading
|
||||
|
||||
|
||||
def test_rename_peer(server_stub, admin_stub, random_peer_hash, random_name):
|
||||
def test_rename_peer(server_stub, admin_stub, peer_id, random_name):
|
||||
# Rename the peer
|
||||
admin_stub.RenamePeer(
|
||||
squeak_admin_pb2.RenamePeerRequest(
|
||||
peer_hash=random_peer_hash,
|
||||
peer_id=peer_id,
|
||||
peer_name=random_name,
|
||||
)
|
||||
)
|
||||
|
|
@ -809,17 +809,17 @@ def test_rename_peer(server_stub, admin_stub, random_peer_hash, random_name):
|
|||
# Get the peer again
|
||||
get_peer_response = admin_stub.GetPeer(
|
||||
squeak_admin_pb2.GetPeerRequest(
|
||||
peer_hash=random_peer_hash,
|
||||
peer_id=peer_id,
|
||||
)
|
||||
)
|
||||
assert get_peer_response.squeak_peer.peer_name == random_name
|
||||
|
||||
|
||||
def test_delete_peer(server_stub, admin_stub, random_peer_hash):
|
||||
def test_delete_peer(server_stub, admin_stub, peer_id):
|
||||
# Delete the peer
|
||||
admin_stub.DeletePeer(
|
||||
squeak_admin_pb2.DeletePeerRequest(
|
||||
peer_hash=random_peer_hash,
|
||||
peer_id=peer_id,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -827,7 +827,7 @@ def test_delete_peer(server_stub, admin_stub, random_peer_hash):
|
|||
with pytest.raises(Exception) as excinfo:
|
||||
admin_stub.GetPeer(
|
||||
squeak_admin_pb2.GetPeerRequest(
|
||||
peer_hash=random_peer_hash,
|
||||
peer_id=peer_id,
|
||||
)
|
||||
)
|
||||
assert "Peer not found." in str(excinfo.value)
|
||||
|
|
@ -1025,9 +1025,8 @@ def test_connect_other_node(
|
|||
admin_stub,
|
||||
other_server_stub,
|
||||
other_admin_stub,
|
||||
connected_peer_hash,
|
||||
lightning_client,
|
||||
signing_profile_address,
|
||||
signing_profile_id,
|
||||
saved_squeak_hash,
|
||||
):
|
||||
# Get all squeak displays
|
||||
|
|
@ -1036,10 +1035,28 @@ def test_connect_other_node(
|
|||
)
|
||||
assert len(get_timeline_squeak_display_response.squeak_display_entries) == 0
|
||||
|
||||
# Add the main node as a peer
|
||||
create_peer_response = other_admin_stub.CreatePeer(
|
||||
squeak_admin_pb2.CreatePeerRequest(
|
||||
peer_name="test_peer",
|
||||
host="squeaknode",
|
||||
port=8774,
|
||||
)
|
||||
)
|
||||
peer_id = create_peer_response.peer_id
|
||||
|
||||
# Set the peer to be downloading
|
||||
other_admin_stub.SetPeerDownloading(
|
||||
squeak_admin_pb2.SetPeerDownloadingRequest(
|
||||
peer_id=peer_id,
|
||||
downloading=True,
|
||||
)
|
||||
)
|
||||
|
||||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=signing_profile_address,
|
||||
profile_id=signing_profile_id,
|
||||
)
|
||||
)
|
||||
squeak_profile_address = get_squeak_profile_response.squeak_profile.address
|
||||
|
|
@ -1053,7 +1070,7 @@ def test_connect_other_node(
|
|||
# Set the signing profile to be sharing on the main server
|
||||
admin_stub.SetSqueakProfileSharing(
|
||||
squeak_admin_pb2.SetSqueakProfileSharingRequest(
|
||||
address=signing_profile_address,
|
||||
profile_id=signing_profile_id,
|
||||
sharing=True,
|
||||
)
|
||||
)
|
||||
|
|
@ -1065,10 +1082,10 @@ def test_connect_other_node(
|
|||
address=squeak_profile_address,
|
||||
)
|
||||
)
|
||||
contact_profile_address = create_contact_profile_response.address
|
||||
contact_profile_id = create_contact_profile_response.profile_id
|
||||
other_admin_stub.SetSqueakProfileFollowing(
|
||||
squeak_admin_pb2.SetSqueakProfileFollowingRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
following=True,
|
||||
)
|
||||
)
|
||||
|
|
@ -1079,7 +1096,7 @@ def test_connect_other_node(
|
|||
)
|
||||
time.sleep(5)
|
||||
# print(sync_squeaks_response)
|
||||
# assert peer_hash in sync_squeaks_response.sync_result.completed_peer_hashs
|
||||
# assert peer_id in sync_squeaks_response.sync_result.completed_peer_ids
|
||||
|
||||
# Get the sent offers from the seller node
|
||||
get_sent_offers_response = admin_stub.GetSentOffers(
|
||||
|
|
@ -1215,16 +1232,33 @@ def test_download_single_squeak(
|
|||
admin_stub,
|
||||
other_server_stub,
|
||||
other_admin_stub,
|
||||
connected_peer_hash,
|
||||
lightning_client,
|
||||
signing_profile_address,
|
||||
signing_profile_id,
|
||||
saved_squeak_hash,
|
||||
):
|
||||
|
||||
# Add the main node as a peer
|
||||
create_peer_response = other_admin_stub.CreatePeer(
|
||||
squeak_admin_pb2.CreatePeerRequest(
|
||||
peer_name="test_peer",
|
||||
host="squeaknode",
|
||||
port=8774,
|
||||
)
|
||||
)
|
||||
peer_id = create_peer_response.peer_id
|
||||
|
||||
# Set the peer to be downloading
|
||||
other_admin_stub.SetPeerDownloading(
|
||||
squeak_admin_pb2.SetPeerDownloadingRequest(
|
||||
peer_id=peer_id,
|
||||
downloading=True,
|
||||
)
|
||||
)
|
||||
|
||||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
address=signing_profile_address,
|
||||
profile_id=signing_profile_id,
|
||||
)
|
||||
)
|
||||
squeak_profile_address = get_squeak_profile_response.squeak_profile.address
|
||||
|
|
@ -1238,7 +1272,7 @@ def test_download_single_squeak(
|
|||
# Set the signing profile to be sharing on the main server
|
||||
admin_stub.SetSqueakProfileSharing(
|
||||
squeak_admin_pb2.SetSqueakProfileSharingRequest(
|
||||
address=signing_profile_address,
|
||||
profile_id=signing_profile_id,
|
||||
sharing=True,
|
||||
)
|
||||
)
|
||||
|
|
@ -1250,10 +1284,10 @@ def test_download_single_squeak(
|
|||
address=squeak_profile_address,
|
||||
)
|
||||
)
|
||||
contact_profile_address = create_contact_profile_response.address
|
||||
contact_profile_id = create_contact_profile_response.profile_id
|
||||
other_admin_stub.SetSqueakProfileFollowing(
|
||||
squeak_admin_pb2.SetSqueakProfileFollowingRequest(
|
||||
address=contact_profile_address,
|
||||
profile_id=contact_profile_id,
|
||||
following=True,
|
||||
)
|
||||
)
|
||||
|
|
@ -1282,7 +1316,7 @@ def test_download_single_squeak(
|
|||
)
|
||||
time.sleep(10)
|
||||
print(sync_squeak_response)
|
||||
# assert peer_hash in sync_squeak_response.sync_result.completed_peer_hashs
|
||||
# assert peer_id in sync_squeak_response.sync_result.completed_peer_ids
|
||||
|
||||
# Get the squeak display item
|
||||
get_squeak_display_response = other_admin_stub.GetSqueakDisplay(
|
||||
|
|
|
|||
|
|
@ -88,6 +88,10 @@ service SqueakAdmin {
|
|||
*/
|
||||
rpc GetSqueakProfile (GetSqueakProfileRequest) returns (GetSqueakProfileReply) {}
|
||||
|
||||
/** sqkadmin: `getsqueakprofilebyaddress`
|
||||
*/
|
||||
rpc GetSqueakProfileByAddress (GetSqueakProfileByAddressRequest) returns (GetSqueakProfileByAddressReply) {}
|
||||
|
||||
/** sqkadmin: `getsqueakprofilebyname`
|
||||
*/
|
||||
rpc GetSqueakProfileByName (GetSqueakProfileByNameRequest) returns (GetSqueakProfileByNameReply) {}
|
||||
|
|
@ -236,8 +240,8 @@ message CreateSigningProfileRequest {
|
|||
}
|
||||
|
||||
message CreateSigningProfileReply {
|
||||
/// The address
|
||||
string address = 1;
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
}
|
||||
|
||||
message ImportSigningProfileRequest {
|
||||
|
|
@ -249,8 +253,8 @@ message ImportSigningProfileRequest {
|
|||
}
|
||||
|
||||
message ImportSigningProfileReply {
|
||||
/// The address
|
||||
string address = 1;
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
}
|
||||
|
||||
message CreateContactProfileRequest {
|
||||
|
|
@ -262,8 +266,8 @@ message CreateContactProfileRequest {
|
|||
}
|
||||
|
||||
message CreateContactProfileReply {
|
||||
/// The address
|
||||
string address = 1;
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
}
|
||||
|
||||
message GetSigningProfilesRequest {
|
||||
|
|
@ -283,8 +287,8 @@ message GetContactProfilesReply {
|
|||
}
|
||||
|
||||
message GetSqueakProfileRequest {
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
}
|
||||
|
||||
message GetSqueakProfileReply {
|
||||
|
|
@ -292,6 +296,16 @@ message GetSqueakProfileReply {
|
|||
SqueakProfile squeak_profile = 1;
|
||||
}
|
||||
|
||||
message GetSqueakProfileByAddressRequest {
|
||||
/// The address
|
||||
string address = 1;
|
||||
}
|
||||
|
||||
message GetSqueakProfileByAddressReply {
|
||||
/// The squeak profile
|
||||
SqueakProfile squeak_profile = 1;
|
||||
}
|
||||
|
||||
message GetSqueakProfileByNameRequest {
|
||||
/// The name
|
||||
string name = 1;
|
||||
|
|
@ -303,8 +317,8 @@ message GetSqueakProfileByNameReply {
|
|||
}
|
||||
|
||||
message SetSqueakProfileFollowingRequest {
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
|
||||
/// Following
|
||||
bool following = 2;
|
||||
|
|
@ -314,8 +328,8 @@ message SetSqueakProfileFollowingReply {
|
|||
}
|
||||
|
||||
message SetSqueakProfileSharingRequest {
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
|
||||
/// Sharing
|
||||
bool sharing = 2;
|
||||
|
|
@ -325,8 +339,8 @@ message SetSqueakProfileSharingReply {
|
|||
}
|
||||
|
||||
message RenameSqueakProfileRequest {
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
|
||||
/// The new profile name
|
||||
string profile_name = 2;
|
||||
|
|
@ -336,8 +350,8 @@ message RenameSqueakProfileReply {
|
|||
}
|
||||
|
||||
message GetSqueakProfilePrivateKeyRequest {
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
}
|
||||
|
||||
message GetSqueakProfilePrivateKeyReply {
|
||||
|
|
@ -346,16 +360,16 @@ message GetSqueakProfilePrivateKeyReply {
|
|||
}
|
||||
|
||||
message DeleteSqueakProfileRequest {
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
}
|
||||
|
||||
message DeleteSqueakProfileReply {
|
||||
}
|
||||
|
||||
message SetSqueakProfileImageRequest {
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
|
||||
/// The profile image
|
||||
string profile_image = 2;
|
||||
|
|
@ -365,16 +379,16 @@ message SetSqueakProfileImageReply {
|
|||
}
|
||||
|
||||
message ClearSqueakProfileImageRequest {
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
}
|
||||
|
||||
message ClearSqueakProfileImageReply {
|
||||
}
|
||||
|
||||
message SqueakProfile {
|
||||
/// The address
|
||||
string address = 1;
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
|
||||
/// The profile name
|
||||
string profile_name = 2;
|
||||
|
|
@ -382,22 +396,25 @@ message SqueakProfile {
|
|||
/// Has private key
|
||||
bool has_private_key = 3;
|
||||
|
||||
/// The address
|
||||
string address = 4;
|
||||
|
||||
/// Sharing
|
||||
bool sharing = 4;
|
||||
bool sharing = 5;
|
||||
|
||||
/// Following
|
||||
bool following = 5;
|
||||
bool following = 6;
|
||||
|
||||
/// The profile image
|
||||
string profile_image = 6;
|
||||
string profile_image = 7;
|
||||
|
||||
/// Has custom profile image
|
||||
bool has_custom_profile_image = 7;
|
||||
bool has_custom_profile_image = 8;
|
||||
}
|
||||
|
||||
message MakeSqueakRequest {
|
||||
/// The profile address
|
||||
string address = 1;
|
||||
/// The profile id
|
||||
int32 profile_id = 1;
|
||||
|
||||
/// The content
|
||||
string content = 2;
|
||||
|
|
@ -514,13 +531,13 @@ message CreatePeerRequest {
|
|||
}
|
||||
|
||||
message CreatePeerReply {
|
||||
/// The peer hash
|
||||
string peer_hash = 1;
|
||||
/// The peer id
|
||||
int32 peer_id = 1;
|
||||
}
|
||||
|
||||
message GetPeerRequest {
|
||||
/// The peer hash
|
||||
string peer_hash = 1;
|
||||
/// The peer id
|
||||
int32 peer_id = 1;
|
||||
}
|
||||
|
||||
message GetPeerReply {
|
||||
|
|
@ -537,8 +554,8 @@ message GetPeersReply {
|
|||
}
|
||||
|
||||
message SqueakPeer {
|
||||
/// The peer hash
|
||||
string peer_hash = 1;
|
||||
/// The peer id
|
||||
int32 peer_id = 1;
|
||||
|
||||
/// The peer name
|
||||
string peer_name = 2;
|
||||
|
|
@ -557,8 +574,8 @@ message SqueakPeer {
|
|||
}
|
||||
|
||||
message SetPeerDownloadingRequest {
|
||||
/// The peer hash
|
||||
string peer_hash = 1;
|
||||
/// The peer id
|
||||
int32 peer_id = 1;
|
||||
|
||||
/// Downloading
|
||||
bool downloading = 2;
|
||||
|
|
@ -568,8 +585,8 @@ message SetPeerDownloadingReply {
|
|||
}
|
||||
|
||||
message SetPeerUploadingRequest {
|
||||
/// The peer hash
|
||||
string peer_hash = 1;
|
||||
/// The peer id
|
||||
int32 peer_id = 1;
|
||||
|
||||
/// Uploading
|
||||
bool uploading = 2;
|
||||
|
|
@ -579,8 +596,8 @@ message SetPeerUploadingReply {
|
|||
}
|
||||
|
||||
message RenamePeerRequest {
|
||||
/// The peer hash
|
||||
string peer_hash = 1;
|
||||
/// The peer id
|
||||
int32 peer_id = 1;
|
||||
|
||||
/// Name of the peer
|
||||
string peer_name = 2;
|
||||
|
|
@ -590,8 +607,8 @@ message RenamePeerReply {
|
|||
}
|
||||
|
||||
message DeletePeerRequest {
|
||||
/// The peer hash
|
||||
string peer_hash = 1;
|
||||
/// The peer id
|
||||
int32 peer_id = 1;
|
||||
}
|
||||
|
||||
message DeletePeerReply {
|
||||
|
|
@ -700,7 +717,7 @@ message SentPayment {
|
|||
/// Has peer
|
||||
bool has_peer = 2;
|
||||
|
||||
/// The peer hash
|
||||
/// The peer id
|
||||
SqueakPeer peer = 3;
|
||||
|
||||
/// The squeak hash
|
||||
|
|
|
|||
|
|
@ -52,14 +52,17 @@ def squeak_entry_to_message(squeak_entry_with_profile: SqueakEntryWithProfile) -
|
|||
|
||||
|
||||
def squeak_profile_to_message(squeak_profile: SqueakProfile) -> squeak_admin_pb2.SqueakProfile:
|
||||
if squeak_profile.profile_id is None:
|
||||
raise Exception("Profile id cannot be None.")
|
||||
has_private_key = squeak_profile.private_key is not None
|
||||
profile_image = squeak_profile.profile_image or DEFAULT_PROFILE_IMAGE
|
||||
has_custom_profile_image = squeak_profile.profile_image is not None
|
||||
image_base64_str = bytes_to_base64_string(profile_image)
|
||||
return squeak_admin_pb2.SqueakProfile(
|
||||
address=squeak_profile.address,
|
||||
profile_id=squeak_profile.profile_id,
|
||||
profile_name=squeak_profile.profile_name,
|
||||
has_private_key=has_private_key,
|
||||
address=squeak_profile.address,
|
||||
sharing=squeak_profile.sharing,
|
||||
following=squeak_profile.following,
|
||||
profile_image=image_base64_str,
|
||||
|
|
@ -68,8 +71,10 @@ def squeak_profile_to_message(squeak_profile: SqueakProfile) -> squeak_admin_pb2
|
|||
|
||||
|
||||
def squeak_peer_to_message(squeak_peer: SqueakPeer) -> squeak_admin_pb2.SqueakPeer:
|
||||
if squeak_peer.peer_id is None:
|
||||
raise Exception("Peer id cannot be None.")
|
||||
return squeak_admin_pb2.SqueakPeer(
|
||||
peer_hash=squeak_peer.peer_hash.hex(),
|
||||
peer_id=squeak_peer.peer_id,
|
||||
peer_name=squeak_peer.peer_name,
|
||||
host=squeak_peer.host,
|
||||
port=squeak_peer.port,
|
||||
|
|
|
|||
|
|
@ -88,11 +88,11 @@ class SqueakAdminServerHandler(object):
|
|||
profile_name = request.profile_name
|
||||
logger.info(
|
||||
"Handle create signing profile with name: {}".format(profile_name))
|
||||
address = self.squeak_controller.create_signing_profile(
|
||||
profile_id = self.squeak_controller.create_signing_profile(
|
||||
profile_name)
|
||||
logger.info("New profile address: {}".format(address))
|
||||
logger.info("New profile_id: {}".format(profile_id))
|
||||
return squeak_admin_pb2.CreateSigningProfileReply(
|
||||
address=address,
|
||||
profile_id=profile_id,
|
||||
)
|
||||
|
||||
def handle_import_signing_profile(self, request):
|
||||
|
|
@ -100,11 +100,11 @@ class SqueakAdminServerHandler(object):
|
|||
private_key = request.private_key
|
||||
logger.info(
|
||||
"Handle import signing profile with name: {}".format(profile_name))
|
||||
address = self.squeak_controller.import_signing_profile(
|
||||
profile_id = self.squeak_controller.import_signing_profile(
|
||||
profile_name, private_key)
|
||||
logger.info("New profile address: {}".format(address))
|
||||
logger.info("New profile_id: {}".format(profile_id))
|
||||
return squeak_admin_pb2.ImportSigningProfileReply(
|
||||
address=address,
|
||||
profile_id=profile_id,
|
||||
)
|
||||
|
||||
def handle_create_contact_profile(self, request):
|
||||
|
|
@ -116,12 +116,12 @@ class SqueakAdminServerHandler(object):
|
|||
squeak_address,
|
||||
)
|
||||
)
|
||||
address = self.squeak_controller.create_contact_profile(
|
||||
profile_id = self.squeak_controller.create_contact_profile(
|
||||
profile_name, squeak_address
|
||||
)
|
||||
logger.info("New profile address: {}".format(address))
|
||||
logger.info("New profile_id: {}".format(profile_id))
|
||||
return squeak_admin_pb2.CreateContactProfileReply(
|
||||
address=address,
|
||||
profile_id=profile_id,
|
||||
)
|
||||
|
||||
def handle_get_signing_profiles(self, request):
|
||||
|
|
@ -141,10 +141,9 @@ class SqueakAdminServerHandler(object):
|
|||
return squeak_admin_pb2.GetContactProfilesReply(squeak_profiles=profile_msgs)
|
||||
|
||||
def handle_get_squeak_profile(self, request):
|
||||
address = request.address
|
||||
logger.info(
|
||||
"Handle get squeak profile with address: {}".format(address))
|
||||
squeak_profile = self.squeak_controller.get_squeak_profile(address)
|
||||
profile_id = request.profile_id
|
||||
logger.info("Handle get squeak profile with id: {}".format(profile_id))
|
||||
squeak_profile = self.squeak_controller.get_squeak_profile(profile_id)
|
||||
if squeak_profile is None:
|
||||
raise Exception("Profile not found.")
|
||||
squeak_profile_msg = squeak_profile_to_message(squeak_profile)
|
||||
|
|
@ -152,6 +151,19 @@ class SqueakAdminServerHandler(object):
|
|||
squeak_profile=squeak_profile_msg,
|
||||
)
|
||||
|
||||
def handle_get_squeak_profile_by_address(self, request):
|
||||
address = request.address
|
||||
logger.info(
|
||||
"Handle get squeak profile with address: {}".format(address))
|
||||
squeak_profile = self.squeak_controller.get_squeak_profile_by_address(
|
||||
address)
|
||||
if squeak_profile is None:
|
||||
raise Exception("Profile not found.")
|
||||
squeak_profile_msg = squeak_profile_to_message(squeak_profile)
|
||||
return squeak_admin_pb2.GetSqueakProfileByAddressReply(
|
||||
squeak_profile=squeak_profile_msg
|
||||
)
|
||||
|
||||
def handle_get_squeak_profile_by_name(self, request):
|
||||
name = request.name
|
||||
logger.info("Handle get squeak profile with name: {}".format(name))
|
||||
|
|
@ -165,94 +177,93 @@ class SqueakAdminServerHandler(object):
|
|||
)
|
||||
|
||||
def handle_set_squeak_profile_following(self, request):
|
||||
address = request.address
|
||||
profile_id = request.profile_id
|
||||
following = request.following
|
||||
logger.info(
|
||||
"Handle set squeak profile following with profile id: {}, following: {}".format(
|
||||
address,
|
||||
profile_id,
|
||||
following,
|
||||
)
|
||||
)
|
||||
self.squeak_controller.set_squeak_profile_following(
|
||||
address, following)
|
||||
profile_id, following)
|
||||
return squeak_admin_pb2.SetSqueakProfileFollowingReply()
|
||||
|
||||
def handle_set_squeak_profile_sharing(self, request):
|
||||
address = request.address
|
||||
profile_id = request.profile_id
|
||||
sharing = request.sharing
|
||||
logger.info(
|
||||
"Handle set squeak profile sharing with profile id: {}, sharing: {}".format(
|
||||
address,
|
||||
profile_id,
|
||||
sharing,
|
||||
)
|
||||
)
|
||||
self.squeak_controller.set_squeak_profile_sharing(address, sharing)
|
||||
self.squeak_controller.set_squeak_profile_sharing(profile_id, sharing)
|
||||
return squeak_admin_pb2.SetSqueakProfileSharingReply()
|
||||
|
||||
def handle_rename_squeak_profile(self, request):
|
||||
address = request.address
|
||||
profile_id = request.profile_id
|
||||
profile_name = request.profile_name
|
||||
logger.info(
|
||||
"Handle rename squeak profile with profile id: {}, new name: {}".format(
|
||||
address,
|
||||
profile_id,
|
||||
profile_name,
|
||||
)
|
||||
)
|
||||
self.squeak_controller.rename_squeak_profile(address, profile_name)
|
||||
self.squeak_controller.rename_squeak_profile(profile_id, profile_name)
|
||||
return squeak_admin_pb2.RenameSqueakProfileReply()
|
||||
|
||||
def handle_delete_squeak_profile(self, request):
|
||||
address = request.address
|
||||
profile_id = request.profile_id
|
||||
logger.info(
|
||||
"Handle delete squeak profile with address: {}".format(address))
|
||||
self.squeak_controller.delete_squeak_profile(address)
|
||||
"Handle delete squeak profile with id: {}".format(profile_id))
|
||||
self.squeak_controller.delete_squeak_profile(profile_id)
|
||||
return squeak_admin_pb2.DeleteSqueakProfileReply()
|
||||
|
||||
def handle_set_squeak_profile_image(self, request):
|
||||
address = request.address
|
||||
profile_id = request.profile_id
|
||||
profile_image = request.profile_image
|
||||
logger.info(
|
||||
"Handle set squeak profile image with profile id: {}".format(
|
||||
address,
|
||||
profile_id,
|
||||
)
|
||||
)
|
||||
profile_image_bytes = base64_string_to_bytes(profile_image)
|
||||
self.squeak_controller.set_squeak_profile_image(
|
||||
address, profile_image_bytes)
|
||||
profile_id, profile_image_bytes)
|
||||
return squeak_admin_pb2.SetSqueakProfileImageReply()
|
||||
|
||||
def handle_clear_squeak_profile_image(self, request):
|
||||
address = request.address
|
||||
profile_id = request.profile_id
|
||||
logger.info(
|
||||
"Handle clear squeak profile image with profile id: {}".format(
|
||||
address,
|
||||
profile_id,
|
||||
)
|
||||
)
|
||||
self.squeak_controller.clear_squeak_profile_image(
|
||||
address,
|
||||
profile_id,
|
||||
)
|
||||
return squeak_admin_pb2.ClearSqueakProfileImageReply()
|
||||
|
||||
def handle_get_squeak_profile_private_key(self, request):
|
||||
address = request.address
|
||||
profile_id = request.profile_id
|
||||
logger.info(
|
||||
"Handle get squeak profile private key for id: {}".format(address))
|
||||
"Handle get squeak profile private key for id: {}".format(profile_id))
|
||||
private_key = self.squeak_controller.get_squeak_profile_private_key(
|
||||
address)
|
||||
profile_id)
|
||||
return squeak_admin_pb2.GetSqueakProfilePrivateKeyReply(
|
||||
private_key=private_key
|
||||
)
|
||||
|
||||
def handle_make_squeak(self, request):
|
||||
address = request.address
|
||||
profile_id = request.profile_id
|
||||
content_str = request.content
|
||||
replyto_hash_str = request.replyto
|
||||
replyto_hash = bytes.fromhex(
|
||||
replyto_hash_str) if replyto_hash_str else None
|
||||
logger.info(
|
||||
"Handle make squeak profile with address: {}".format(address))
|
||||
logger.info("Handle make squeak profile with id: {}".format(profile_id))
|
||||
inserted_squeak_hash = self.squeak_controller.make_squeak(
|
||||
address, content_str, replyto_hash
|
||||
profile_id, content_str, replyto_hash
|
||||
)
|
||||
return squeak_admin_pb2.MakeSqueakReply(
|
||||
squeak_hash=inserted_squeak_hash.hex(),
|
||||
|
|
@ -387,21 +398,19 @@ class SqueakAdminServerHandler(object):
|
|||
port,
|
||||
)
|
||||
)
|
||||
peer_hash = self.squeak_controller.create_peer(
|
||||
peer_id = self.squeak_controller.create_peer(
|
||||
peer_name,
|
||||
host,
|
||||
port,
|
||||
)
|
||||
return squeak_admin_pb2.CreatePeerReply(
|
||||
peer_hash=peer_hash.hex(),
|
||||
peer_id=peer_id,
|
||||
)
|
||||
|
||||
def handle_get_squeak_peer(self, request):
|
||||
peer_hash_str = request.peer_hash
|
||||
peer_hash = bytes.fromhex(peer_hash_str)
|
||||
logger.info(
|
||||
"Handle get squeak peer with hash: {}".format(peer_hash_str))
|
||||
squeak_peer = self.squeak_controller.get_peer(peer_hash)
|
||||
peer_id = request.peer_id
|
||||
logger.info("Handle get squeak peer with id: {}".format(peer_id))
|
||||
squeak_peer = self.squeak_controller.get_peer(peer_id)
|
||||
if squeak_peer is None:
|
||||
raise Exception("Peer not found.")
|
||||
squeak_peer_msg = squeak_peer_to_message(squeak_peer)
|
||||
|
|
@ -420,50 +429,45 @@ class SqueakAdminServerHandler(object):
|
|||
)
|
||||
|
||||
def handle_set_squeak_peer_downloading(self, request):
|
||||
peer_hash_str = request.peer_hash
|
||||
peer_hash = bytes.fromhex(peer_hash_str)
|
||||
peer_id = request.peer_id
|
||||
downloading = request.downloading
|
||||
logger.info(
|
||||
"Handle set peer downloading with peer id: {}, downloading: {}".format(
|
||||
peer_hash,
|
||||
peer_id,
|
||||
downloading,
|
||||
)
|
||||
)
|
||||
self.squeak_controller.set_peer_downloading(peer_hash, downloading)
|
||||
self.squeak_controller.set_peer_downloading(peer_id, downloading)
|
||||
return squeak_admin_pb2.SetPeerDownloadingReply()
|
||||
|
||||
def handle_rename_squeak_peer(self, request):
|
||||
peer_hash_str = request.peer_hash
|
||||
peer_hash = bytes.fromhex(peer_hash_str)
|
||||
peer_id = request.peer_id
|
||||
peer_name = request.peer_name
|
||||
logger.info(
|
||||
"Handle rename peer with peer id: {}, new name: {}".format(
|
||||
peer_hash_str,
|
||||
peer_id,
|
||||
peer_name,
|
||||
)
|
||||
)
|
||||
self.squeak_controller.rename_peer(peer_hash, peer_name)
|
||||
self.squeak_controller.rename_peer(peer_id, peer_name)
|
||||
return squeak_admin_pb2.RenamePeerReply()
|
||||
|
||||
def handle_set_squeak_peer_uploading(self, request):
|
||||
peer_hash_str = request.peer_hash
|
||||
peer_hash = bytes.fromhex(peer_hash_str)
|
||||
peer_id = request.peer_id
|
||||
uploading = request.uploading
|
||||
logger.info(
|
||||
"Handle set peer uploading with peer id: {}, uploading: {}".format(
|
||||
peer_hash,
|
||||
peer_id,
|
||||
uploading,
|
||||
)
|
||||
)
|
||||
self.squeak_controller.set_peer_uploading(peer_hash, uploading)
|
||||
self.squeak_controller.set_peer_uploading(peer_id, uploading)
|
||||
return squeak_admin_pb2.SetPeerUploadingReply()
|
||||
|
||||
def handle_delete_squeak_peer(self, request):
|
||||
peer_hash_str = request.peer_hash
|
||||
peer_hash = bytes.fromhex(peer_hash_str)
|
||||
logger.info(
|
||||
"Handle delete squeak peer with hash: {}".format(peer_hash_str))
|
||||
self.squeak_controller.delete_peer(peer_hash)
|
||||
peer_id = request.peer_id
|
||||
logger.info("Handle delete squeak peer with id: {}".format(peer_id))
|
||||
self.squeak_controller.delete_peer(peer_id)
|
||||
return squeak_admin_pb2.DeletePeerReply()
|
||||
|
||||
def handle_get_buy_offers(self, request):
|
||||
|
|
|
|||
|
|
@ -80,6 +80,9 @@ class SqueakAdminServerServicer(squeak_admin_pb2_grpc.SqueakAdminServicer):
|
|||
return squeak_admin_pb2.GetSqueakProfileReply()
|
||||
return reply
|
||||
|
||||
def GetSqueakProfileByAddress(self, request, context):
|
||||
return self.handler.handle_get_squeak_profile_by_address(request)
|
||||
|
||||
def GetSqueakProfileByName(self, request, context):
|
||||
return self.handler.handle_get_squeak_profile_by_name(request)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
{
|
||||
"files": {
|
||||
"main.js": "/static/js/main.7169983f.chunk.js",
|
||||
"main.js.map": "/static/js/main.7169983f.chunk.js.map",
|
||||
"main.js": "/static/js/main.74560df3.chunk.js",
|
||||
"main.js.map": "/static/js/main.74560df3.chunk.js.map",
|
||||
"runtime-main.js": "/static/js/runtime-main.9f0ba400.js",
|
||||
"runtime-main.js.map": "/static/js/runtime-main.9f0ba400.js.map",
|
||||
"static/css/2.15110fae.chunk.css": "/static/css/2.15110fae.chunk.css",
|
||||
"static/js/2.b63efdf4.chunk.js": "/static/js/2.b63efdf4.chunk.js",
|
||||
"static/js/2.b63efdf4.chunk.js.map": "/static/js/2.b63efdf4.chunk.js.map",
|
||||
"static/js/2.ee5e70e8.chunk.js": "/static/js/2.ee5e70e8.chunk.js",
|
||||
"static/js/2.ee5e70e8.chunk.js.map": "/static/js/2.ee5e70e8.chunk.js.map",
|
||||
"index.html": "/index.html",
|
||||
"precache-manifest.ebb4a51a3c77377da8475172e03f0f7c.js": "/precache-manifest.ebb4a51a3c77377da8475172e03f0f7c.js",
|
||||
"precache-manifest.72a3118e05450807c47caf4b92918296.js": "/precache-manifest.72a3118e05450807c47caf4b92918296.js",
|
||||
"service-worker.js": "/service-worker.js",
|
||||
"static/css/2.15110fae.chunk.css.map": "/static/css/2.15110fae.chunk.css.map",
|
||||
"static/js/2.b63efdf4.chunk.js.LICENSE.txt": "/static/js/2.b63efdf4.chunk.js.LICENSE.txt",
|
||||
"static/js/2.ee5e70e8.chunk.js.LICENSE.txt": "/static/js/2.ee5e70e8.chunk.js.LICENSE.txt",
|
||||
"static/media/font-awesome.min.css": "/static/media/fontawesome-webfont.fee66e71.woff",
|
||||
"static/media/google.svg": "/static/media/google.695a3160.svg",
|
||||
"static/media/logo.svg": "/static/media/logo.a0185b04.svg"
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
"entrypoints": [
|
||||
"static/js/runtime-main.9f0ba400.js",
|
||||
"static/css/2.15110fae.chunk.css",
|
||||
"static/js/2.b63efdf4.chunk.js",
|
||||
"static/js/main.7169983f.chunk.js"
|
||||
"static/js/2.ee5e70e8.chunk.js",
|
||||
"static/js/main.74560df3.chunk.js"
|
||||
]
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Squeak Node</title><meta name="description" content="Squeak Node is a frontend for accessing a squeak node"><meta name="keywords" content="squeak, bitcoin, lightning"><meta name="author" content="Flatlogic LLC."><link href="/static/css/2.15110fae.chunk.css" rel="stylesheet"></head><body style="font-family:Roboto,sans-serif"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,f,l=r[0],a=r[1],i=r[2],c=0,s=[];c<l.length;c++)f=l[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var a=t[l];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var l=this["webpackJsonpsqueak-node-frontend"]=this["webpackJsonpsqueak-node-frontend"]||[],a=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var p=a;t()}([])</script><script src="/static/js/2.b63efdf4.chunk.js"></script><script src="/static/js/main.7169983f.chunk.js"></script></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Squeak Node</title><meta name="description" content="Squeak Node is a frontend for accessing a squeak node"><meta name="keywords" content="squeak, bitcoin, lightning"><meta name="author" content="Flatlogic LLC."><link href="/static/css/2.15110fae.chunk.css" rel="stylesheet"></head><body style="font-family:Roboto,sans-serif"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,f,l=r[0],a=r[1],i=r[2],c=0,s=[];c<l.length;c++)f=l[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var a=t[l];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var l=this["webpackJsonpsqueak-node-frontend"]=this["webpackJsonpsqueak-node-frontend"]||[],a=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var p=a;t()}([])</script><script src="/static/js/2.ee5e70e8.chunk.js"></script><script src="/static/js/main.74560df3.chunk.js"></script></body></html>
|
||||
|
|
@ -1,23 +1,23 @@
|
|||
self.__precacheManifest = (self.__precacheManifest || []).concat([
|
||||
{
|
||||
"revision": "f2adce8dff71ef16ea1b25cd8c82ca7d",
|
||||
"revision": "4e358f2c6b161f761432c8a8bb6873fa",
|
||||
"url": "/index.html"
|
||||
},
|
||||
{
|
||||
"revision": "a10df19718592a5c7206",
|
||||
"revision": "3c94c4e3efa056791ec1",
|
||||
"url": "/static/css/2.15110fae.chunk.css"
|
||||
},
|
||||
{
|
||||
"revision": "a10df19718592a5c7206",
|
||||
"url": "/static/js/2.b63efdf4.chunk.js"
|
||||
"revision": "3c94c4e3efa056791ec1",
|
||||
"url": "/static/js/2.ee5e70e8.chunk.js"
|
||||
},
|
||||
{
|
||||
"revision": "7156b2c9571000777b9be03b3c6006ee",
|
||||
"url": "/static/js/2.b63efdf4.chunk.js.LICENSE.txt"
|
||||
"url": "/static/js/2.ee5e70e8.chunk.js.LICENSE.txt"
|
||||
},
|
||||
{
|
||||
"revision": "42109bfd7b1a31a4993e",
|
||||
"url": "/static/js/main.7169983f.chunk.js"
|
||||
"revision": "db4334b24ecdf72a3d02",
|
||||
"url": "/static/js/main.74560df3.chunk.js"
|
||||
},
|
||||
{
|
||||
"revision": "cc9816de5a8639d377ea",
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
|
||||
|
||||
importScripts(
|
||||
"/precache-manifest.ebb4a51a3c77377da8475172e03f0f7c.js"
|
||||
"/precache-manifest.72a3118e05450807c47caf4b92918296.js"
|
||||
);
|
||||
|
||||
self.addEventListener('message', (event) => {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -16,4 +16,4 @@ class ReceivedOffer(NamedTuple):
|
|||
destination: str
|
||||
node_host: str
|
||||
node_port: int
|
||||
peer_hash: bytes
|
||||
peer_id: int
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class SentPayment(NamedTuple):
|
|||
"""Represents a payment made by a buyer."""
|
||||
sent_payment_id: Optional[int]
|
||||
created: Optional[datetime]
|
||||
peer_hash: bytes
|
||||
peer_id: int
|
||||
squeak_hash: bytes
|
||||
payment_hash: bytes
|
||||
secret_key: bytes
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ from squeaknode.core.received_offer import ReceivedOffer
|
|||
from squeaknode.core.received_payment_summary import ReceivedPaymentSummary
|
||||
from squeaknode.core.sent_offer import SentOffer
|
||||
from squeaknode.core.sent_payment_summary import SentPaymentSummary
|
||||
from squeaknode.core.squeak_peer import make_squeak_peer
|
||||
from squeaknode.core.squeak_peer import SqueakPeer
|
||||
from squeaknode.core.squeak_profile import SqueakProfile
|
||||
from squeaknode.core.util import get_hash
|
||||
|
|
@ -131,6 +130,7 @@ class SqueakController:
|
|||
signing_key_str = str(signing_key)
|
||||
signing_key_bytes = signing_key_str.encode()
|
||||
squeak_profile = SqueakProfile(
|
||||
profile_id=None,
|
||||
profile_name=profile_name,
|
||||
private_key=signing_key_bytes,
|
||||
address=str(address),
|
||||
|
|
@ -147,6 +147,7 @@ class SqueakController:
|
|||
signing_key_str = str(signing_key)
|
||||
signing_key_bytes = signing_key_str.encode()
|
||||
squeak_profile = SqueakProfile(
|
||||
profile_id=None,
|
||||
profile_name=profile_name,
|
||||
private_key=signing_key_bytes,
|
||||
address=str(address),
|
||||
|
|
@ -168,6 +169,7 @@ class SqueakController:
|
|||
),
|
||||
)
|
||||
squeak_profile = SqueakProfile(
|
||||
profile_id=None,
|
||||
profile_name=profile_name,
|
||||
private_key=None,
|
||||
address=squeak_address,
|
||||
|
|
@ -183,41 +185,44 @@ class SqueakController:
|
|||
def get_contact_profiles(self):
|
||||
return self.squeak_db.get_contact_profiles()
|
||||
|
||||
def get_squeak_profile(self, address: str):
|
||||
return self.squeak_db.get_profile(address)
|
||||
def get_squeak_profile(self, profile_id: int):
|
||||
return self.squeak_db.get_profile(profile_id)
|
||||
|
||||
def get_squeak_profile_by_address(self, address: str):
|
||||
return self.squeak_db.get_profile_by_address(address)
|
||||
|
||||
def get_squeak_profile_by_name(self, name: str):
|
||||
return self.squeak_db.get_profile_by_name(name)
|
||||
|
||||
def set_squeak_profile_following(self, address: str, following: bool):
|
||||
self.squeak_db.set_profile_following(address, following)
|
||||
def set_squeak_profile_following(self, profile_id: int, following: bool):
|
||||
self.squeak_db.set_profile_following(profile_id, following)
|
||||
self.squeak_whitelist.refresh()
|
||||
|
||||
def set_squeak_profile_sharing(self, address: str, sharing: bool):
|
||||
self.squeak_db.set_profile_sharing(address, sharing)
|
||||
def set_squeak_profile_sharing(self, profile_id: int, sharing: bool):
|
||||
self.squeak_db.set_profile_sharing(profile_id, sharing)
|
||||
|
||||
def rename_squeak_profile(self, address: str, profile_name: str):
|
||||
self.squeak_db.set_profile_name(address, profile_name)
|
||||
def rename_squeak_profile(self, profile_id: int, profile_name: str):
|
||||
self.squeak_db.set_profile_name(profile_id, profile_name)
|
||||
|
||||
def delete_squeak_profile(self, address: str):
|
||||
self.squeak_db.delete_profile(address)
|
||||
def delete_squeak_profile(self, profile_id: int):
|
||||
self.squeak_db.delete_profile(profile_id)
|
||||
|
||||
def set_squeak_profile_image(self, address: str, profile_image: bytes):
|
||||
self.squeak_db.set_profile_image(address, profile_image)
|
||||
def set_squeak_profile_image(self, profile_id: int, profile_image: bytes):
|
||||
self.squeak_db.set_profile_image(profile_id, profile_image)
|
||||
|
||||
def clear_squeak_profile_image(self, address: str):
|
||||
self.squeak_db.set_profile_image(address, None)
|
||||
def clear_squeak_profile_image(self, profile_id: int):
|
||||
self.squeak_db.set_profile_image(profile_id, None)
|
||||
|
||||
def get_squeak_profile_private_key(self, address: str):
|
||||
profile = self.get_squeak_profile(address)
|
||||
def get_squeak_profile_private_key(self, profile_id: int):
|
||||
profile = self.get_squeak_profile(profile_id)
|
||||
if profile.private_key is None:
|
||||
raise Exception("Profile with address: {} does not have a private key.".format(
|
||||
address
|
||||
raise Exception("Profile with id: {} does not have a private key.".format(
|
||||
profile_id
|
||||
))
|
||||
return profile.private_key
|
||||
|
||||
def make_squeak(self, address: str, content_str: str, replyto_hash: bytes):
|
||||
squeak_profile = self.squeak_db.get_profile(address)
|
||||
def make_squeak(self, profile_id: int, content_str: str, replyto_hash: bytes):
|
||||
squeak_profile = self.squeak_db.get_profile(profile_id)
|
||||
squeak_entry = self.squeak_core.make_squeak(
|
||||
squeak_profile, content_str, replyto_hash)
|
||||
# return self.save_created_squeak(squeak_entry.squeak)
|
||||
|
|
@ -237,7 +242,8 @@ class SqueakController:
|
|||
"Peer name cannot be empty.",
|
||||
)
|
||||
port = port or self.config.core.default_peer_rpc_port
|
||||
squeak_peer = make_squeak_peer(
|
||||
squeak_peer = SqueakPeer(
|
||||
peer_id=None,
|
||||
peer_name=peer_name,
|
||||
host=host,
|
||||
port=port,
|
||||
|
|
@ -246,8 +252,8 @@ class SqueakController:
|
|||
)
|
||||
return self.squeak_db.insert_peer(squeak_peer)
|
||||
|
||||
def get_peer(self, peer_hash: bytes):
|
||||
return self.squeak_db.get_peer(peer_hash)
|
||||
def get_peer(self, peer_id: int):
|
||||
return self.squeak_db.get_peer(peer_id)
|
||||
|
||||
def get_peers(self):
|
||||
return self.squeak_db.get_peers()
|
||||
|
|
@ -258,17 +264,17 @@ class SqueakController:
|
|||
def get_uploading_peers(self):
|
||||
return self.squeak_db.get_uploading_peers()
|
||||
|
||||
def set_peer_downloading(self, peer_hash: bytes, downloading: bool):
|
||||
self.squeak_db.set_peer_downloading(peer_hash, downloading)
|
||||
def set_peer_downloading(self, peer_id: int, downloading: bool):
|
||||
self.squeak_db.set_peer_downloading(peer_id, downloading)
|
||||
|
||||
def set_peer_uploading(self, peer_hash: bytes, uploading: bool):
|
||||
self.squeak_db.set_peer_uploading(peer_hash, uploading)
|
||||
def set_peer_uploading(self, peer_id: int, uploading: bool):
|
||||
self.squeak_db.set_peer_uploading(peer_id, uploading)
|
||||
|
||||
def rename_peer(self, peer_hash: bytes, peer_name: str):
|
||||
self.squeak_db.set_peer_name(peer_hash, peer_name)
|
||||
def rename_peer(self, peer_id: int, peer_name: str):
|
||||
self.squeak_db.set_peer_name(peer_id, peer_name)
|
||||
|
||||
def delete_peer(self, peer_hash: bytes):
|
||||
self.squeak_db.delete_peer(peer_hash)
|
||||
def delete_peer(self, peer_id: int):
|
||||
self.squeak_db.delete_peer(peer_id)
|
||||
|
||||
def get_buy_offers_with_peer(self, squeak_hash: bytes):
|
||||
return self.squeak_db.get_offers_with_peer(squeak_hash)
|
||||
|
|
@ -422,12 +428,12 @@ class SqueakController:
|
|||
include_locked=True,
|
||||
)
|
||||
|
||||
def lookup_squeaks_needing_offer(self, addresses: List[str], min_block, max_block, peer_hash: bytes):
|
||||
def lookup_squeaks_needing_offer(self, addresses: List[str], min_block, max_block, peer_id):
|
||||
return self.squeak_db.lookup_squeaks_needing_offer(
|
||||
addresses,
|
||||
min_block,
|
||||
max_block,
|
||||
peer_hash,
|
||||
peer_id,
|
||||
)
|
||||
|
||||
def save_offer(self, received_offer: ReceivedOffer):
|
||||
|
|
|
|||
|
|
@ -186,6 +186,8 @@ class SqueakCore:
|
|||
Returns:
|
||||
ReceivedOffer: A record of the details of the offer for the buyer.
|
||||
"""
|
||||
if peer.peer_id is None:
|
||||
raise Exception("Peer must have a non-null peer_id.")
|
||||
# Get the squeak hash
|
||||
squeak_hash = get_hash(squeak)
|
||||
# TODO: check if squeak hash matches squeak_hash in buy_offer.
|
||||
|
|
@ -222,7 +224,7 @@ class SqueakCore:
|
|||
destination=destination,
|
||||
node_host=node_host,
|
||||
node_port=node_port,
|
||||
peer_hash=peer.peer_hash,
|
||||
peer_id=peer.peer_id,
|
||||
)
|
||||
|
||||
def pay_offer(self, received_offer: ReceivedOffer) -> SentPayment:
|
||||
|
|
@ -253,7 +255,7 @@ class SqueakCore:
|
|||
return SentPayment(
|
||||
sent_payment_id=None,
|
||||
created=None,
|
||||
peer_hash=received_offer.peer_hash,
|
||||
peer_id=received_offer.peer_id,
|
||||
squeak_hash=received_offer.squeak_hash,
|
||||
payment_hash=received_offer.payment_hash,
|
||||
secret_key=secret_key,
|
||||
|
|
|
|||
|
|
@ -1,30 +1,12 @@
|
|||
from typing import NamedTuple
|
||||
|
||||
from squeaknode.core.util import get_peer_hash
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class SqueakPeer(NamedTuple):
|
||||
"""Represents another node in the network."""
|
||||
peer_hash: bytes
|
||||
peer_id: Optional[int]
|
||||
peer_name: str
|
||||
host: str
|
||||
port: int
|
||||
uploading: bool
|
||||
downloading: bool
|
||||
|
||||
|
||||
def make_squeak_peer(
|
||||
peer_name: str,
|
||||
host: str,
|
||||
port: int,
|
||||
uploading: bool,
|
||||
downloading: bool,
|
||||
):
|
||||
return SqueakPeer(
|
||||
get_peer_hash(host, port),
|
||||
peer_name,
|
||||
host,
|
||||
port,
|
||||
uploading,
|
||||
downloading,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ from typing import Optional
|
|||
|
||||
class SqueakProfile(NamedTuple):
|
||||
"""Represents a user who can author squeaks."""
|
||||
address: str
|
||||
profile_id: Optional[int]
|
||||
profile_name: str
|
||||
private_key: Optional[bytes]
|
||||
address: str
|
||||
sharing: bool
|
||||
following: bool
|
||||
profile_image: Optional[bytes]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import os
|
||||
from hashlib import sha256
|
||||
|
||||
from bitcoin.base58 import Base58ChecksumError
|
||||
from bitcoin.wallet import CBitcoinAddressError
|
||||
|
|
@ -59,8 +58,3 @@ def is_address_valid(address: str) -> bool:
|
|||
except (Base58ChecksumError, CBitcoinAddressError):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def get_peer_hash(host: str, port: int) -> bytes:
|
||||
host_port_str = "{}:{}".format(host, port)
|
||||
return sha256(host_port_str.encode()).digest()
|
||||
|
|
|
|||
|
|
@ -1,87 +0,0 @@
|
|||
"""Use peer hash for peer primary key
|
||||
|
||||
Revision ID: 9eb4ba6da999
|
||||
Revises: d1cf733279c4
|
||||
Create Date: 2021-02-02 22:14:57.682676
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy import Integer
|
||||
from sqlalchemy import String
|
||||
from sqlalchemy.sql import column
|
||||
from sqlalchemy.sql import table
|
||||
|
||||
from squeaknode.core.util import get_peer_hash
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '9eb4ba6da999'
|
||||
down_revision = 'd1cf733279c4'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
|
||||
# Create the peer_hash column
|
||||
with op.batch_alter_table('peer', schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column('peer_hash', sa.String(length=64), nullable=False, server_default=''))
|
||||
with op.batch_alter_table('received_offer', schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column('peer_hash', sa.String(length=64), nullable=False, server_default=''))
|
||||
with op.batch_alter_table('sent_payment', schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column('peer_hash', sa.String(length=64), nullable=False, server_default=''))
|
||||
|
||||
peers = table(
|
||||
"peer",
|
||||
column("peer_hash", String(64)),
|
||||
column("server_host", String),
|
||||
column("server_port", Integer),
|
||||
)
|
||||
|
||||
# Set the peer_hash column in the peers table.
|
||||
op.execute(
|
||||
peers.update().
|
||||
values(
|
||||
peer_hash=get_peer_hash(
|
||||
peers.c.server_host,
|
||||
peers.c.server_port,
|
||||
).hex(),
|
||||
)
|
||||
)
|
||||
|
||||
# Delete peer_id and create the primary key on peer_hash
|
||||
with op.batch_alter_table('peer', schema=None) as batch_op:
|
||||
batch_op.drop_column('peer_id')
|
||||
batch_op.create_primary_key(
|
||||
"pk_peer", ["peer_hash"]
|
||||
)
|
||||
with op.batch_alter_table('received_offer', schema=None) as batch_op:
|
||||
batch_op.drop_column('peer_id')
|
||||
with op.batch_alter_table('sent_payment', schema=None) as batch_op:
|
||||
batch_op.drop_column('peer_id')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('peer', schema=None) as batch_op:
|
||||
batch_op.drop_constraint("pk_peer")
|
||||
batch_op.add_column(sa.Column('peer_id', sa.INTEGER(),
|
||||
nullable=False, server_default='0'))
|
||||
batch_op.drop_column('peer_hash')
|
||||
with op.batch_alter_table('received_offer', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('peer_id', sa.INTEGER(),
|
||||
nullable=False, server_default='0'))
|
||||
batch_op.drop_column('peer_hash')
|
||||
with op.batch_alter_table('sent_payment', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('peer_id', sa.INTEGER(),
|
||||
nullable=False, server_default='0'))
|
||||
batch_op.drop_column('peer_hash')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
"""Use address for profile primary key
|
||||
|
||||
Revision ID: d1cf733279c4
|
||||
Revises: 6851569c46e3
|
||||
Create Date: 2021-02-02 17:12:40.262077
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd1cf733279c4'
|
||||
down_revision = '6851569c46e3'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('profile', schema=None) as batch_op:
|
||||
batch_op.drop_column('profile_id')
|
||||
batch_op.create_primary_key(
|
||||
"pk_profile", ["address"]
|
||||
)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('profile', schema=None) as batch_op:
|
||||
batch_op.drop_constraint("pk_profile")
|
||||
batch_op.add_column(
|
||||
sa.Column('profile_id', sa.INTEGER(), nullable=False))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -58,11 +58,12 @@ class Models:
|
|||
self.profiles = Table(
|
||||
"profile",
|
||||
self.metadata,
|
||||
Column("address", String(35), primary_key=True),
|
||||
Column("profile_id", Integer, primary_key=True),
|
||||
Column("created", TZDateTime,
|
||||
server_default=func.now(), nullable=False),
|
||||
Column("profile_name", String, unique=True, nullable=False),
|
||||
Column("private_key", Binary),
|
||||
Column("address", String(35), unique=True, nullable=False),
|
||||
Column("sharing", Boolean, nullable=False),
|
||||
Column("following", Boolean, nullable=False),
|
||||
Column("profile_image", Binary, nullable=True),
|
||||
|
|
@ -71,7 +72,7 @@ class Models:
|
|||
self.peers = Table(
|
||||
"peer",
|
||||
self.metadata,
|
||||
Column("peer_hash", String(64), primary_key=True),
|
||||
Column("peer_id", Integer, primary_key=True),
|
||||
Column("created", TZDateTime,
|
||||
server_default=func.now(), nullable=False),
|
||||
Column("peer_name", String),
|
||||
|
|
@ -98,7 +99,7 @@ class Models:
|
|||
Column("destination", String(66), nullable=False),
|
||||
Column("node_host", String, nullable=False),
|
||||
Column("node_port", Integer, nullable=False),
|
||||
Column("peer_hash", String(64), nullable=False),
|
||||
Column("peer_id", Integer, nullable=False),
|
||||
)
|
||||
|
||||
self.sent_payments = Table(
|
||||
|
|
@ -107,7 +108,7 @@ class Models:
|
|||
Column("sent_payment_id", Integer, primary_key=True),
|
||||
Column("created", TZDateTime,
|
||||
server_default=func.now(), nullable=False),
|
||||
Column("peer_hash", String(64), nullable=False),
|
||||
Column("peer_id", Integer, nullable=False),
|
||||
Column("squeak_hash", String(64), nullable=False),
|
||||
Column("payment_hash", String(64), nullable=False),
|
||||
Column("secret_key", String(64), nullable=False),
|
||||
|
|
|
|||
|
|
@ -395,7 +395,7 @@ class SqueakDb:
|
|||
addresses: List[str],
|
||||
min_block: int,
|
||||
max_block: int,
|
||||
peer_hash: bytes,
|
||||
peer_id: int,
|
||||
include_unverified: bool = False
|
||||
) -> List[bytes]:
|
||||
""" Lookup squeaks that are locked and don't have an offer. """
|
||||
|
|
@ -409,7 +409,7 @@ class SqueakDb:
|
|||
self.received_offers,
|
||||
and_(
|
||||
self.received_offers.c.squeak_hash == self.squeaks.c.hash,
|
||||
self.received_offers.c.peer_hash == peer_hash.hex(),
|
||||
self.received_offers.c.peer_id == peer_id,
|
||||
),
|
||||
)
|
||||
)
|
||||
|
|
@ -435,7 +435,7 @@ class SqueakDb:
|
|||
# SELECT hash FROM squeak
|
||||
# LEFT JOIN offer
|
||||
# ON squeak.hash=offer.squeak_hash
|
||||
# AND offer.peer_hash=%s
|
||||
# AND offer.peer_id=%s
|
||||
# WHERE author_address IN %s
|
||||
# AND n_block_height >= %s
|
||||
# AND n_block_height <= %s
|
||||
|
|
@ -452,13 +452,13 @@ class SqueakDb:
|
|||
# # mogrify to debug.
|
||||
# # logger.info(curs.mogrify(sql, (addresses_tuple, min_block, max_block)))
|
||||
# curs.execute(
|
||||
# sql, (peer_hash, addresses_tuple, min_block, max_block, include_unverified)
|
||||
# sql, (peer_id, addresses_tuple, min_block, max_block, include_unverified)
|
||||
# )
|
||||
# rows = curs.fetchall()
|
||||
# hashes = [bytes.fromhex(row["hash"]) for row in rows]
|
||||
# return hashes
|
||||
|
||||
def insert_profile(self, squeak_profile: SqueakProfile) -> str:
|
||||
def insert_profile(self, squeak_profile: SqueakProfile) -> int:
|
||||
""" Insert a new squeak profile. """
|
||||
ins = self.profiles.insert().values(
|
||||
profile_name=squeak_profile.profile_name,
|
||||
|
|
@ -469,8 +469,8 @@ class SqueakDb:
|
|||
)
|
||||
with self.get_connection() as connection:
|
||||
res = connection.execute(ins)
|
||||
address = res.inserted_primary_key[0]
|
||||
return address
|
||||
profile_id = res.inserted_primary_key[0]
|
||||
return profile_id
|
||||
|
||||
def get_signing_profiles(self) -> List[SqueakProfile]:
|
||||
""" Get all signing profiles. """
|
||||
|
|
@ -541,7 +541,35 @@ class SqueakDb:
|
|||
profiles = [self._parse_squeak_profile(row) for row in rows]
|
||||
return profiles
|
||||
|
||||
def get_profile(self, address: str) -> Optional[SqueakProfile]:
|
||||
# sql = """
|
||||
# SELECT * FROM profile
|
||||
# WHERE sharing;
|
||||
# """
|
||||
# with self.get_cursor() as curs:
|
||||
# curs.execute(sql)
|
||||
# rows = curs.fetchall()
|
||||
# profiles = [self._parse_squeak_profile(row) for row in rows]
|
||||
# return profiles
|
||||
|
||||
def get_profile(self, profile_id: int) -> Optional[SqueakProfile]:
|
||||
""" Get a profile. """
|
||||
s = select([self.profiles]).where(
|
||||
self.profiles.c.profile_id == profile_id)
|
||||
with self.get_connection() as connection:
|
||||
result = connection.execute(s)
|
||||
row = result.fetchone()
|
||||
if row is None:
|
||||
return None
|
||||
return self._parse_squeak_profile(row)
|
||||
|
||||
# sql = """
|
||||
# SELECT * FROM profile WHERE profile_id=%s"""
|
||||
# with self.get_cursor() as curs:
|
||||
# curs.execute(sql, (profile_id,))
|
||||
# row = curs.fetchone()
|
||||
# return self._parse_squeak_profile(row)
|
||||
|
||||
def get_profile_by_address(self, address: str) -> Optional[SqueakProfile]:
|
||||
""" Get a profile by address. """
|
||||
s = select([self.profiles]).where(self.profiles.c.address == address)
|
||||
with self.get_connection() as connection:
|
||||
|
|
@ -570,49 +598,65 @@ class SqueakDb:
|
|||
return None
|
||||
return self._parse_squeak_profile(row)
|
||||
|
||||
def set_profile_following(self, address: str, following: bool):
|
||||
def set_profile_following(self, profile_id: int, following: bool):
|
||||
""" Set a profile is following. """
|
||||
stmt = (
|
||||
self.profiles.update()
|
||||
.where(self.profiles.c.address == address)
|
||||
.where(self.profiles.c.profile_id == profile_id)
|
||||
.values(following=following)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
connection.execute(stmt)
|
||||
|
||||
def set_profile_sharing(self, address: str, sharing: bool):
|
||||
# sql = """
|
||||
# UPDATE profile
|
||||
# SET following=%s
|
||||
# WHERE profile_id=%s;
|
||||
# """
|
||||
# with self.get_cursor() as curs:
|
||||
# curs.execute(sql, (following, profile_id,))
|
||||
|
||||
def set_profile_sharing(self, profile_id: int, sharing: bool):
|
||||
""" Set a profile is sharing. """
|
||||
stmt = (
|
||||
self.profiles.update()
|
||||
.where(self.profiles.c.address == address)
|
||||
.where(self.profiles.c.profile_id == profile_id)
|
||||
.values(sharing=sharing)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
connection.execute(stmt)
|
||||
|
||||
def set_profile_name(self, address: str, profile_name: str):
|
||||
# sql = """
|
||||
# UPDATE profile
|
||||
# SET sharing=%s
|
||||
# WHERE profile_id=%s;
|
||||
# """
|
||||
# with self.get_cursor() as curs:
|
||||
# curs.execute(sql, (sharing, profile_id,))
|
||||
|
||||
def set_profile_name(self, profile_id: int, profile_name: str):
|
||||
""" Set a profile name. """
|
||||
stmt = (
|
||||
self.profiles.update()
|
||||
.where(self.profiles.c.address == address)
|
||||
.where(self.profiles.c.profile_id == profile_id)
|
||||
.values(profile_name=profile_name)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
connection.execute(stmt)
|
||||
|
||||
def delete_profile(self, address: str):
|
||||
def delete_profile(self, profile_id: int):
|
||||
""" Delete a profile. """
|
||||
delete_profile_stmt = self.profiles.delete().where(
|
||||
self.profiles.c.address == address
|
||||
self.profiles.c.profile_id == profile_id
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
connection.execute(delete_profile_stmt)
|
||||
|
||||
def set_profile_image(self, address: str, profile_image: bytes):
|
||||
def set_profile_image(self, profile_id: int, profile_image: bytes):
|
||||
""" Set a profile image. """
|
||||
stmt = (
|
||||
self.profiles.update()
|
||||
.where(self.profiles.c.address == address)
|
||||
.where(self.profiles.c.profile_id == profile_id)
|
||||
.values(profile_image=profile_image)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
|
|
@ -683,10 +727,9 @@ class SqueakDb:
|
|||
# with self.get_cursor() as curs:
|
||||
# curs.execute(sql, (squeak_hash_str,))
|
||||
|
||||
def insert_peer(self, squeak_peer: SqueakPeer) -> bytes:
|
||||
def insert_peer(self, squeak_peer: SqueakPeer) -> int:
|
||||
""" Insert a new squeak peer. """
|
||||
ins = self.peers.insert().values(
|
||||
peer_hash=squeak_peer.peer_hash.hex(),
|
||||
peer_name=squeak_peer.peer_name,
|
||||
server_host=squeak_peer.host,
|
||||
server_port=squeak_peer.port,
|
||||
|
|
@ -695,14 +738,12 @@ class SqueakDb:
|
|||
)
|
||||
with self.get_connection() as connection:
|
||||
res = connection.execute(ins)
|
||||
peer_hash_str = res.inserted_primary_key[0]
|
||||
return bytes.fromhex(peer_hash_str)
|
||||
id = res.inserted_primary_key[0]
|
||||
return id
|
||||
|
||||
def get_peer(self, peer_hash: bytes) -> Optional[SqueakPeer]:
|
||||
def get_peer(self, peer_id: int) -> Optional[SqueakPeer]:
|
||||
""" Get a peer. """
|
||||
s = select([self.peers]).where(
|
||||
self.peers.c.peer_hash == peer_hash.hex()
|
||||
)
|
||||
s = select([self.peers]).where(self.peers.c.peer_id == peer_id)
|
||||
with self.get_connection() as connection:
|
||||
result = connection.execute(s)
|
||||
row = result.fetchone()
|
||||
|
|
@ -737,40 +778,39 @@ class SqueakDb:
|
|||
peers = [self._parse_squeak_peer(row) for row in rows]
|
||||
return peers
|
||||
|
||||
def set_peer_downloading(self, peer_hash: bytes, downloading: bool):
|
||||
def set_peer_downloading(self, peer_id: int, downloading: bool):
|
||||
""" Set a peer is downloading. """
|
||||
stmt = (
|
||||
self.peers.update()
|
||||
.where(self.peers.c.peer_hash == peer_hash.hex())
|
||||
.where(self.peers.c.peer_id == peer_id)
|
||||
.values(downloading=downloading)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
connection.execute(stmt)
|
||||
|
||||
def set_peer_uploading(self, peer_hash: bytes, uploading: bool):
|
||||
def set_peer_uploading(self, peer_id: int, uploading: bool):
|
||||
""" Set a peer is uploading. """
|
||||
stmt = (
|
||||
self.peers.update()
|
||||
.where(self.peers.c.peer_hash == peer_hash.hex())
|
||||
.where(self.peers.c.peer_id == peer_id)
|
||||
.values(uploading=uploading)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
connection.execute(stmt)
|
||||
|
||||
def set_peer_name(self, peer_hash: bytes, peer_name: str):
|
||||
def set_peer_name(self, peer_id: int, peer_name: str):
|
||||
""" Set a peer name. """
|
||||
stmt = (
|
||||
self.peers.update()
|
||||
.where(self.peers.c.peer_hash == peer_hash.hex())
|
||||
.where(self.peers.c.peer_id == peer_id)
|
||||
.values(peer_name=peer_name)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
connection.execute(stmt)
|
||||
|
||||
def delete_peer(self, peer_hash: bytes):
|
||||
def delete_peer(self, peer_id: int):
|
||||
""" Delete a peer. """
|
||||
delete_peer_stmt = self.peers.delete().where(
|
||||
self.peers.c.peer_hash == peer_hash.hex())
|
||||
delete_peer_stmt = self.peers.delete().where(self.peers.c.peer_id == peer_id)
|
||||
with self.get_connection() as connection:
|
||||
connection.execute(delete_peer_stmt)
|
||||
|
||||
|
|
@ -788,7 +828,7 @@ class SqueakDb:
|
|||
destination=received_offer.destination,
|
||||
node_host=received_offer.node_host,
|
||||
node_port=received_offer.node_port,
|
||||
peer_hash=received_offer.peer_hash.hex(),
|
||||
peer_id=received_offer.peer_id,
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
res = connection.execute(ins)
|
||||
|
|
@ -812,7 +852,7 @@ class SqueakDb:
|
|||
.select_from(
|
||||
self.received_offers.outerjoin(
|
||||
self.peers,
|
||||
self.peers.c.peer_hash == self.received_offers.c.peer_hash,
|
||||
self.peers.c.peer_id == self.received_offers.c.peer_id,
|
||||
)
|
||||
)
|
||||
.where(self.received_offers.c.squeak_hash == squeak_hash.hex())
|
||||
|
|
@ -831,7 +871,7 @@ class SqueakDb:
|
|||
.select_from(
|
||||
self.received_offers.outerjoin(
|
||||
self.peers,
|
||||
self.peers.c.peer_hash == self.received_offers.c.peer_hash,
|
||||
self.peers.c.peer_id == self.received_offers.c.peer_id,
|
||||
)
|
||||
)
|
||||
.where(self.received_offers.c.received_offer_id == received_offer_id)
|
||||
|
|
@ -885,7 +925,7 @@ class SqueakDb:
|
|||
def insert_sent_payment(self, sent_payment: SentPayment):
|
||||
""" Insert a new sent payment. """
|
||||
ins = self.sent_payments.insert().values(
|
||||
peer_hash=sent_payment.peer_hash.hex(),
|
||||
peer_id=sent_payment.peer_id,
|
||||
squeak_hash=sent_payment.squeak_hash.hex(),
|
||||
payment_hash=sent_payment.payment_hash.hex(),
|
||||
secret_key=sent_payment.secret_key.hex(),
|
||||
|
|
@ -905,7 +945,7 @@ class SqueakDb:
|
|||
.select_from(
|
||||
self.sent_payments.outerjoin(
|
||||
self.peers,
|
||||
self.peers.c.peer_hash == self.sent_payments.c.peer_hash,
|
||||
self.peers.c.peer_id == self.sent_payments.c.peer_id,
|
||||
)
|
||||
)
|
||||
.order_by(
|
||||
|
|
@ -926,7 +966,7 @@ class SqueakDb:
|
|||
.select_from(
|
||||
self.sent_payments.outerjoin(
|
||||
self.peers,
|
||||
self.peers.c.peer_hash == self.sent_payments.c.peer_hash,
|
||||
self.peers.c.peer_id == self.sent_payments.c.peer_id,
|
||||
)
|
||||
)
|
||||
.where(self.sent_payments.c.sent_payment_id == sent_payment_id)
|
||||
|
|
@ -1114,6 +1154,7 @@ class SqueakDb:
|
|||
private_key_column = row["private_key"]
|
||||
private_key = bytes(private_key_column) if private_key_column else None
|
||||
return SqueakProfile(
|
||||
profile_id=row["profile_id"],
|
||||
profile_name=row["profile_name"],
|
||||
private_key=private_key,
|
||||
address=row["address"],
|
||||
|
|
@ -1124,7 +1165,10 @@ class SqueakDb:
|
|||
|
||||
def _parse_squeak_entry_with_profile(self, row) -> SqueakEntryWithProfile:
|
||||
squeak_entry = self._parse_squeak_entry(row)
|
||||
squeak_profile = self._parse_squeak_profile(row)
|
||||
if row["profile_id"] is None:
|
||||
squeak_profile = None
|
||||
else:
|
||||
squeak_profile = self._parse_squeak_profile(row)
|
||||
return SqueakEntryWithProfile(
|
||||
squeak_entry=squeak_entry,
|
||||
squeak_profile=squeak_profile,
|
||||
|
|
@ -1132,7 +1176,7 @@ class SqueakDb:
|
|||
|
||||
def _parse_squeak_peer(self, row) -> SqueakPeer:
|
||||
return SqueakPeer(
|
||||
peer_hash=bytes.fromhex(row[self.peers.c.peer_hash]),
|
||||
peer_id=row[self.peers.c.peer_id],
|
||||
peer_name=row["peer_name"],
|
||||
host=row["server_host"],
|
||||
port=row["server_port"],
|
||||
|
|
@ -1154,12 +1198,12 @@ class SqueakDb:
|
|||
destination=row["destination"],
|
||||
node_host=row["node_host"],
|
||||
node_port=row["node_port"],
|
||||
peer_hash=bytes.fromhex(row[self.received_offers.c.peer_hash]),
|
||||
peer_id=row[self.peers.c.peer_id],
|
||||
)
|
||||
|
||||
def _parse_received_offer_with_peer(self, row) -> ReceivedOfferWithPeer:
|
||||
offer = self._parse_received_offer(row)
|
||||
if row[self.peers.c.peer_hash] is None:
|
||||
if row[self.peers.c.peer_id] is None:
|
||||
peer = None
|
||||
else:
|
||||
peer = self._parse_squeak_peer(row)
|
||||
|
|
@ -1172,7 +1216,7 @@ class SqueakDb:
|
|||
return SentPayment(
|
||||
sent_payment_id=row["sent_payment_id"],
|
||||
created=row[self.sent_payments.c.created],
|
||||
peer_hash=bytes.fromhex(row[self.sent_payments.c.peer_hash]),
|
||||
peer_id=row[self.sent_payments.c.peer_id],
|
||||
squeak_hash=bytes.fromhex(row["squeak_hash"]),
|
||||
payment_hash=bytes.fromhex(row["payment_hash"]),
|
||||
secret_key=bytes.fromhex(row["secret_key"]),
|
||||
|
|
@ -1183,7 +1227,7 @@ class SqueakDb:
|
|||
|
||||
def _parse_sent_payment_with_peer(self, row) -> SentPaymentWithPeer:
|
||||
sent_payment = self._parse_sent_payment(row)
|
||||
if row[self.peers.c.peer_hash] is None:
|
||||
if row[self.peers.c.peer_id] is None:
|
||||
peer = None
|
||||
else:
|
||||
peer = self._parse_squeak_peer(row)
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class PeerConnection:
|
|||
followed_addresses,
|
||||
min_block,
|
||||
max_block,
|
||||
self.peer.peer_hash,
|
||||
self.peer.peer_id,
|
||||
)
|
||||
# Get hashes to get offer
|
||||
hashes_to_get_offer = set(remote_hashes) & set(locked_hashes)
|
||||
|
|
@ -124,7 +124,7 @@ class PeerConnection:
|
|||
def _get_saved_offer(self, squeak_hash: bytes) -> Optional[ReceivedOfferWithPeer]:
|
||||
offers = self.squeak_controller.get_buy_offers_with_peer(squeak_hash)
|
||||
for offer_with_peer in offers:
|
||||
if offer_with_peer.received_offer.peer_hash == self.peer.peer_hash:
|
||||
if offer_with_peer.received_offer.peer_id == self.peer.peer_id:
|
||||
return offer_with_peer
|
||||
return None
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ from squeaknode.core.lightning_address import LightningAddressHostPort
|
|||
from squeaknode.core.squeak_controller import SqueakController
|
||||
from squeaknode.core.squeak_core import SqueakCore
|
||||
from squeaknode.core.squeak_peer import SqueakPeer
|
||||
from squeaknode.core.util import get_peer_hash
|
||||
from squeaknode.db.squeak_db import SqueakDb
|
||||
from squeaknode.node.squeak_rate_limiter import SqueakRateLimiter
|
||||
from squeaknode.node.squeak_whitelist import SqueakWhitelist
|
||||
|
|
@ -132,7 +131,7 @@ def test_create_peer(squeak_db, squeak_controller):
|
|||
|
||||
squeak_db.insert_peer.assert_called_with(
|
||||
SqueakPeer(
|
||||
peer_hash=get_peer_hash("fake_host", 5678),
|
||||
peer_id=None,
|
||||
peer_name="fake_peer_name",
|
||||
host="fake_host",
|
||||
port=5678,
|
||||
|
|
@ -151,10 +150,7 @@ def test_create_peer_default_port(config, squeak_db, squeak_controller):
|
|||
|
||||
squeak_db.insert_peer.assert_called_with(
|
||||
SqueakPeer(
|
||||
peer_hash=get_peer_hash(
|
||||
"fake_host",
|
||||
config.core.default_peer_rpc_port,
|
||||
),
|
||||
peer_id=None,
|
||||
peer_name="fake_peer_name",
|
||||
host="fake_host",
|
||||
port=config.core.default_peer_rpc_port,
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ def signing_profile():
|
|||
signing_key_str = str(signing_key)
|
||||
signing_key_bytes = signing_key_str.encode()
|
||||
return SqueakProfile(
|
||||
profile_id=None,
|
||||
profile_name=profile_name,
|
||||
private_key=signing_key_bytes,
|
||||
address=str(address),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue