/// <summary> /// Serialize a work unit so it goes over the wire to a device. /// The structure must be common to all devices and algorithm implementations but the header can really be /// arbitrary payload as long as it's in the format the device expects. /// Each algorithm implementation takes a different payload so this can't just consume a <see cref="RequestedWork"/>. /// </summary> /// <returns>Opaque blob to send back to device.</returns> static internal byte[] YourWork(uint wid, IReadOnlyList <byte> payload) { var blob = new byte[1 + 4 + payload.Count]; var store = StoreOps.StoreKind(blob, OutgoingKind.WorkUnit); store = StoreOps.StoreUint(store, wid); store = StoreOps.StoreByteList(store, payload); ThrowIfNotFullyConsumed(store); return(blob); }
public void UintStoredBigEndian() { var blob = new byte[4]; var span = StoreOps.StoreUint(blob, 0xABCDEF01); Assert.True(span.IsEmpty); Assert.Equal(0x01, blob[0]); Assert.Equal(0xEF, blob[1]); Assert.Equal(0xCD, blob[2]); Assert.Equal(0xAB, blob[3]); }