示例#1
0
        public static Nonced <InnerType> Mine <InnerType>(InnerType value, int zerosInFront, CancellationToken cancellationToken)
        {
            // TODO: This is a total no-no for competitive mining.
            long ourNonce = 1337;

            for (;;) // the cookie monster loop is the most delicious infinite loop
            {
                if (cancellationToken != null && cancellationToken.IsCancellationRequested)
                {
                    return(null);
                }
                Nonced <InnerType> attempt       = new Nonced <InnerType>(value, ourNonce);
                DagNode            attemptedNode = IpfsDagSerialization.MapToDag <Nonced <InnerType> >(attempt);

                bool match = FoundGoldenNonce(Base58.Decode(attemptedNode.Hash), zerosInFront);

                if (match)
                {
                    return(attempt);
                }

                ourNonce++;
            }
        }
示例#2
0
 public static bool FoundGoldenNonce(object obj, int zerosInFront)
 {
     return(FoundGoldenNonce(Base58.Decode(IpfsDagSerialization.MapToDag(obj).Hash), zerosInFront));
 }