mirror of
https://github.com/kaspanet/kaspad.git
synced 2026-02-21 03:03:08 +00:00
Compare commits
6 Commits
try-6
...
miner-dela
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71efac329a | ||
|
|
54fbfadf84 | ||
|
|
1334454e4f | ||
|
|
d80144ef15 | ||
|
|
11bd3a7e3f | ||
|
|
e457503aea |
@@ -238,7 +238,7 @@ func (m *Manager) registerTransactionRelayFlow(router *routerpkg.Router, isStopp
|
||||
outgoingRoute := router.OutgoingRoute()
|
||||
|
||||
return []*flow{
|
||||
m.registerFlow("HandleRelayedTransactions", router,
|
||||
m.registerFlowWithCapacity("HandleRelayedTransactions", 10_000, router,
|
||||
[]appmessage.MessageCommand{appmessage.CmdInvTransaction, appmessage.CmdTx, appmessage.CmdTransactionNotFound}, isStopping, errChan,
|
||||
func(incomingRoute *routerpkg.Route, peer *peerpkg.Peer) error {
|
||||
return transactionrelay.HandleRelayedTransactions(m.context, incomingRoute, outgoingRoute)
|
||||
@@ -274,6 +274,24 @@ func (m *Manager) registerFlow(name string, router *routerpkg.Router, messageTyp
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return m.registerFlowForRoute(route, name, isStopping, errChan, initializeFunc)
|
||||
}
|
||||
|
||||
func (m *Manager) registerFlowWithCapacity(name string, capacity int, router *routerpkg.Router,
|
||||
messageTypes []appmessage.MessageCommand, isStopping *uint32,
|
||||
errChan chan error, initializeFunc flowInitializeFunc) *flow {
|
||||
|
||||
route, err := router.AddIncomingRouteWithCapacity(capacity, messageTypes)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return m.registerFlowForRoute(route, name, isStopping, errChan, initializeFunc)
|
||||
}
|
||||
|
||||
func (m *Manager) registerFlowForRoute(route *routerpkg.Route, name string, isStopping *uint32,
|
||||
errChan chan error, initializeFunc flowInitializeFunc) *flow {
|
||||
|
||||
return &flow{
|
||||
name: name,
|
||||
executeFunc: func(peer *peerpkg.Peer) {
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
|
||||
Kaspad v0.9.2 - 2021-03-31
|
||||
===========================
|
||||
* Increase the route capacity of InvTransaction messages. (#1603) (#1637)
|
||||
|
||||
Kaspad v0.9.1 - 2021-03-14
|
||||
===========================
|
||||
* Testnet network reset
|
||||
|
||||
@@ -38,6 +38,7 @@ type configFlags struct {
|
||||
MineWhenNotSynced bool `long:"mine-when-not-synced" description:"Mine even if the node is not synced with the rest of the network."`
|
||||
Profile string `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65536"`
|
||||
TargetBlocksPerSecond *float64 `long:"target-blocks-per-second" description:"Sets a maximum block rate. 0 means no limit (The default one is 2 * target network block rate)"`
|
||||
Delay int `long:"delay" hidden:"true"`
|
||||
config.NetworkFlags
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ func main() {
|
||||
|
||||
doneChan := make(chan struct{})
|
||||
spawn("mineLoop", func() {
|
||||
err = mineLoop(client, cfg.NumberOfBlocks, *cfg.TargetBlocksPerSecond, cfg.MineWhenNotSynced, miningAddr)
|
||||
err = mineLoop(client, cfg.NumberOfBlocks, *cfg.TargetBlocksPerSecond, cfg.MineWhenNotSynced, cfg.Delay, miningAddr)
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "error in mine loop"))
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ var hashesTried uint64
|
||||
const logHashRateInterval = 10 * time.Second
|
||||
|
||||
func mineLoop(client *minerClient, numberOfBlocks uint64, targetBlocksPerSecond float64, mineWhenNotSynced bool,
|
||||
miningAddr util.Address) error {
|
||||
delay int, miningAddr util.Address) error {
|
||||
rand.Seed(time.Now().UnixNano()) // Seed the global concurrent-safe random source.
|
||||
|
||||
errChan := make(chan error)
|
||||
@@ -79,6 +79,9 @@ func mineLoop(client *minerClient, numberOfBlocks uint64, targetBlocksPerSecond
|
||||
spawn("handleFoundBlock", func() {
|
||||
for i := uint64(0); numberOfBlocks == 0 || i < numberOfBlocks; i++ {
|
||||
block := <-foundBlockChan
|
||||
if delay > 0 {
|
||||
<-time.After(time.Duration(delay) * time.Second)
|
||||
}
|
||||
err := handleFoundBlock(client, block)
|
||||
if err != nil {
|
||||
errChan <- err
|
||||
|
||||
@@ -182,10 +182,10 @@ var testnetGenesisCoinbaseTx = transactionhelper.NewSubnetworkTransaction(0,
|
||||
// testnetGenesisHash is the hash of the first block in the block DAG for the test
|
||||
// network (genesis block).
|
||||
var testnetGenesisHash = externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{
|
||||
0x0f, 0x7f, 0x3f, 0x9d, 0x70, 0x8e, 0x58, 0x33,
|
||||
0xac, 0xb6, 0x50, 0xea, 0xcc, 0xb9, 0x74, 0x28,
|
||||
0x79, 0x54, 0xd6, 0xee, 0x00, 0x1c, 0xe8, 0x1c,
|
||||
0xad, 0x16, 0xcb, 0x84, 0xf0, 0xa2, 0x21, 0xd0,
|
||||
0x49, 0xa6, 0x19, 0xe4, 0x25, 0xa0, 0x8d, 0xae,
|
||||
0xd9, 0x67, 0x76, 0x82, 0xd8, 0x8e, 0x93, 0xa3,
|
||||
0xf5, 0x42, 0x5a, 0x02, 0x4d, 0x55, 0xef, 0x5e,
|
||||
0x39, 0x61, 0x9f, 0x2d, 0xd9, 0x51, 0xe4, 0x55,
|
||||
})
|
||||
|
||||
// testnetGenesisMerkleRoot is the hash of the first transaction in the genesis block
|
||||
@@ -206,9 +206,9 @@ var testnetGenesisBlock = externalapi.DomainBlock{
|
||||
testnetGenesisMerkleRoot,
|
||||
&externalapi.DomainHash{},
|
||||
&externalapi.DomainHash{},
|
||||
0x1777751272b,
|
||||
0x177e83f864a,
|
||||
0x1e7fffff,
|
||||
0x55c0,
|
||||
0x4d8e0,
|
||||
),
|
||||
Transactions: []*externalapi.DomainTransaction{testnetGenesisCoinbaseTx},
|
||||
}
|
||||
|
||||
@@ -256,11 +256,11 @@ var MainnetParams = Params{
|
||||
// TestnetParams defines the network parameters for the test Kaspa network.
|
||||
var TestnetParams = Params{
|
||||
K: defaultGHOSTDAGK,
|
||||
Name: "kaspa-testnet-3",
|
||||
Name: "kaspa-testnet-4",
|
||||
Net: appmessage.Testnet,
|
||||
RPCPort: "16210",
|
||||
DefaultPort: "16211",
|
||||
DNSSeeds: []string{"testnet-3-dnsseed.daglabs-dev.com"},
|
||||
DNSSeeds: []string{"testnet-4-dnsseed.daglabs-dev.com"},
|
||||
|
||||
// DAG parameters
|
||||
GenesisBlock: &testnetGenesisBlock,
|
||||
|
||||
@@ -35,13 +35,32 @@ func NewRouter() *Router {
|
||||
// be routed to the given `route`
|
||||
func (r *Router) AddIncomingRoute(messageTypes []appmessage.MessageCommand) (*Route, error) {
|
||||
route := NewRoute()
|
||||
err := r.initializeIncomingRoute(route, messageTypes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return route, nil
|
||||
}
|
||||
|
||||
// AddIncomingRouteWithCapacity registers the messages of types `messageTypes` to
|
||||
// be routed to the given `route` with a capacity of `capacity`
|
||||
func (r *Router) AddIncomingRouteWithCapacity(capacity int, messageTypes []appmessage.MessageCommand) (*Route, error) {
|
||||
route := newRouteWithCapacity(capacity)
|
||||
err := r.initializeIncomingRoute(route, messageTypes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return route, nil
|
||||
}
|
||||
|
||||
func (r *Router) initializeIncomingRoute(route *Route, messageTypes []appmessage.MessageCommand) error {
|
||||
for _, messageType := range messageTypes {
|
||||
if r.doesIncomingRouteExist(messageType) {
|
||||
return nil, errors.Errorf("a route for '%s' already exists", messageType)
|
||||
return errors.Errorf("a route for '%s' already exists", messageType)
|
||||
}
|
||||
r.setIncomingRoute(messageType, route)
|
||||
}
|
||||
return route, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemoveRoute unregisters the messages of types `messageTypes` from
|
||||
|
||||
@@ -11,7 +11,7 @@ const validCharacters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrs
|
||||
const (
|
||||
appMajor uint = 0
|
||||
appMinor uint = 9
|
||||
appPatch uint = 1
|
||||
appPatch uint = 2
|
||||
)
|
||||
|
||||
// appBuild is defined as a variable so it can be overridden during the build
|
||||
|
||||
Reference in New Issue
Block a user