Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
destream-blockchain
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DeStream-public
destream-blockchain
Commits
0191a5d6
Commit
0191a5d6
authored
Aug 09, 2018
by
Pavel Pavlov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The research of the problem of the lack of connection with the wallet "Electrum"
parent
ecf81b95
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
19 deletions
+36
-19
Program.cs
Sources/DeStream.DeStreamD.ForTest/Program.cs
+12
-8
TestClassHelper.cs
Sources/DeStream.DeStreamD.ForTest/TestClassHelper.cs
+3
-3
CheckpointsTest.cs
...ratis.Bitcoin.Features.Consensus.Tests/CheckpointsTest.cs
+2
-0
NetworkPeerConnection.cs
Sources/Stratis.Bitcoin/P2P/Peer/NetworkPeerConnection.cs
+17
-7
launchSettings.json
Sources/Stratis.StratisD/Properties/launchSettings.json
+2
-1
No files found.
Sources/DeStream.DeStreamD.ForTest/Program.cs
View file @
0191a5d6
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
using
System.Threading
;
using
System.Threading
;
...
@@ -68,19 +69,22 @@ namespace DeStream.DeStreamD.ForTest
...
@@ -68,19 +69,22 @@ namespace DeStream.DeStreamD.ForTest
.
AddRPC
()
.
AddRPC
()
.
Build
();
.
Build
();
(
Wallet
wallet
,
Block
block
,
ChainedHeader
chainedHeader
)
result
=
TestClassHelper
.
CreateFirstTransaction
(
nodeSettings
,
node
.
WalletManager
(),
node
.
NodeService
<
WalletSettings
>(),
//
(Wallet wallet, Block block, ChainedHeader chainedHeader) result = TestClassHelper.CreateFirstTransaction(nodeSettings, node.WalletManager(), node.NodeService<WalletSettings>(),
node
.
NodeService
<
IWalletFeePolicy
>());
//
node.NodeService<IWalletFeePolicy>());
var
walletManager
=
node
.
WalletManager
();
//
var walletManager = node.WalletManager();
walletManager
.
Wallets
.
Add
(
result
.
wallet
);
//
walletManager.Wallets.Add(result.wallet);
HdAddress
addr
=
result
.
wallet
.
AccountsRoot
.
ElementAt
(
0
).
Accounts
.
ElementAt
(
0
).
ExternalAddresses
.
ElementAt
(
0
);
//
HdAddress addr = result.wallet.AccountsRoot.ElementAt(0).Accounts.ElementAt(0).ExternalAddresses.ElementAt(0);
Key
key
=
result
.
wallet
.
GetExtendedPrivateKeyForAddress
(
"password"
,
addr
).
PrivateKey
;
//
Key key = result.wallet.GetExtendedPrivateKeyForAddress("password", addr).PrivateKey;
TestClassHelper
.
CreateTestBlock
(
node
,
key
);
//
TestClassHelper.CreateTestBlock(node, key);
//walletManager.SaveWallets();
//walletManager.SaveWallets();
var
test
=
node
.
WalletManager
().
GetSpendableTransactionsInWallet
(
"myWallet1"
).
Sum
(
s
=>
s
.
Transaction
.
Amount
);
//var test = node.WalletManager().GetSpendableTransactionsInWallet("myWallet1").Sum(s => s.Transaction.Amount);
Process
currentProcess
=
Process
.
GetCurrentProcess
();
Console
.
WriteLine
(
"##############################: "
+
currentProcess
.
Id
.
ToString
());
int
qwe0
=
1
;
int
qwe0
=
1
;
if
(
node
!=
null
)
if
(
node
!=
null
)
await
node
.
RunAsync
();
await
node
.
RunAsync
();
...
...
Sources/DeStream.DeStreamD.ForTest/TestClassHelper.cs
View file @
0191a5d6
...
@@ -49,7 +49,7 @@ namespace DeStream.DeStreamD.ForTest
...
@@ -49,7 +49,7 @@ namespace DeStream.DeStreamD.ForTest
var
coinbase
=
new
Transaction
();
var
coinbase
=
new
Transaction
();
coinbase
.
AddInput
(
TxIn
.
CreateCoinbase
(
chain
.
Height
+
1
));
coinbase
.
AddInput
(
TxIn
.
CreateCoinbase
(
chain
.
Height
+
1
));
coinbase
.
AddOutput
(
new
TxOut
(
Get
9
Billion
(),
address
.
ScriptPubKey
));
coinbase
.
AddOutput
(
new
TxOut
(
Get
6
Billion
(),
address
.
ScriptPubKey
));
block
.
AddTransaction
(
coinbase
);
block
.
AddTransaction
(
coinbase
);
block
.
Header
.
Nonce
=
0
;
block
.
Header
.
Nonce
=
0
;
...
@@ -244,7 +244,7 @@ namespace DeStream.DeStreamD.ForTest
...
@@ -244,7 +244,7 @@ namespace DeStream.DeStreamD.ForTest
block
.
Header
.
UpdateTime
(
DateTimeOffset
.
UtcNow
,
fullNode
.
Network
,
fullNode
.
Chain
.
Tip
);
block
.
Header
.
UpdateTime
(
DateTimeOffset
.
UtcNow
,
fullNode
.
Network
,
fullNode
.
Chain
.
Tip
);
var
coinbase
=
new
Transaction
();
var
coinbase
=
new
Transaction
();
//coinbase.AddInput(TxIn.CreateCoinbase(fullNode.Chain.Height + 1));
//coinbase.AddInput(TxIn.CreateCoinbase(fullNode.Chain.Height + 1));
coinbase
.
AddOutput
(
new
TxOut
(
Get
9
Billion
(),
dest
.
GetAddress
()));
coinbase
.
AddOutput
(
new
TxOut
(
Get
6
Billion
(),
dest
.
GetAddress
()));
block
.
AddTransaction
(
coinbase
);
block
.
AddTransaction
(
coinbase
);
if
(
passedTransactions
?.
Any
()
??
false
)
if
(
passedTransactions
?.
Any
()
??
false
)
{
{
...
...
Sources/Stratis.Bitcoin.Features.Consensus.Tests/CheckpointsTest.cs
View file @
0191a5d6
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Text
;
using
NBitcoin
;
using
NBitcoin
;
using
Stratis.Bitcoin.Configuration.Settings
;
using
Stratis.Bitcoin.Consensus
;
using
Xunit
;
using
Xunit
;
namespace
Stratis.Bitcoin.Features.Consensus.Tests
namespace
Stratis.Bitcoin.Features.Consensus.Tests
...
...
Sources/Stratis.Bitcoin/P2P/Peer/NetworkPeerConnection.cs
View file @
0191a5d6
...
@@ -150,7 +150,7 @@ namespace Stratis.Bitcoin.P2P.Peer
...
@@ -150,7 +150,7 @@ namespace Stratis.Bitcoin.P2P.Peer
this
.
MessageProducer
.
PushMessage
(
incomingMessage
);
this
.
MessageProducer
.
PushMessage
(
incomingMessage
);
}
}
}
}
catch
(
OperationCanceledException
)
catch
(
OperationCanceledException
ex
)
{
{
this
.
logger
.
LogTrace
(
"Receiving cancelled."
);
this
.
logger
.
LogTrace
(
"Receiving cancelled."
);
this
.
peer
.
Disconnect
(
"Receiving cancelled."
);
this
.
peer
.
Disconnect
(
"Receiving cancelled."
);
...
@@ -340,7 +340,7 @@ namespace Stratis.Bitcoin.P2P.Peer
...
@@ -340,7 +340,7 @@ namespace Stratis.Bitcoin.P2P.Peer
/// <exception cref="ProtocolViolationException">Thrown if the incoming message is too big.</exception>
/// <exception cref="ProtocolViolationException">Thrown if the incoming message is too big.</exception>
private
async
Task
<
byte
[
]>
ReadMessageAsync
(
ProtocolVersion
protocolVersion
,
CancellationToken
cancellation
=
default
(
CancellationToken
))
private
async
Task
<
byte
[
]>
ReadMessageAsync
(
ProtocolVersion
protocolVersion
,
CancellationToken
cancellation
=
default
(
CancellationToken
))
{
{
this
.
logger
.
LogTrace
(
"({0}:{1})"
,
nameof
(
protocolVersion
),
protocolVersion
);
//
this.logger.LogTrace("({0}:{1})", nameof(protocolVersion), protocolVersion);
// First find and read the magic.
// First find and read the magic.
await
this
.
ReadMagicAsync
(
this
.
network
.
MagicBytes
,
cancellation
).
ConfigureAwait
(
false
);
await
this
.
ReadMagicAsync
(
this
.
network
.
MagicBytes
,
cancellation
).
ConfigureAwait
(
false
);
...
@@ -411,7 +411,7 @@ namespace Stratis.Bitcoin.P2P.Peer
...
@@ -411,7 +411,7 @@ namespace Stratis.Bitcoin.P2P.Peer
this
.
logger
.
LogTrace
(
"(-)"
);
this
.
logger
.
LogTrace
(
"(-)"
);
}
}
static
int
_offset
=
0
;
/// <summary>
/// <summary>
/// Reads a specific number of bytes from the connection stream into a buffer.
/// Reads a specific number of bytes from the connection stream into a buffer.
/// </summary>
/// </summary>
...
@@ -423,11 +423,20 @@ namespace Stratis.Bitcoin.P2P.Peer
...
@@ -423,11 +423,20 @@ namespace Stratis.Bitcoin.P2P.Peer
/// <exception cref="OperationCanceledException">Thrown if the operation was cancelled or the end of the stream was reached.</exception>
/// <exception cref="OperationCanceledException">Thrown if the operation was cancelled or the end of the stream was reached.</exception>
private
async
Task
ReadBytesAsync
(
byte
[]
buffer
,
int
offset
,
int
bytesToRead
,
CancellationToken
cancellation
=
default
(
CancellationToken
))
private
async
Task
ReadBytesAsync
(
byte
[]
buffer
,
int
offset
,
int
bytesToRead
,
CancellationToken
cancellation
=
default
(
CancellationToken
))
{
{
this
.
logger
.
LogTrace
(
"({0}:{1},{2}:{3})"
,
nameof
(
offset
),
offset
,
nameof
(
bytesToRead
),
bytesToRead
);
//
this.logger.LogTrace("({0}:{1},{2}:{3})", nameof(offset), offset, nameof(bytesToRead), bytesToRead);
while
(
bytesToRead
>
0
)
while
(
bytesToRead
>
0
)
{
{
int
chunkSize
=
await
this
.
stream
.
ReadAsync
(
buffer
,
offset
,
bytesToRead
,
cancellation
).
ConfigureAwait
(
false
);
int
chunkSize
=
0
;
try
{
chunkSize
=
this
.
stream
.
Read
(
buffer
,
offset
,
bytesToRead
);
//chunkSize = await this.stream.ReadAsync(buffer, offset, bytesToRead, cancellation).ConfigureAwait(false);
}
catch
(
Exception
ex
)
{
int
qwe
=
1
;
_offset
=
0
;
}
if
(
chunkSize
==
0
)
if
(
chunkSize
==
0
)
{
{
this
.
logger
.
LogTrace
(
"(-)[STREAM_END]"
);
this
.
logger
.
LogTrace
(
"(-)[STREAM_END]"
);
...
@@ -435,10 +444,11 @@ namespace Stratis.Bitcoin.P2P.Peer
...
@@ -435,10 +444,11 @@ namespace Stratis.Bitcoin.P2P.Peer
}
}
offset
+=
chunkSize
;
offset
+=
chunkSize
;
_offset
+=
offset
;
bytesToRead
-=
chunkSize
;
bytesToRead
-=
chunkSize
;
}
}
this
.
logger
.
LogTrace
(
"(-)"
);
//
this.logger.LogTrace("(-)");
}
}
/// <summary>
/// <summary>
...
@@ -456,7 +466,7 @@ namespace Stratis.Bitcoin.P2P.Peer
...
@@ -456,7 +466,7 @@ namespace Stratis.Bitcoin.P2P.Peer
/// </remarks>
/// </remarks>
private
async
Task
<
Message
>
ReadAndParseMessageAsync
(
ProtocolVersion
protocolVersion
,
CancellationToken
cancellation
)
private
async
Task
<
Message
>
ReadAndParseMessageAsync
(
ProtocolVersion
protocolVersion
,
CancellationToken
cancellation
)
{
{
this
.
logger
.
LogTrace
(
"({0}:{1})"
,
nameof
(
protocolVersion
),
protocolVersion
);
//
this.logger.LogTrace("({0}:{1})", nameof(protocolVersion), protocolVersion);
Message
message
=
null
;
Message
message
=
null
;
...
...
Sources/Stratis.StratisD/Properties/launchSettings.json
View file @
0191a5d6
{
{
"profiles"
:
{
"profiles"
:
{
"Stratis.StratisD"
:
{
"Stratis.StratisD"
:
{
"commandName"
:
"Project"
"commandName"
:
"Project"
,
"commandLineArgs"
:
"-testnode"
},
},
"Stratis.StratisD Test"
:
{
"Stratis.StratisD Test"
:
{
"commandName"
:
"Project"
,
"commandName"
:
"Project"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment