Beispiel #1
0
 public Block(Hash <Block>?previous, IMerkleTree <Message> inputMessages, IMerkleTree <Message> outputMessages, ChainState state)
 {
     Previous       = previous;
     InputMessages  = inputMessages;
     OutputMessages = outputMessages;
     State          = state;
 }
 public DetailsModel(TrustDBContext context, IMerkleTree merkleTree, IBlockchainServiceFactory blockchainServiceFactory, IWorkflowService workflowService, IConfiguration configuration)
 {
     _context    = context;
     _merkleTree = merkleTree;
     _blockchainServiceFactory = blockchainServiceFactory;
     _workflowService          = workflowService;
     _configuration            = configuration;
 }
 public CreateProofWorkflow(IMediator mediator, TrustDBContext db, IConfiguration configuration, ILogger <CreateProofWorkflow> logger, IMerkleTree merkleTree, IBlockchainServiceFactory blockchainServiceFactory, IKeyValueService keyValueService, IDTPApiService apiService)
 {
     _mediator                 = mediator;
     _db                       = db;
     _configuration            = configuration;
     _logger                   = logger;
     _merkleTree               = merkleTree;
     _blockchainServiceFactory = blockchainServiceFactory;
     _keyValueService          = keyValueService;
     _apiService               = apiService;
 }
Beispiel #4
0
        /// <summary>
        /// Creates a new instance of JobNotification.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="algorithm"></param>
        /// <param name="blockTemplate"></param>
        /// <param name="generationTransaction"></param>
        public Job(UInt64 id, IHashAlgorithm algorithm, IBlockTemplate blockTemplate, IGenerationTransaction generationTransaction)
        {
            // init the values.
            Id                        = id;
            HashAlgorithm             = algorithm;
            BlockTemplate             = blockTemplate;
            Height                    = blockTemplate.Height;
            GenerationTransaction     = generationTransaction;
            MetronomeHash             = blockTemplate.MetronomeHash.HexToByteArray().ToHexString();
            MetronomeHashReversed     = blockTemplate.MetronomeHash.HexToByteArray().ReverseByteOrder().ToHexString();
            RefHash                   = blockTemplate.RefHash.HexToByteArray().ToHexString();
            PreviousBlockHash         = blockTemplate.PreviousBlockHash.HexToByteArray().ToHexString();
            PreviousBlockHashReversed = blockTemplate.PreviousBlockHash.HexToByteArray().ReverseByteOrder().ToHexString();
            CoinbaseInitial           = generationTransaction.Initial.ToHexString();
            CoinbaseFinal             = generationTransaction.Final.ToHexString();
            CreationTime              = TimeHelpers.NowInUnixTimestamp();

            _shares = new List <UInt64>();

            // calculate the merkle tree
            MerkleTree = new MerkleTree(BlockTemplate.Transactions.GetHashList());

            // set version
            Version = BitConverter.GetBytes(blockTemplate.Version.BigEndian()).ToHexString();

            // set the encoded difficulty (bits)
            EncodedDifficulty = blockTemplate.Bits;

            // set the target
            Target = string.IsNullOrEmpty(blockTemplate.Target)
                ? EncodedDifficulty.BigIntFromBitsHex()
                : BigInteger.Parse(blockTemplate.Target, NumberStyles.HexNumber);

            // set the block diff
            Difficulty = ((double)new BigRational(AlgorithmManager.Diff1, Target));

            // set the ntime
            NTime = BitConverter.GetBytes(blockTemplate.CurTime.BigEndian()).ToHexString();
        }
Beispiel #5
0
        /// <summary>
        /// Creates a new instance of JobNotification.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="algorithm"></param>
        /// <param name="blockTemplate"></param>
        /// <param name="generationTransaction"></param>
        public Job(UInt64 id, IHashAlgorithm algorithm, IBlockTemplate blockTemplate, IGenerationTransaction generationTransaction)
        {
            // init the values.
            Id = id;
            HashAlgorithm = algorithm;
            BlockTemplate = blockTemplate;
            Height = blockTemplate.Height;
            GenerationTransaction = generationTransaction;
            PreviousBlockHash = blockTemplate.PreviousBlockHash.HexToByteArray().ToHexString();
            PreviousBlockHashReversed = blockTemplate.PreviousBlockHash.HexToByteArray().ReverseByteOrder().ToHexString();
            CoinbaseInitial = generationTransaction.Initial.ToHexString();
            CoinbaseFinal = generationTransaction.Final.ToHexString();
            CreationTime = TimeHelpers.NowInUnixTimestamp();

            _shares = new List<UInt64>();

            // calculate the merkle tree
            MerkleTree = new MerkleTree(BlockTemplate.Transactions.GetHashList());
        
            // set version
            Version = BitConverter.GetBytes(blockTemplate.Version.BigEndian()).ToHexString();

            // set the encoded difficulty (bits)
            EncodedDifficulty = blockTemplate.Bits;

            // set the target
            Target = string.IsNullOrEmpty(blockTemplate.Target)
                ? EncodedDifficulty.BigIntFromBitsHex()
                : BigInteger.Parse(blockTemplate.Target, NumberStyles.HexNumber);

            // set the block diff
            Difficulty = ((double)new BigRational(AlgorithmManager.Diff1, Target));

            // set the ntime
            NTime = BitConverter.GetBytes(blockTemplate.CurTime.BigEndian()).ToHexString();
        }
Beispiel #6
0
 public ChainState(IMerkleTree <AgentState> agentStates, int nextAgentNonce)
 {
     AgentStates    = agentStates;
     NextAgentNonce = nextAgentNonce;
 }
 public TimestampService(TrustDBContext dB, IBlockchainServiceFactory blockchainServiceFactory, IMerkleTree merkleTree)
 {
     DB = dB;
     _blockchainServiceFactory = blockchainServiceFactory;
     _merkleTree = merkleTree;
 }