Skip to content

Commit

Permalink
add txnFee to GetOrCreateID in nknd.go when registerring id
Browse files Browse the repository at this point in the history
add txnFee to GetOrCreateID in nknd.go when registerring id

Signed-off-by: NoelBright <[email protected]>
  • Loading branch information
NoelBright authored and gdmmx committed Aug 9, 2019
1 parent d1ac11d commit 1f8a140
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions nknd.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func nknMain(c *cli.Context) error {
// if InitLedger return err, chain.DefaultLedger is uninitialized.
defer chain.DefaultLedger.Store.Close()

id, err := GetOrCreateID(config.Parameters.SeedList, wallet, Fixed64(config.Parameters.RegisterIDFee))
id, err := GetOrCreateID(config.Parameters.SeedList, wallet, Fixed64(config.Parameters.RegisterIDRegFee), Fixed64(config.Parameters.RegisterIDTxnFee))
if err != nil {
panic(fmt.Errorf("Get or create id error: %v", err))
}
Expand Down Expand Up @@ -441,7 +441,7 @@ func GetID(seeds []string, publickey []byte) ([]byte, error) {
return nil, fmt.Errorf("failed to get ID from majority of %d seeds", n)
}

func CreateID(seeds []string, wallet vault.Wallet, regFee Fixed64) error {
func CreateID(seeds []string, wallet vault.Wallet, regFee, txnFee Fixed64) error {
account, err := wallet.GetDefaultAccount()
if err != nil {
return err
Expand All @@ -463,7 +463,7 @@ func CreateID(seeds []string, wallet vault.Wallet, regFee Fixed64) error {
continue
}

txn, err := common.MakeGenerateIDTransaction(wallet, regFee, nonce, 0)
txn, err := common.MakeGenerateIDTransaction(wallet, regFee, nonce, txnFee)
if err != nil {
return err
}
Expand All @@ -485,7 +485,7 @@ func CreateID(seeds []string, wallet vault.Wallet, regFee Fixed64) error {
return errors.New("create ID failed")
}

func GetOrCreateID(seeds []string, wallet vault.Wallet, regFee Fixed64) ([]byte, error) {
func GetOrCreateID(seeds []string, wallet vault.Wallet, regFee, txnFee Fixed64) ([]byte, error) {
account, err := wallet.GetDefaultAccount()
if err != nil {
return nil, err
Expand All @@ -497,7 +497,7 @@ func GetOrCreateID(seeds []string, wallet vault.Wallet, regFee Fixed64) ([]byte,
if err != nil {
log.Warningf("Get id from neighbors error: %v", err)
}
if err := CreateID(seeds, wallet, regFee); err != nil {
if err := CreateID(seeds, wallet, regFee, txnFee); err != nil {
return nil, err
}
} else if len(id) != config.NodeIDBytes {
Expand Down
6 changes: 4 additions & 2 deletions util/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ var (
TxPoolPerAccountTxCap: 32,
TxPoolTotalTxCap: 0,
TxPoolMaxMemorySize: 32,
RegisterIDFee: 0,
RegisterIDRegFee: 0,
RegisterIDTxnFee: 0,
LogPath: "Log",
ChainDBPath: "ChainDB",
WalletFile: "wallet.json",
Expand Down Expand Up @@ -161,7 +162,8 @@ type Configuration struct {
GenesisBlockProposer string `json:"GenesisBlockProposer"`
NumLowFeeTxnPerBlock uint32 `json:"NumLowFeeTxnPerBlock"`
MinTxnFee int64 `json:"MinTxnFee"`
RegisterIDFee int64 `json:"RegisterIDFee"`
RegisterIDRegFee int64 `json:"RegisterIDRegFee"`
RegisterIDTxnFee int64 `json:"RegisterIDTxnFee"`
Hostname string `json:"Hostname"`
Transport string `json:"Transport"`
NAT bool `json:"NAT"`
Expand Down

0 comments on commit 1f8a140

Please sign in to comment.