Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PubNub on Ethereum "Web3" Decentralized Network as a Smart Contract
pragma solidity ^0.4.19;
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// PubNub on Ethereum "Web3" Decentralized Network as a Smart Contract
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
contract PubNubV1 {
mapping(bytes32 => mapping(bytes32 => bytes32)) private channel_groups;
mapping(bytes32 => mapping(bytes32 => bytes32)) private channel_presence;
event Message(
address indexed from
, bytes32 indexed channel
, string message
);
// TODO Byte Array for Message (allows sym-encryption)
function publish( bytes32 channel, string message ) public {
Message( msg.sender, channel, message );
}
// helper function to get as bytestring
function channelHash(string channel) internal pure returns (bytes32) {
return stringToBytes32(channel);
}
function stringToBytes32(string memory source) internal pure returns (bytes32 result) {
bytes memory tempEmptyStringTest = bytes(source);
if (tempEmptyStringTest.length == 0) {
return 0x0;
}
assembly {
result := mload(add(source, 32))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.