示例#1
0
文件: Tracker.cs 项目: MaxDZ8/fastdee
        /// <summary>
        /// As much as I am concerned, the device is 'working' if I have provided you a result to this call.
        /// If you fail to send over the wire, that's your concern.
        /// I also don't care about header format, as long as the dependancy from the work generator is there
        /// I'm happy with it.
        /// </summary>
        /// <returns>Null if no work available to be given.</returns>
        internal RequestedWork?ConsumeNonces(T originator, ulong scanCount)
        {
            var           devInfo = GetCurrently(originator);
            RequestedWork cooked;
            uint?         prev = null;

            lock (devInfo)
            {
                var work = genWork(scanCount);
                if (null == work)
                {
                    return(null);
                }
                var wid = (uint)work.uniq; // We hope to never have 2^32 work dispatch in flight!
                cooked = new RequestedWork(wid, work.header, work.target.TargD, work.nonceBase);
                var dispatching = new Dispatched(work, cooked);
                if (devInfo.dispatched != null)
                {
                    prev = devInfo.dispatched.provide.wid;
                }
                devInfo.Working(dispatching);
            }
            lock (crunching)
            {
                if (prev.HasValue)
                {
                    crunching.Remove(prev.Value);
                }
                crunching.Add(cooked.wid, devInfo);
            }
            return(cooked);
        }
示例#2
0
文件: Tracker.cs 项目: MaxDZ8/fastdee
 internal Dispatched(Work origin, RequestedWork provide)
 {
     this.origin  = origin;
     this.provide = provide;
 }