CalculateWork() public method

public CalculateWork ( ) : UInt256
return UInt256
Exemplo n.º 1
0
 public static ChainedHeader CreateForGenesisBlock(BlockHeader genesisBlockHeader)
 {
     return new ChainedHeader
     (
         blockHeader: genesisBlockHeader,
         height: 0,
         totalWork: genesisBlockHeader.CalculateWork()
     );
 }
Exemplo n.º 2
0
        public static ChainedHeader CreateFromPrev(ChainedHeader prevChainedHeader, BlockHeader blockHeader, DateTimeOffset dateSeen)
        {
            var headerWork = blockHeader.CalculateWork();

            return new ChainedHeader(blockHeader,
                prevChainedHeader.Height + 1,
                prevChainedHeader.TotalWork + headerWork.ToBigInteger(),
                dateSeen);
        }
Exemplo n.º 3
0
 public static ChainedHeader CreateForGenesisBlock(BlockHeader genesisBlockHeader)
 {
     return(new ChainedHeader
            (
                blockHeader: genesisBlockHeader,
                height: 0,
                totalWork: genesisBlockHeader.CalculateWork()
            ));
 }
Exemplo n.º 4
0
        public static ChainedHeader CreateFromPrev(ChainedHeader prevChainedHeader, BlockHeader blockHeader, DateTimeOffset dateSeen)
        {
            var headerWork = blockHeader.CalculateWork();

            return(new ChainedHeader(blockHeader,
                                     prevChainedHeader.Height + 1,
                                     prevChainedHeader.TotalWork + headerWork.ToBigInteger(),
                                     dateSeen));
        }
Exemplo n.º 5
0
 public static ChainedHeader CreateForGenesisBlock(BlockHeader genesisBlockHeader)
 {
     return new ChainedHeader
     (
         blockHeader: genesisBlockHeader,
         height: 0,
         totalWork: genesisBlockHeader.CalculateWork().ToBigInteger(),
         dateSeen: DateTimeOffset.MinValue
     );
 }
Exemplo n.º 6
0
        public static ChainedHeader CreateFromPrev(ChainedHeader prevChainedHeader, BlockHeader blockHeader)
        {
            var headerWork = blockHeader.CalculateWork();
            if (headerWork < 0)
                return null;

            return new ChainedHeader(blockHeader,
                prevChainedHeader.Height + 1,
                prevChainedHeader.TotalWork + headerWork);
        }
Exemplo n.º 7
0
 public static ChainedHeader CreateForGenesisBlock(BlockHeader genesisBlockHeader)
 {
     return(new ChainedHeader
            (
                blockHeader: genesisBlockHeader,
                height: 0,
                totalWork: genesisBlockHeader.CalculateWork().ToBigInteger(),
                dateSeen: DateTimeOffset.MinValue
            ));
 }
Exemplo n.º 8
0
        public ChainedHeader GenesisChained()
        {
            if (this.blockHeaders.Count > 0)
                throw new InvalidOperationException();

            var blockHeader = new BlockHeader(0, UInt256.Zero, UInt256.Zero, 0, this.bits, this.nonce);
            this.totalWork = blockHeader.CalculateWork();

            var chainedHeader = new ChainedHeader(blockHeader, 0, this.totalWork);
            this.blockHeaders.Add(chainedHeader);

            return chainedHeader;
        }
Exemplo n.º 9
0
        public ChainedHeader NextChained(UInt32? bits = null)
        {
            if (this.blockHeaders.Count == 0)
                throw new InvalidOperationException();

            var prevBlockHeader = this.blockHeaders.Last();

            var blockHeader = new BlockHeader(0, prevBlockHeader.Hash, UInt256.Zero, 0, bits ?? this.bits, this.nonce);
            this.totalWork += blockHeader.CalculateWork();

            var chainedHeader = new ChainedHeader(blockHeader, this.blockHeaders.Count, this.totalWork);
            this.blockHeaders.Add(chainedHeader);

            return chainedHeader;
        }