private static AnnouncementPayLoad MakeAnnouncementKeyAndValueFrom(byte[] roomHash, byte[] ownerPubKey, byte[] payPeriodInDays, byte[] price) { byte[] key = Sha256(roomHash.Concat(ownerPubKey).Concat(payPeriodInDays).Concat(price)); object[] parameters = new object[] { roomHash, ownerPubKey, payPeriodInDays, price }; AnnouncementPayLoad payload = new AnnouncementPayLoad(); payload.key = key; payload.value = parameters.Serialize(); return(payload); }
public static void CreateAnnouncement(byte[] roomHash, byte[] ownerPubKey, byte[] payPeriodInDays, byte[] price) { if (!Runtime.CheckWitness(ownerPubKey)) { Runtime.Log("CheckWitness Failed"); return; } if (!CheckRoomAndOwner(roomHash, ownerPubKey)) { Runtime.Log("CheckRoomAndOwner Failed"); return; } StorageMap announcements = Storage.CurrentContext.CreateMap(announcementsStorageMapKey); AnnouncementPayLoad payload = MakeAnnouncementKeyAndValueFrom(roomHash, ownerPubKey, payPeriodInDays, price); Runtime.Notify(payload.key); announcements.Put(payload.key, payload.value); return; }