|
|
@ -15,7 +15,7 @@ defmodule Explorer.Chain.StakingPool do |
|
|
|
@attrs ~w( |
|
|
|
@attrs ~w( |
|
|
|
is_active delegators_count staked_amount self_staked_amount is_validator |
|
|
|
is_active delegators_count staked_amount self_staked_amount is_validator |
|
|
|
was_validator_count is_banned was_banned_count banned_until likelihood |
|
|
|
was_validator_count is_banned was_banned_count banned_until likelihood |
|
|
|
staked_ratio min_delegators_stake min_candidate_stake |
|
|
|
staked_ratio min_delegator_stake min_candidate_stake |
|
|
|
staking_address_hash mining_address_hash |
|
|
|
staking_address_hash mining_address_hash |
|
|
|
)a |
|
|
|
)a |
|
|
|
|
|
|
|
|
|
|
@ -28,11 +28,12 @@ defmodule Explorer.Chain.StakingPool do |
|
|
|
field(:likelihood, :decimal) |
|
|
|
field(:likelihood, :decimal) |
|
|
|
field(:staked_ratio, :decimal) |
|
|
|
field(:staked_ratio, :decimal) |
|
|
|
field(:min_candidate_stake, Wei) |
|
|
|
field(:min_candidate_stake, Wei) |
|
|
|
field(:min_delegators_stake, Wei) |
|
|
|
field(:min_delegator_stake, Wei) |
|
|
|
field(:self_staked_amount, Wei) |
|
|
|
field(:self_staked_amount, Wei) |
|
|
|
field(:staked_amount, Wei) |
|
|
|
field(:staked_amount, Wei) |
|
|
|
field(:was_banned_count, :integer) |
|
|
|
field(:was_banned_count, :integer) |
|
|
|
field(:was_validator_count, :integer) |
|
|
|
field(:was_validator_count, :integer) |
|
|
|
|
|
|
|
field(:is_deleted, :boolean, default: false) |
|
|
|
|
|
|
|
|
|
|
|
belongs_to( |
|
|
|
belongs_to( |
|
|
|
:staking_address, |
|
|
|
:staking_address, |
|
|
@ -50,7 +51,7 @@ defmodule Explorer.Chain.StakingPool do |
|
|
|
type: Hash.Address |
|
|
|
type: Hash.Address |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
timestamps() |
|
|
|
timestamps(null: false, type: :utc_datetime_usec) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@doc false |
|
|
|
@doc false |
|
|
@ -59,6 +60,7 @@ defmodule Explorer.Chain.StakingPool do |
|
|
|
|> cast(attrs, @attrs) |
|
|
|
|> cast(attrs, @attrs) |
|
|
|
|> validate_required(@attrs) |
|
|
|
|> validate_required(@attrs) |
|
|
|
|> validate_staked_amount() |
|
|
|
|> validate_staked_amount() |
|
|
|
|
|
|
|
|> unique_constraint(:staking_address_hash) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
defp validate_staked_amount(%{valid?: false} = c), do: c |
|
|
|
defp validate_staked_amount(%{valid?: false} = c), do: c |
|
|
|